Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

帮忙啊

Posted by 19205213 at 2006-07-16 10:28:54 on Problem 1061
我是新手,对编程不熟悉,但我认为这个题应该算简单的,用一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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator