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

Re:为什么测试了各种数据都是对的,但是提交的时候却还是Wrong呢???求大神帮助呀

Posted by limuyun at 2015-03-01 16:46:25 on Problem 1503
In Reply To:为什么测试了各种数据都是对的,但是提交的时候却还是Wrong呢???求大神帮助呀 Posted by:zhjacm at 2013-04-09 23:22:04
> #include<iostream>
> using namespace std;
> int main()
> {
> 	char temp[100];
> int sum[100]={0},i,s,j,k=0,t=0;
> while(cin>>temp,temp[0]!='0')
> 	{	
> 	int m[100]={0};
> 	for(i=0;temp[i]!='\0';i++);
> 	    if(i>k)
> 		k=i;
> 	 for(j=100-i,s=0;j<100;s++,j++)
> 			m[j]=temp[s]-48;
> 		for(j=99;j>99-k;j--)
> 		{
> 			sum[j]+=m[j];
> 			if(j==100-k)
> 			break;
> 			if(sum[j]>=10)
> 			{
> 				sum[j]-=10;
> 				sum[j-1]+=1;
> 			}
> 		}
> 		for(i=0;i<100;i++)
> 			temp[i]='\0';t++;
> 	}
> 
> 	for(i=100-k;i<100;i++)
> 		cout<<sum[i];
> 	cout<<endl;
> 	return 0;
> }
> 
> var sum:array[1..1000] of integer;
    st:string;
    i,l:integer;
begin
  readln(st);
  while st<>'0' do
    begin
      l:=length(st);
      for i:=1 to l do
        begin
          inc(sum[i],ord(st[l+1-i])-ord('0'));
          if sum[i]>=10 then
            begin
              inc(sum[i+1],sum[i] div 10);
              sum[i]:=sum[i] mod 10;
            end;
        end;
      readln(st);
    end;
  while sum[l]>0 do inc(l);
  dec(l);
  for i:=l downto 1 do write(sum[i]);
  writeln;
end.

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