Submission #3413981
Source Code Expand
// Skqliao #include <bits/stdc++.h> #define rep(i, l, r) for (__typeof(l) i = (l), _##i##_ = (r); i < _##i##_; ++i) #define rof(i, l, r) for (__typeof(l) i = (l) - 1, _##i##_ = (r); i >= _##i##_; --i) #define SZ(x) (int)x.size() #define ALL(x) x.begin(), x.end() template<typename T> bool chkMax(T &x, const T& y) {return x < y ? (x = y), 1 : 0;} template<typename T> bool chkMin(T &x, const T& y) {return x > y ? (x = y), 1 : 0;} typedef long long ll; #define debug(...) fprintf(stderr, __VA_ARGS__) #define DEBUG debug("passing %d in %s\n", __LINE__, __FUNCTION__) const int MAXN = 50000 + 5; char Str[MAXN]; int N; bool check(int x) { static int A[MAXN]; int len = N - 1, sum = 0; rep(i, 0, N) { A[i] = (Str[i] - '0') * 9; } A[0] += 9 * x; for(int i = 0; i <= len; ++i) { if(i == len && A[i] > 9) { A[++len] = 0; } A[i + 1] += A[i] / 10; A[i] %= 10; sum += A[i]; } return sum <= 9 * x; } int main() { scanf("%s", Str); N = strlen(Str); std::reverse(Str, Str + N); int l = 1, r = N; int ans = 0; while(l <= r) { int m = (l + r) >> 1; if(check(m)) { ans = m; r = m - 1; } else { l = m + 1; } } printf("%d\n", ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Increasing Numbers |
User | Skqliao |
Language | C++ (GCC 5.4.1) |
Score | 0 |
Code Size | 1237 Byte |
Status | RE |
Exec Time | 98 ms |
Memory | 512 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:39:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%s", Str); ^
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 1300 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample1.txt, sample2.txt, sample3.txt, sample4.txt |
All | sample1.txt, sample2.txt, sample3.txt, sample4.txt, in1.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in2.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, in27.txt, in28.txt, in29.txt, in3.txt, in30.txt, in31.txt, in4.txt, in5.txt, in500000.txt, in6.txt, in7.txt, in8.txt, in9.txt, sample1.txt, sample2.txt, sample3.txt, sample4.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
in1.txt | AC | 2 ms | 256 KB |
in10.txt | RE | 96 ms | 512 KB |
in11.txt | RE | 96 ms | 512 KB |
in12.txt | RE | 98 ms | 512 KB |
in13.txt | RE | 97 ms | 512 KB |
in14.txt | RE | 97 ms | 512 KB |
in15.txt | RE | 97 ms | 512 KB |
in16.txt | RE | 96 ms | 512 KB |
in17.txt | RE | 97 ms | 512 KB |
in18.txt | RE | 96 ms | 512 KB |
in19.txt | RE | 96 ms | 512 KB |
in2.txt | RE | 97 ms | 512 KB |
in20.txt | RE | 97 ms | 512 KB |
in21.txt | RE | 97 ms | 512 KB |
in22.txt | RE | 97 ms | 512 KB |
in23.txt | RE | 97 ms | 512 KB |
in24.txt | RE | 96 ms | 512 KB |
in25.txt | RE | 97 ms | 512 KB |
in26.txt | RE | 97 ms | 512 KB |
in27.txt | RE | 97 ms | 512 KB |
in28.txt | RE | 96 ms | 512 KB |
in29.txt | RE | 97 ms | 512 KB |
in3.txt | RE | 97 ms | 512 KB |
in30.txt | RE | 97 ms | 512 KB |
in31.txt | RE | 96 ms | 512 KB |
in4.txt | RE | 97 ms | 512 KB |
in5.txt | RE | 97 ms | 512 KB |
in500000.txt | RE | 98 ms | 512 KB |
in6.txt | RE | 98 ms | 512 KB |
in7.txt | RE | 97 ms | 512 KB |
in8.txt | RE | 97 ms | 512 KB |
in9.txt | RE | 98 ms | 512 KB |
sample1.txt | AC | 1 ms | 256 KB |
sample2.txt | AC | 1 ms | 256 KB |
sample3.txt | AC | 1 ms | 256 KB |
sample4.txt | AC | 1 ms | 256 KB |