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 Leo at 2005-10-23 13:36:36 on Problem 2680
In Reply To:不行!!大侠帮忙看看! Posted by:sza at 2005-10-23 12:09:00
> package computertransformation;
> 
> import java.io.*;
> import java.util.*;
> import java.math.BigInteger;
> 
> public class Main{
>     public static void main(String args[])
>     {
>         String input;
>         int number=0;
>         BigInteger array[]=new BigInteger[1001];
>         for(int i=0;i<=1000;i++){
>             array[i]=new BigInteger("0");
>         }
>         array[1]=new BigInteger("0");
>         array[2]=new BigInteger("1");
>         BigInteger one=new BigInteger("1");
>         BigInteger two=new BigInteger("2");
>         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{
>                 for(int i=3;i<=number;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);
>                     }
>                 }
>                 System.out.println(array[number]);
>             }
>         }
>     }
> }

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