Submission #1359080
Source Code Expand
#include <iostream> #include <cstring> using namespace std; int N[1000005]; char Str[500005]; int nine[1000005], sum, limit; void Read() { cin.getline(Str, 500005); int len = strlen(Str); for(int i = len - 1; i >= 0; i--) { N[++N[0]] = Str[i] - '0'; } limit = N[0]; } void Add() { int t = 0; for(int i = 1; i <= N[0] || i <= nine[0] || t; i++) { sum -= N[i]; N[i] = (N[i] + nine[i] + t); t = N[i] / 10; N[i] %= 10; sum += N[i]; } } void mul() { int i, t = 0; for (i = 1; i <= N[0] || t; i++, t /= 10) N[i] = (t += N[i] * 9) % 10; N[0] = i - 1; for(int i = 1; i <= N[0]; i++) sum += N[i]; } void Solve() { mul(); nine[0] = 1; nine[1] = 9; for(int k = 1; k <= limit; k++) { Add(); if(sum <= 9 * k) { cout << k << "\n"; return; } } } int main() { Read(); Solve(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Increasing Numbers |
User | alex99 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1059 Byte |
Status | TLE |
Exec Time | 2107 ms |
Memory | 6400 KB |
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 | 151 ms | 4352 KB |
in10.txt | TLE | 2103 ms | 6400 KB |
in11.txt | AC | 22 ms | 6400 KB |
in12.txt | TLE | 2103 ms | 6400 KB |
in13.txt | TLE | 2103 ms | 6400 KB |
in14.txt | TLE | 2103 ms | 6400 KB |
in15.txt | TLE | 2103 ms | 6400 KB |
in16.txt | TLE | 2103 ms | 6400 KB |
in17.txt | AC | 25 ms | 6400 KB |
in18.txt | TLE | 2103 ms | 6400 KB |
in19.txt | TLE | 2103 ms | 6400 KB |
in2.txt | TLE | 2103 ms | 6400 KB |
in20.txt | AC | 1783 ms | 6400 KB |
in21.txt | TLE | 2103 ms | 6400 KB |
in22.txt | TLE | 2103 ms | 6400 KB |
in23.txt | TLE | 2103 ms | 6400 KB |
in24.txt | TLE | 2103 ms | 6400 KB |
in25.txt | TLE | 2103 ms | 6400 KB |
in26.txt | TLE | 2103 ms | 6400 KB |
in27.txt | TLE | 2103 ms | 4352 KB |
in28.txt | TLE | 2107 ms | 6400 KB |
in29.txt | TLE | 2103 ms | 6400 KB |
in3.txt | TLE | 2103 ms | 6400 KB |
in30.txt | TLE | 2103 ms | 6400 KB |
in31.txt | TLE | 2103 ms | 6400 KB |
in4.txt | TLE | 2103 ms | 6400 KB |
in5.txt | AC | 198 ms | 6400 KB |
in500000.txt | AC | 22 ms | 6400 KB |
in6.txt | TLE | 2103 ms | 6400 KB |
in7.txt | TLE | 2103 ms | 4352 KB |
in8.txt | AC | 31 ms | 6400 KB |
in9.txt | TLE | 2103 ms | 6400 KB |
sample1.txt | AC | 2 ms | 4352 KB |
sample2.txt | AC | 2 ms | 4352 KB |
sample3.txt | AC | 2 ms | 4352 KB |
sample4.txt | AC | 2 ms | 4352 KB |