https://vjudge.net/contest/67836#problem/M

There is a beautiful river in a small village. N rocks are arranged in a straight line numbered 1 to N from left bank to the right bank, as shown below.

[Left Bank] - [Rock1] - [Rock2] - [Rock3] - [Rock4] ... [Rock n] - [Right Bank]

The distance between two adjacent rocks is exactly 1 meter, while the distance between the left bank and rock 1 and the distance between Rock n and the right bank are also 1 meter.

Frog Frank was about to cross the river, his neighbor Frog Funny came to him and said,

'Hello, Frank. Happy Children's Day! I have a gift for you. See it? A little parcel on Rock 5.'

'Oh, that's great! Thank you! I'll get it.'

'Wait...This present is for smart frogs only. You can't get it by jumping to it directly.'

'Oh? Then what should I do?'

'Jump more times. Your first jump must be from the left bank to Rock 1, then, jump as many times as you like - no matter forward or backward, but your ith jump must cover 2*i-1 meters. What's more, once you return to the left bank or reach the right bank, the game ends, and no more jumps are allowed.'

'Hmmm, not easy... let me have a think!' Answered Frog Frank, 'Should I give it a try?'

Input

The input will contain no more than 2000 test cases. Each test case contains a single line. It contains two positive integers N (2<=N<=10^6), and M (1<=M<=N), M indicates the number of the rock on which the gift is located. A test case in which N=0, M=0 will terminate the input and should not be regarded as a test case.

Output

For each test case, output a single line containing 'Let me try!' If it's possible to get to Rock m, otherwise, output a single line containing 'Don't make fun of me!'

Sample Input

9 5
12 2
0 0

Sample Output

Don't make fun of me!
Let me try!

代码:

#include <bits/stdc++.h>
using namespace std; int N, Gift;
bool flag[55]; void dfs(int i, int sum) {
if(sum <= 0 || sum >= N + 1)
return ;
flag[sum] = true;
dfs(i + 1, sum + 2 * i - 1);
dfs(i + 1, sum - 2 * i + 1);
} int main() {
while(~scanf("%d%d", &N, &Gift)) {
if(!N && !Gift) break; if(N >= 50)
printf("Let me try!\n");
else {
memset(flag, false, sizeof(flag));
dfs(2, 1);
if(flag[Gift])
printf("Let me try!\n");
else
printf("Don't make fun of me!\n");
}
}
return 0;
}

  

ZOJ 1229 M-Gift?!的更多相关文章

  1. ZOJ题目分类

    ZOJ题目分类初学者题: 1001 1037 1048 1049 1051 1067 1115 1151 1201 1205 1216 1240 1241 1242 1251 1292 1331 13 ...

  2. USACO . Greedy Gift Givers

    Greedy Gift Givers A group of NP (2 ≤ NP ≤ 10) uniquely named friends has decided to exchange gifts ...

  3. ZOJ People Counting

    第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ  3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...

  4. ZOJ 3686 A Simple Tree Problem

    A Simple Tree Problem Time Limit: 3 Seconds      Memory Limit: 65536 KB Given a rooted tree, each no ...

  5. ZOJ Problem Set - 1394 Polar Explorer

    这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求 ...

  6. ZOJ Problem Set - 1392 The Hardest Problem Ever

    放了一个长长的暑假,可能是这辈子最后一个这么长的暑假了吧,呵呵...今天来实验室了,先找了zoj上面简单的题目练练手直接贴代码了,不解释,就是一道简单的密文转换问题: #include <std ...

  7. ZOJ Problem Set - 1049 I Think I Need a Houseboat

    这道题目说白了是一道平面几何的数学问题,重在理解题目的意思: 题目说,弗雷德想买地盖房养老,但是土地每年会被密西西比河淹掉一部分,而且经调查是以半圆形的方式淹没的,每年淹没50平方英里,以初始水岸线为 ...

  8. ZOJ Problem Set - 1006 Do the Untwist

    今天在ZOJ上做了道很简单的题目是关于加密解密问题的,此题的关键点就在于求余的逆运算: 比如假设都是正整数 A=(B-C)%D 则 B - C = D*n + A 其中 A < D 移项 B = ...

  9. ZOJ Problem Set - 1001 A + B Problem

    ZOJ ACM题集,编译环境VC6.0 #include <stdio.h> int main() { int a,b; while(scanf("%d%d",& ...

随机推荐

  1. Spark Streaming job的生成及数据清理总结

    关于这次总结还是要从一个bug说起....... 场景描述:项目的基本处理流程为:从文件系统读取每隔一分钟上传的日志并由Spark Streaming进行计算消费,最后将结果写入InfluxDB中,然 ...

  2. Jupyter Notebook的魔法

    在腾讯云上搭建了一个Jupyter Notebook 还是很好用的, 这里总结了一些看到的小技巧及快捷键使得我们更加快捷的完成工作. Notebook 与 Vim 有些类似,有两种键盘输入模式,即命令 ...

  3. 第5章 MapReduce操作

    目录 5.1 案例分析:单词计数 1.设计思路 2.程序源代码 3.程序解读 4.程序运行 5.2 案例分析:数据去重 1.设计思路 2.编写程序 3.程序解读 4.程序运行 5.3 案例分析:求平均 ...

  4. Linux3.5—IIC学习分析

    I2C控制器的设备对象内核已经实现并关联到platform总线. I2C控制器的驱动对象内核已经实现. 看mach-tiny4412.h /plat-samsung/目录下 /drivers/i2c/ ...

  5. 《CURL技术知识教程》系列分享专栏

    <CURL技术知识教程>已整理成PDF文档,点击可直接下载至本地查阅https://www.webfalse.com/read/201737.html 文章 PHP采集相关教程之一 CUR ...

  6. Qt——事件

    1.常见事件 [1]鼠标事件 (1)坐标 x(),y(), 相对windows globalX() globalY() (2)获得点击 button() [2]键盘事件 [3]定时器事件 timerI ...

  7. Java 反射 (Class、ClassLoader、Constructor、Method、Field)

    反射是Java中一个非常重要.非常强大的机制.曾看到一句话“反射是框架的灵魂”,初学时不懂,等到学完框架之后才慢慢理解其意. 什么是反射?我们先通过几个类和示例来初步体会一下反射. 一.ClassLo ...

  8. iOS 库 开发小结

    1.基本用法 定义类,导出头文件,注意头文件,库文件的search path 2.加载资源 - 使用主工程的文件,耦合性太强 - 封装到NSBundle中 NSBundle可以封装xib storyb ...

  9. Python 列表下标操作

    Python  列表下标操作 引用网址: https://www.jianshu.com/p/a98e935e4d46

  10. WeTest功能优化第3期:业内首创,有声音的云真机

    第3期功能优化目录 [云真机远程调试]音频同步传输实现测试有声 [兼容性测试报告]新增视频助力动态定位问题 [云真机远程调试]菜单栏优化助力机型选择 本期介绍的新功能,秉承创造用户需求的理念,在云真机 ...