AtCoder Grand Contest 011

Submission #1365304

Source codeソースコード

#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
const double PI=acos(-1);
typedef long long ll;
typedef pair<int,int> pi;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for (int i=(a);i<=(b);i++)
#define per(i,a,b) for (int i=(a);i>=(b);i--)
#define Rep(i,a,b) for (int i=(a);i<(b);i++)
#define Per(i,a,b) for (int i=(a);i>(b);i--)
//debug
#define deb printf("begin\n");
#define dee printf("end\n");
#define def printf("find\n");
#define dey printf("Yes\n");
#define den printf("No\n");
#define dew printf("wrong\n");
void read(int&x){
	x=0;int f=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if (ch=='-')f=-1,ch=getchar();
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=f;
}
//--------------------------head--------------------------//
#define maxn 500005
char s[maxn];int a[maxn],n,now;
int main(){
   	scanf("%s",s+1);n=strlen(s+1);
    rep(i,1,n)a[i+1]=s[i]-'0';
    	
    int lst=0;per(i,n+1,1){int res=a[i]*9+lst;a[i]=res%10;lst=res/10;now+=a[i];}
    //rep(i,1,n+1)printf("%d",a[i]);printf("\n");
    lst=9;
    per(i,n+1,0){
    	//printf("%d\n",a[i]+lst);
    	if(a[i]+lst<10){now+=lst;a[i]+=lst;break;}
    	else{
    			now-=a[i];
    			int res=a[i]+lst;
    			lst=res/10;
    			a[i]=res%10;
    			now+=a[i];
   			}
   	}
    //rep(i,1,n+1)printf("%d",a[i]);printf("\n");
    //printf("%d\n",now);
   	printf("%d\n",(now+8)/9);
}

Submission

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

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

./Main.cpp: In function ‘int main()’:
./Main.cpp:40:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%s",s+1);n=strlen(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 4 ms 2560 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 4 ms 2560 KB
in29.txt WA
in3.txt AC 4 ms 2560 KB
in30.txt WA
in31.txt AC 4 ms 2560 KB
in4.txt WA
in5.txt WA
in500000.txt AC 4 ms 2560 KB
in6.txt WA
in7.txt AC 4 ms 2048 KB
in8.txt WA
in9.txt WA
sample1.txt AC 1 ms 128 KB
sample2.txt AC 1 ms 128 KB
sample3.txt AC 1 ms 128 KB
sample4.txt AC 1 ms 128 KB