记录编号 132257 评测结果 AAAAAAAAAA
题目名称 [POJ 1061] 青蛙的约会 最终得分 100
用户昵称 Gravatar水中音 是否通过 通过
代码语言 C++ 运行时间 0.044 s
提交时间 2014-10-25 19:00:26 内存使用 0.28 MiB
显示代码纯文本
  1. #include<cstdio>
  2. #include<iostream>
  3. using namespace std;
  4. bool qwq=false;
  5. long long x,y,n,m,l,i=0;
  6. int main()
  7. {
  8. freopen("poj_hama.in","r",stdin);
  9. freopen("poj_hama.out","w",stdout);
  10. scanf("%lld%lld%lld%lld%lld",&x,&y,&m,&n,&l);
  11. x%=l;y%=l;n%=l;m%=l;
  12. while(x!=y)
  13. {
  14. i++;
  15. x+=m;x%=l;
  16. y+=n;y%=l;
  17. if(i>1000000)
  18. {
  19. qwq=true;
  20. break;
  21. }
  22. }
  23. if(qwq) printf("Impossible\n");
  24. else printf("%lld\n",i);
  25. return 0;
  26. }