AtCoder Grand Contest 011

Submission #1365311

Source codeソースコード

    #include<bits/stdc++.h>
    #define rep(i,k,n) for(int i=k;i<=n;i++)
    #define rep2(i,k,n) for(int i=k;i>=n;i--)
    using namespace std;
    const int N=5e5+7;
    char s[N];
    int a[N],n,now;
    int main(){
    	scanf("%s",s+1);
    	n=strlen(s+1);
    	rep(i,1,n)a[i+1]=s[i]-'0';
    	
    	int c=0;
    	rep2(i,n+1,1){
    		int res=a[i]*9 + c;
    		a[i]=res%10;
    		c=res/10;
    		now+=a[i];
    	}
    		c=9;
    		rep2(i,n+1,0){
    			if(a[i]+c < 10){
    				now+=c;
    				a[i]+=c;
    				break;
    			}else{
    				now-=a[i];
    				int res=a[i]+c;
    				c=res/10;
    				a[i]=res%10;
    				now+=a[i];
    			}
    		}
    	rep(k,1,1000000){
    		if(now<=9*k){
    			printf("%d\n",k);
    			return 0;
    		}
    	}
    }

Submission

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

Compiler messageコンパイルメッセージ

./Main.cpp: In function ‘int main()’:
./Main.cpp:9:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%s",s+1);
^

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 WA
in10.txt WA
in11.txt WA
in12.txt WA
in13.txt WA
in14.txt WA
in15.txt WA
in16.txt WA
in17.txt WA
in18.txt AC 5 ms 2688 KB
in19.txt WA
in2.txt WA
in20.txt WA
in21.txt WA
in22.txt WA
in23.txt WA
in24.txt WA
in25.txt WA
in26.txt WA
in27.txt WA
in28.txt AC 5 ms 2688 KB
in29.txt WA
in3.txt AC 5 ms 2688 KB
in30.txt WA
in31.txt AC 5 ms 2688 KB
in4.txt WA
in5.txt WA
in500000.txt AC 5 ms 2688 KB
in6.txt WA
in7.txt AC 4 ms 2176 KB
in8.txt WA
in9.txt WA
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