2268 Cutting Game
来源:互联网 发布:杭州创业软件 编辑:程序博客网 时间:2024/06/02 00:15
Accept: 119 Submit: 275
Time Limit: 1000 mSec Memory Limit : 32768 KB
Problem Description
Fat brother and Maze are playing a kind of special (hentai) game with a piece of gold of length N where N is an integer. Although, Fat Brother and Maze can buy almost everything in this world (except love) with this gold, but they still think that is not convenient enough. Just like if they would like to buy the moon with M lengths of the gold, the man who sold the moon need to pay back Fat Brother and Maze N-M lengths of the gold, they hope that they could buy everything they can afford without any change. So they decide to cut this gold into pieces. Now Fat Brother and Maze would like to know the number of the pieces they need to cut in order to make them fulfill the requirement. The number of the gold pieces should be as small as possible. The length of each piece of the gold should be an integer after cutting.
Input
The first line of the data is an integer T (1 <= T <= 100), which is the number of the text cases.
Then T cases follow, each case contains an integer N (1 <= N <= 10^9) indicated the length of the gold.
Output
For each case, output the case number first, and then output the number of the gold pieces they need to cut.
Sample Input
Sample Output
Hint
In the first case, the gold can be cut into 2 pieces with length 1 and 2 in order to buy everything they can afford without change.
Source
第七届福建省大学生程序设计竞赛-重现赛(感谢承办方闽江学院)【题解】:
找钱问题,就是花钱尽量不用找钱,自己可以刚凑够这么多钱
你自己画出来就好了,我很懒1 2 4 7 15 .......看出来了吧
【代码】:
#include<iostream>#include<cstdio>//#include<cmath>#include<vector>#include<map>#define MAX 10000000using namespace std;int main(){ int re; scanf("%d",&re); for(int t=1;t<=re;t++) { int cnt=1; int test; scanf("%d",&test); while(test!=1){ test/=2; cnt++; } printf("Case %d: %d\n",t,cnt); } return 0;}
- 2268 Cutting Game
- poj2311 Cutting Game-----sg
- poj2311 Cutting Game
- POJ 2311 Cutting Game
- POJ-2311-Cutting Game
- POJ 2311 Cutting Game
- POJ2311 Cutting Game (博弈)
- POJ - 2311 Cutting Game
- POJ 2311 Cutting Game
- poj 2311 cutting game
- Cutting Game---博弈
- poj 2311 Cutting Game
- POJ2311 Cutting Game SG函数
- [POJ2311]Cutting Game(博弈)
- 【POJ2311】Cutting Game-SG博弈
- POJ 2311 Cutting Game 笔记
- poj 2311 Cutting Game(sg函数)
- POJ 2311 Cutting Game (SG函数)
- Java——Math,Set,List,map相关练习
- mysql启动的几种方式
- php在window和linux安装扩展
- 工作中行转列的小需求
- springmvc的执行流程
- 2268 Cutting Game
- String、StringBuffer与StringBuilder
- 中国联通公司与中国移动的差别,就在这!
- Neo4j CQL
- 网络判断
- pcap库的使用
- 知道这20个正则表达式,能让你少写1,000行代码
- ILSVRC2017:Beyond ImageNet Large Scale Visual Recognition Challenge
- how to share register and bit field definitions between a device driver and the FPGA it controls