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. python应用:爬虫框架Scrapy系统学习第二篇——windows下安装scrapy

    windows下安装scrapy 依次执行下列操作: pip install wheel pip install lxml pip install PyOpenssl 安装Microsoft visu ...

  2. RMI入门HelloWorld

    java RMI(Remote Method Invocation)是一种基于java远程调用技术,是对RPC的java实现,可以在不同主机上进行通信与方法调用.PRC通信原理如图: 方法调用从客户对 ...

  3. 【8086汇编-Day5】第二次实验

    debug的使用 偷个懒,之前写过了这里不再赘述 实验 1)实验1 要求:用e将一些数据写入内存,用a写入一段程序,t 逐条执行 观察具体参数变化,并探究现象 1.e写入,d检查 2.a写入程序 3. ...

  4. IDEA阿里Java规范插件的安装

    本文参考自阿飞博客:http://www.cnblogs.com/aflyun/p/7668306.html 官方使用教程:https://zhuanlan.zhihu.com/p/30191998? ...

  5. DSP5509之采样定理

    1. 在实际种信号是模拟连续的,但是AD采样确实离散的数字的,根据采样定理,采样频率要是模拟信号的频率2倍以上采样到的值才没问题. 2. 打开工程 unsigned ]; main() { int i ...

  6. LOB类型的学习、总结

    LOB相关的概念 LOB类型: 将信息文件(十进制.二进制).图像甚至音频信息采用数据库作为保存载体时,就需要使用lob类型数据. 有两种Lob,Internal Lob和External Lob.I ...

  7. 「日常训练」Jin Yong’s Wukong Ranking List(HihoCoder-1870)

    题意与分析 2018ICPC北京站A题. 题意是这样的,给定若干人的武力值大小(A B的意思是A比B厉害),问到第几行会出现矛盾. 这题不能出现思维定势,看到矛盾就是矛盾并查集--A>B.A&g ...

  8. APP上下左右滑动屏幕的处理

    #获得机器屏幕大小x,y driver = self.driver def getSize(): x = driver.get_window_size()['width'] y = driver.ge ...

  9. Selenium(Python)调用pywin32上传图片

    import unittestfrom time import sleep import osfrom selenium import webdriverimport win32apiimport w ...

  10. 【转】APP推广什么是cpa,cps,cpm

    转载自:http://www.apptg.cn 经常做做APP推广和做运营的同学对于cpa,cps,cpm,cpc这些名词肯定不会陌生,也基本都知道其表示的含义,但是对于新手来说,这几个词的含义还是不 ...