Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
这题目数据貌似有点问题?哪位看一下![Code 1]: #include<stdio.h> int a[2][1000001]; int main() { long n,i; scanf("%ld",&n); for(i=n-1;i>=0;i--) { scanf("%d%d",&a[0][i],&a[1][i]); a[0][i]+=a[1][i]; } for(i=0;i<n;i++) { a[0][i+1]+=a[0][i]/10; a[0][i]=a[0][i]%10; } for(i=n-1;i>=0;i--)printf("%d",a[0][i]); } [Code 2]: #include<stdio.h> int a[2][1000001]; int main() { long n,i; scanf("%ld",&n); for(i=n-1;i>=0;i--) { scanf("%d%d",&a[0][i],&a[1][i]); a[0][i]+=a[1][i]; } for(i=0;i<n;i++) { a[0][i+1]+=a[0][i]/10; a[0][i]=a[0][i]%10; } if(a[0][i]!=0)printf("1"); for(i=n-1;i>=0;i--)printf("%d",a[0][i]); } 两个都AC了,但第一个计算99+99时就不对了。因为没进位,是数据问题还是我理解错了? Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator