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 |
感觉我这个程序应该没错 可就是通不过有高手能给我看看吗 输入了N组数据都能行#include<iostream> #include<math.h> using namespace std; int main() { long i,x,y,n,m,l; long z; cin>>x>>y>>n>>m>>l; if(x==y||x>=2000000000||y>=2000000000) { if(n>=2000000000||m>=2000000000||n<0||m<0||l>=2100000000) exit(0); } if((x>y&&n<m)||(x<y&&n>m)) { for(i=0;i<=abs(n-m);i++) { z=(abs(y-x)); if((i*l+z)%abs(n-m)==0) { cout<<(i*l+z)%abs(n-m); break; } } } else if((x<y&&n<m)||(x>y&&n>m)) { for(i=0;i<=abs(n-m);i++) { z=(abs(y-x)); if((i*l-z+l)%(n-m)==0) { cout<<(i*l-z+l)/abs(n-m); break; } } } else if(m==n) { cout<<"Impossible"; return 0; } if(i==abs(n-m)+1) {cout<<"Impossible";} return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator