Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

这题目数据貌似有点问题?哪位看一下!

Posted by chenyy at 2007-07-30 12:18:13 on Problem 2602
[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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator