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 |
帮忙啊我是新手,对编程不熟悉,但我认为这个题应该算简单的,用一for循环来判断(m*i+x)%L==(n*i+y)%L不就可以了吗?我也试了数据,但提交后偏偏就错了,各位,有空帮我指点一下迷津 #include<stdio.h> #include<math.h> int main() {int x,y,m,n,L,i; scanf("%d%d%d%d%d",&x,&y,&m,&n,&L); for(i=0;i<32767;i++) if((m*i+x)%L==(n*i+y)%L)break; printf("%d",i); if(i==32767)printf("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