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 |
Re:为什么我的数据与上面的全对到了还过不了?In Reply To:Re:用我过了的程序也给几组测试数据,希望对大家有帮助。。。 Posted by:haobaobao at 2008-08-14 22:58:13 #include <iostream> using namespace std; int x,y,m,n,l; int k; int t; int main() { cin>>x>>y>>m>>n>>l; if(m>n) { int deta=(y-x>=0)?(y-x):(y-x+l); int lyu=l%(m-n); for(t=0;t<m-n;t++) { if(!((t*lyu+deta)%(m-n))) { k=(long long int)(t*l+deta)/(m-n); break; } } if(t==m-n){cout<<"Impossible"<<endl;return 0;} else {cout<<k<<endl;return 0;} } if(n>m) { int deta=(x-y>=0)?(x-y):(x+l-y); int lyu=l%(n-m); for(t=0;t<n-m;t++) { if(!((t*lyu+deta)%(n-m))) { k=(long long int)(t*l+deta)/(n-m); break; } } if(t==n-m){cout<<"Impossible"<<endl;return 0;} else {cout<<k<<endl;return 0;} } if(m==n&&(((y-x)%l)!=0)){cout<<"Impossible"<<endl;return 0;} else cout<<0<<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