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……

Posted by FinalLaugh at 2004-09-27 15:06:59 on Problem 1840
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        String str=in.readLine();
        StringTokenizer st=new StringTokenizer(str," ");
        int a1=Integer.parseInt(st.nextToken());
        int a2=Integer.parseInt(st.nextToken());
        int a3=Integer.parseInt(st.nextToken());
        int a4=-Integer.parseInt(st.nextToken());
        int a5=-Integer.parseInt(st.nextToken());
        int[]pow=new int[101];
        for (int i=-50;i<0;i++){
            pow[i+50]=i*i*i;
            pow[i+101]=(i+51)*(i+51)*(i+51);
        }
        int[]val1=new int[2000000];
        int[]val2=new int[2000000];
        int p1=0;
        int p2=0;
        //*
        for (int i=-50;i<=50;i++){
            if (i==0)i=1;
            for (int j=-50;j<=50;j++){
                if(j==0)j=1;
                val2[p2]=a4*pow[i+50]+a5*pow[j+50];
                p2++;
                for (int k=-50;k<=50;k++){
                    if (k==0)k=1;
                    val1[p1]=a1*pow[i+50]+a2*pow[j+50]+a3*pow[k+50];
                    p1++;
                }
            }
        }
        //*/
        Arrays.sort(val1,0,p1);
        Arrays.sort(val2,0,p2);
        int t1=0,t2=0;
        int c=0;
        //*
        while (t2<p2){
            while (t1<p1&&val1[t1]<val2[t2]){t1++;}
            while (t1<p1&&val1[t1]==val2[t2]){
                t1++;
                c++;
            }
            t2++;
        }
        //*/
        System.out.println(c);
        
        in.close();
    }
}

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