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 |
代数学少了吧? 会求模逆就会做~ ^_^下面的代码仅供参考: #include<iostream> using namespace std; int Solve(int k,int p) { int m; for(m=1;m<p && m*k%p!=1;m++); return m; } int main() { int p,e,i,d,c=0,val,pS,eS,iS; pS=Solve((28*33)%23,23)*28*33; eS=Solve((23*33)%28,28)*23*33; iS=Solve((23*28)%33,33)*23*28; while(cin>>p>>e>>i>>d && p!=-1) { p=(23+(d-p)%23)%23; e=(28+(d-e)%28)%28; i=(33+(d-i)%33)%33; val=(p*pS+e*eS+i*iS)%21252; val=21252-val; cout<<"Case "<<++c<<": the next triple peak occurs in "<<val<<" days."<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator