题意:

In one one-dimensional world there are n platforms. Platform with index k (platforms are numbered from 1) is a segment with coordinates[(k - 1)m, (k - 1)m + l], and l < m. Grasshopper Bob starts to jump along the platforms from point 0, with each jump he moves exactlyd units right. Find out the coordinate of the point, where Bob will fall down. The grasshopper falls down, if he finds himself not on the platform, but if he finds himself on the edge of the platform, he doesn't fall down.

找到第一个FALL DOWN的位置

思路:

暴力,但可能会出现"循环"【一直不会FALL DOWN,直到超出第N个PLATFORM】。则循环一定是又跳到0。即D%M==0的第一个位置。

代码:

ll n,d,m,l;

int main(){

    cin>>n>>d>>m>>l;
ll D=0;
for(;;){
ll t=D%m;
if(t>l){
print("%I64d\n",D);
ret 0;
}
if(D&&D%m==0){
print("%I64d\n",((n-1)*m+l)/d*d+d);
ret 0;
}
D+=d;
} return 0;
}

最新文章

  1. C#字符串操作 取文本左边 取文本右边 取文本中间 取文本中间到List集合 指定文本倒序
  2. 【设计模式】Java版设计模式的类图汇总
  3. Command模式
  4. 荒木毬菜 小情歌日文版 - 独身OL之歌
  5. Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) C - Bear and Colors
  6. 使用Netty进行Android与Server端通信实现文字发送接收与图片上传
  7. js函数、表单验证
  8. XMLHttpRequest2的进步之处
  9. 深入剖析Java中的装箱和拆箱(转)
  10. List、Set、Map的使用
  11. g++ gcc 的区别
  12. Hyper-v虚拟机上网
  13. java 之 迭代器模式(大话设计模式)
  14. 《SpringMVC从入门到放肆》三、DispatcherServlet的url-pattern配置详解
  15. java算法(1)---余弦相似度计算字符串相似率
  16. 剑指offer:链表中倒数第k个结点
  17. 弹性盒模型,flex布局
  18. Linux(C/C++)下的文件操作open、fopen与freopen
  19. 微信小程序 倒计时
  20. 基于 Java Web 的毕业设计选题管理平台--系统设计和任务分配

热门文章

  1. 10.6Java学习
  2. 【C++基础教程】第三课
  3. 【OI】C++STL 不定长数组 vector
  4. CentOS8安装ntp实现时间同步
  5. 判断手机浏览器还是微信浏览器(PHP)
  6. JDBC-1(概述&amp;建立)
  7. 《使用Jmeter进行批量发送http请求》
  8. P5305-[GXOI/GZOI2019]旧词【树链剖分,线段树】
  9. MyBatis的缓存玩法
  10. 1.1 jvm核心类加载器--jdk源码剖析