AtCoder Beginner Contest 001

Submission #2820017

Source codeソースコード

#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int a[1002],b[1002],c[1002];
int main()
{

	int i,j,k,len,f1=1,f2=1,f,x;
	string s1,s2,t;
	cin>>s1>>s2;
	if(s1[0]=='-') 
		{f1=-1;s1.erase(0,1);}
	if(s2[0]=='-') 
		{f2=-1;s2.erase(0,1);}
	if(s1.size()<s2.size()){t=s1;s1=s2;s2=t;if(f2==1) cout<<"-";}
	else if(s1.size()==s2.size()&&(s1<s2)){t=s1;s1=s2;s2=t;if(f2==1) cout<<"-";}
		 else if(f1==-1) cout<<"-";
	for(i=1;i<=s1.size();i++)
		a[i]=s1[s1.size()-i]-48;
	for(i=1;i<=s2.size();i++)
		b[i]=s2[s2.size()-i]-48;
	if(f1*f2==1)
		{for(i=1;i<=s1.size();i++)
			{if(a[i]<b[i])	{a[i]=a[i]+10;a[i+1]--;	}
			c[i]=a[i]-b[i];
			}
		}
	if(f1*f2==-1)
		{x=0;
		for(i=1;i<=s1.size()+1;i++)
			{c[i]=a[i]+b[i]+x;
			x=c[i]/10;
			c[i]=c[i]%10;
			}
		}
	len=s1.size()+1;
	while(c[len]==0&&len>1) len--;
	for(i=len;i>=1;i--)
		cout<<c[i];
  cout<<endl;		
} 

Submission

Task問題 A - 積雪深差
User nameユーザ名 luogu_bot1
Created time投稿日時
Language言語 C++ (GCC 5.4.1)
Status状態 AC
Score得点 100
Source lengthソースコード長 874 Byte
File nameファイル名
Exec time実行時間 1 ms
Memory usageメモリ使用量 256 KB

Test case

Set

Set name Score得点 / Max score Cases
all 100 / 100 00_sample_01.txt,00_sample_02.txt,00_sample_03.txt,test_01.txt,test_02.txt,test_03.txt,test_04.txt,test_05.txt,test_06.txt,test_07.txt,test_08.txt,test_09.txt,test_10.txt,test_11.txt,test_12.txt,test_13.txt,test_14.txt,test_15.txt,test_16.txt,test_17.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
00_sample_01.txt AC 1 ms 256 KB
00_sample_02.txt AC 1 ms 256 KB
00_sample_03.txt AC 1 ms 256 KB
test_01.txt AC 1 ms 256 KB
test_02.txt AC 1 ms 256 KB
test_03.txt AC 1 ms 256 KB
test_04.txt AC 1 ms 256 KB
test_05.txt AC 1 ms 256 KB
test_06.txt AC 1 ms 256 KB
test_07.txt AC 1 ms 256 KB
test_08.txt AC 1 ms 256 KB
test_09.txt AC 1 ms 256 KB
test_10.txt AC 1 ms 256 KB
test_11.txt AC 1 ms 256 KB
test_12.txt AC 1 ms 256 KB
test_13.txt AC 1 ms 256 KB
test_14.txt AC 1 ms 256 KB
test_15.txt AC 1 ms 256 KB
test_16.txt AC 1 ms 256 KB
test_17.txt AC 1 ms 256 KB