| ||||||||||
| 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 | |||||||||
Re:为什么总是RuntimeError的,会有什么原因导致这样的?In Reply To:为什么总是RuntimeError的,会有什么原因导致这样的? Posted by:victor286 at 2006-04-08 10:28:25 > 为什么总是RuntimeError的,会有什么原因导致这样的?
import java.io.*;
import java.util.*;
public class Main
{
public static void main(String args[])throws IOException
{Vector v=new Vector();
Vector k=new Vector();
while(true){
BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in));
String s=stdin.readLine();
int n=Integer.parseInt(s);
if(n==0)break;
k.add(""+n);
int suma=0;
int i=1;
while(true)
{
suma=suma+i;
if(suma>n)break;
i++;
}
int sumb=0;
for(int j=1;j<=i;j++)
{
sumb=sumb+j*j;
}
v.add(""+(sumb-(suma-n)*i));
}
for(int c=0;c<v.size();c++)
{
String s1=(String)k.get(c);
String s2=(String)v.get(c);
int a=Integer.parseInt(s1);
int b=Integer.parseInt(s2);
System.out.println(a+" "+b);
}
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator