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 |
晕,贴错了In Reply To:Re:不行!!大侠帮忙看看! Posted by:Leo at 2005-10-23 13:36:36 import java.io.*; import java.util.*; import java.math.BigInteger; public class Main { public static void main(String args[])throws Exception { String input; int number=0; BigInteger array[]=new BigInteger[1001]; array[1]=new BigInteger("0"); array[2]=new BigInteger("1"); BigInteger one=new BigInteger("1"); BigInteger two=new BigInteger("2"); for(int i=3;i<=1000;i++) { if(i%2==0) { array[i]=array[i-1].multiply(two); array[i]=array[i].add(one); } else { array[i]=array[i-1].multiply(two); array[i]=array[i].subtract(one); } } while(true) { try { Scanner cin=new Scanner(System.in); if(cin==null) break; number=cin.nextInt(); } catch(Exception e) { break; } if(number==1) { System.out.println("0"); } else if(number==2) { System.out.println("1"); } else { System.out.println(array[number]); } } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator