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 nabber at 2006-07-26 17:33:51
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String args[])
	{

	
	int lines;
	int length;
	
	Scanner cin=new Scanner(System.in);
	lines=cin.nextInt();
	int i[]=new int[lines];
	for(int j=1;j<=lines;j++)
	{
		length=cin.nextInt();
		int k=1;
		while(k*(k+1)<2*length)
		{
			k++;
		}
		
		if(k*(k+1)==2*length)
		  i[j-1]=k;
		else
		{	
			k--;
			i[j-1]=(2*length-k*(k+1))/2;
			}
		
	}
	for(int j=1;j<=lines;j++)
	{System.out.println(i[j-1]);}

	
	}
}

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