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

555555555555555555555

Posted by sunmoonstar_love at 2006-10-26 20:38:30 on Problem 2696
In Reply To:递归超时啊?怎么办?高人帮忙啊。。。 Posted by:ppdg_error at 2006-02-20 11:48:51
> #include <iostream>
> using namespace std;
> inline int fai(int a,int b,int c,int d,int e,int f,int g,int h,int i){
>     int temp;
>     if(i==0){return a;}
>     if(i==1){return b;}
>     if(i==2){return c;}
>     if((i>=3)&&(i%2==1)){
>                          temp=d*fai(a,b,c,d,e,f,g,h,i-1)+e*fai(a,b,c,d,e,f,g,h,i-2)-f*fai(a,b,c,d,e,f,g,h,i-3);
>                          while(temp<0){
>                                        temp=temp+g;
>                                        
>                                        }
>                                        return temp%g;
>                          }
>     if((i>=3)&&(i%2==0)){
>                          temp=f*fai(a,b,c,d,e,f,g,h,i-1)-d*fai(a,b,c,d,e,f,g,h,i-2)+e*fai(a,b,c,d,e,f,g,h,i-3);
>                          while(temp<0){
>                                        temp=temp+h;
>                                        
>                                        }
>                                        return temp%h;
>                          }                     
>     }
> int main()
> {
> int a,b,c,d,e,f,g,h,i,num,count=1;
>     cin>>num;
>     while(count<=num){
>     cin>>a>>b>>c>>d>>e>>f>>g>>h>>i;
>     cout<<fai(a,b,c,d,e,f,g,h,i)<<endl;
>     count++;
>     }
> system("PAUSE");
> 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