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

我的程序为何WA?

Posted by sza at 2006-02-23 19:27:07 on Problem 2602
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[]) throws Exception {
	int array1[]=new int[1000001];
        int array2[]=new int[1000001];
        int sum[]=new int[1000001];
        int i;
        int ci=0;
        BufferedReader stdin =
                new BufferedReader(
                new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(stdin.readLine());    
              
        
	int N=Integer.parseInt(st.nextToken()); 
        for(i=0;i<N;i++){
            st = new StringTokenizer(stdin.readLine());
            array1[i]=Integer.parseInt(st.nextToken());
            array2[i]=Integer.parseInt(st.nextToken());
            sum[i]=0;
        }
        for(i=N-1;i>=0;i--){
            sum[i]=(array1[i]+array2[i]+ci)%10;
            ci=(array1[i]+array2[i])/10;
        }
        for(i=0;i<N;i++){
            System.out.print(sum[i]);
        }
        System.out.println(); 
    }
}

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