zoukankan      html  css  js  c++  java
  • cf18B Platforms(仔细谨慎题)

    题意:

    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
    ",D);
                ret 0;
            }
            if(D&&D%m==0){
                print("%I64d
    ",((n-1)*m+l)/d*d+d);
                ret 0;
            }
            D+=d;
        }
    
        return 0;
    }
  • 相关阅读:
    2014 非常好用的开源 Android 测试工具
    Android 开发最佳实践
    Java_综合案例DAO设计模式(重要)
    Java_Set接口
    Java_List
    Java_类集框架简介
    Java_对象序列化
    Java_打印流
    Java_IO编程
    Java_文件操作
  • 原文地址:https://www.cnblogs.com/fish7/p/4329889.html
Copyright © 2011-2022 走看看