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 |
Time Limit Exceeded 怎么该啊!算法不会,大侠指点啊!#include<iostream> #include<cstdlib> #include<cstring> #include<cmath> using namespace std; int main() { __int64 x,y,L,m,n; scanf("%I64d %I64d %I64d %I64d %I64d",&x,&y,&m,&n,&L); for(int i=0;i<L;i++) { if((x+i*m)%L == (y+i*n)%L) { cout<<i<<endl; break; } if(((x+i*m)%L != (y+i*n)%L)&&i==L-1) cout<<"Impossible"<<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