AtCoder Grand Contest 011

Submission #1359080

Source codeソースコード

#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

Task問題 E - Increasing Numbers
User nameユーザ名 alex99
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 TLE
Score得点 0
Source lengthソースコード長 1059 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample1.txt,sample2.txt,sample3.txt,sample4.txt
All 0 / 1300 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
in1.txt AC 151 ms 4352 KB
in10.txt TLE
in11.txt AC 22 ms 6400 KB
in12.txt TLE
in13.txt TLE
in14.txt TLE
in15.txt TLE
in16.txt TLE
in17.txt AC 25 ms 6400 KB
in18.txt TLE
in19.txt TLE
in2.txt TLE
in20.txt AC 1783 ms 6400 KB
in21.txt TLE
in22.txt TLE
in23.txt TLE
in24.txt TLE
in25.txt TLE
in26.txt TLE
in27.txt TLE
in28.txt TLE
in29.txt TLE
in3.txt TLE
in30.txt TLE
in31.txt TLE
in4.txt TLE
in5.txt AC 198 ms 6400 KB
in500000.txt AC 22 ms 6400 KB
in6.txt TLE
in7.txt TLE
in8.txt AC 31 ms 6400 KB
in9.txt TLE
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