2022年1月17日学习总结

9:00~9:30
听一篇英语听力
9:30~11:00
做一套英语试卷
12:00~14:30
辅导妹妹高中数学和英语
14:30~18:00
AC昨天测试的补题


第一题:

CF18B

Platforms

题目描述

In one one-dimensional world there are nn platforms. Platform with index kk (platforms are numbered from 1) is a segment with coordinates [(k-1)m,(k-1)m+l][(k−1)m,(k−1)m+l] , and l<ml<m . Grasshopper Bob starts to jump along the platforms from point 00 , with each jump he moves exactly dd 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.

输入格式

The first input line contains 4 integer numbers nn , dd , mm , ll ( 1<=n,d,m,l<=10^{6},l<m1<=n,d,m,l<=106,l<m ) — respectively: amount of platforms, length of the grasshopper Bob's jump, and numbers mm and ll needed to find coordinates of the kk -th platform: [(k-1)m,(k-1)m+l][(k−1)m,(k−1)m+l] .

输出格式

Output the coordinates of the point, where the grosshopper will fall down. Don't forget that if Bob finds himself on the platform edge, he doesn't fall down.

题意翻译

题目描述:在一坐标轴上给出n块板子,每个板子所占的空间为[(k-1)m,(k-1)m+l](l<m),一个青蛙从原点0起跳,每次跳d距离远,问最后青蛙会落在哪里(没落在板子上就结束跳跃) 输入:一行四个整数n,d,m,l 输出:一个整数,即青蛙最后的落点 1<=n,d,m,l<=10^6 l<m

Translated by 稀神探女

输入输出样例

输入 #1复制

2 2 5 3

输出 #1复制

4

输入 #2复制

5 4 11 8

输出 #2复制

20

题解:青蛙在本题目中一共有两种情况。一种是不在板子上,跳到两个板子中间最后或者跳出了最后一个板子。直接遍历每块板子,当青蛙跳不到这一块板子上结束循环,能跳上该板子就让它一直跳直到跳出该板子。

AC代码:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,d,m,l,ans,i;
    cin>>n>>d>>m>>l;
    ans=0;
    for(i=1;i<=n;i++) {
        if(ans<((i-1)*m))  break;//若是不能调到板子上,就结束
        while(ans<=(i-1)*m+l)   ans=(((i-1)*m+l)/d)*d+d;//继续跳,直到跳出这块板子
    }
    cout<<ans<<endl;
    return 0;
}

后面想做最后一个题目发现不会做

便继续学习树和二叉树。

树是由n(n>=1)个有限结点组成一个具有层次关系的集合。把它叫做“树”是因为它看起来像一棵倒挂的树,也就
是说它是根朝上,而叶朝下的。

二叉树的定义:

二叉树就是度不超过2的树(每个结点最多有两个子结点)。上面那张图就是二叉树。

满二叉树:
一个二叉树,如果每一个层的结点树都达到最大值,则这个二叉树就是满二叉树。

然后学习了一下如何创建和如何遍历二叉树。

明天试着AC一下本周的题目!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值