首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

田鸡的约会

2013-10-10 
青蛙的约会题目:点击打开链接分析:输出impossible应该是两只青蛙的移动速度一样代码:#include stdio.h#i

青蛙的约会

题目:点击打开链接

分析:输出impossible应该是两只青蛙的移动速度一样

代码:

 

#include <stdio.h>#include <stdlib.h>int main(){   int x,y,m,n,l;   int a=0;   scanf("%d %d %d %d %d",&x,&y,&m,&n,&l);   for(;;)   {      if(m==n || x==y)      {           printf("impossible\n");           break;      }      x+=m;      y+=n;      a++;      if(x%l==y%l)      break;   }   printf("%d\n",a);   return 0;}


热点排行