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:3070,为什么会WA呢?我已经想了很长时间了,真的崩溃了

Posted by y09shendazhi at 2009-08-15 22:32:55
In Reply To:3070,为什么会WA呢?我已经想了很长时间了,真的崩溃了 Posted by:Lone_mover at 2008-07-05 11:06:44
> 我的代码是这样的:
> 
> #include <iostream>
> 
> 
> using namespace std;
> 
>  __int64 base[][2] ={{1, 1},{1, 0}};
>  __int64 res[2][2] = {1, 0, 0, 1};
> 
> void multi(__int64 a[][2], __int64 b[][2])
> {
>   __int64 temp1 = a[0][0]*b[0][0] + a[0][1]*b[1][0];
>   __int64 temp2 = a[0][0]*b[0][1] + a[0][1]*b[1][1];
>   
>   __int64 temp3 = a[1][0]*b[0][0] + a[1][1]*b[1][0];
>   __int64 temp4 = a[1][0]*b[0][1] + a[1][0]*b[1][1];
>   
>   a[0][0] = temp1%10000;
>   a[0][1] = temp2%10000;
>   a[1][0] = temp3%10000;
>   a[1][1] = temp4%10000;
>     
> } 
> 
> 
> 
> 
> 
> int cal(__int64 n)
> {
>   if(n == 0)
>     return 0;
>   else
>    if(n == 1)
>      return 1;
>   else
>     if(n == 2)
>       return 1;
>   
>   
>   
>   __int64 level = n - 1;
>   
>   //cout<<level<<endl;
>   
>   base[0][0] = 1;
>   base[0][1] = 1;
>   base[1][0] = 1;
>   base[1][1] = 0;
>   
>   
>   res[0][0] = 1;
>   res[0][1] = 0;
>   res[1][0] = 0;
>   res[1][1] = 1;
>   
>   //cout<<level<<endl;
>   while(level>1)
>   {
>     if(level%2 == 1)
>       multi(res, base);
>      
>      
>      multi(base, base);
>      level/=2;
>   }
>     
>   multi(res, base);
>   
>   int result = res[0][0];
>   
>   //cout<<result<<endl;
>   
>   
>   
>   return result%10000;
>   
>   
>  
> }
> 
> int main()
> {
> 
>   __int64 n;
>   while(cin>>n&&n!= - 1)
>     cout<<cal(n)<<endl;
>   
>     
>   return 0;
>   
> }
> 
> 小的测试数据是对的,换大一点的为什么就不行了呢?
>  郁闷
越界了吗?

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