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 |
FT 这就过 这么水?import java.util.Scanner; public class Main { public static int cal(int a) { int temp=a/2; return (temp)*(temp-1); } public static int cal_(int a) { int temp=a/2; int temp_=a-temp; return (temp)*(temp-1)/2+(temp_)*(temp_-1)/2; } public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); for(int i=0;i<n;i++) { int a=sc.nextInt(); if(a%2==0) { System.out.println(cal(a)); } else { System.out.println(cal_(a)); } } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator