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