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 117474335 at 2010-10-23 21:37:29 on Problem 2663
In Reply To:n =1 是输出1,wa了几次 Posted by:969869102 at 2010-08-29 21:09:20
#include <stdio.h>

__int64 a, b, c;
int n ;

main () 
{
    int i ;
    while (scanf ("%d" , &n) , n != -1){
        if (n % 2){printf ("0\n") ; continue ;} 
        if (!n){printf ("1\n") ; continue ;} 
        n /= 2 ;
        a = 3; b = 11 ;
        for (i = 3; i <= n; i ++ ){
            c = 4 * b - a ;
            a = b ;
            b = c ;}
        if (n == 1) printf ("3\n") ;
        else printf ("%I64d\n" , b) ;}
}

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