点击打开链接Problem 2268 Cutting Game

Accept: 219    Submit: 525
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

13

Sample Output

Case 1: 2

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.

PS:刚开始一直摸不着头脑,后来列了几项,渐渐才找到了规律。

AC:

#include<stdio.h>

int main()
{
int t,n,i,m;
scanf("%d",&t);
i=1;
while(t--)
{
scanf("%d",&n);
m=1;
while(n>1)
{
n/=2;
m++;
}
printf("Case %d: %d\n",i++,m);
}
return 0;
}

FZU-2268 Cutting Game相关推荐

  1. FZU - 2268 Cutting Game

    /*这题主要是想到突破口--每次除以2(我感觉还是思维题,就像我当时做时,就是想不到 T^T)然后,用1个奇数和1个偶数举一下例子f(7) = f(3) + 1, f(3) = f(1) + 1, f ...

  2. fzu 2150 Fire Game 【身手BFS】

    称号:fzu 2150 Fire Game :给出一个m*n的图,'#'表示草坪,' . '表示空地,然后能够选择在随意的两个草坪格子点火.火每 1 s会向周围四个格子扩散,问选择那两个点使得燃烧全部 ...

  3. Codeforces Round #300 A. Cutting Banner 水题

    A. Cutting Banner Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/538/pro ...

  4. UVA10003 切木棍 Cutting Sticks(区间DP、细节)

    整理的算法模板合集: ACM模板 本题其实就是一个区间DP 的模板题,总长度为len,有n个切割点,也就是说能被切割成n+1段,所以左边界是0,有边界是n + 1,所以答案就是f[0][n + 1]. ...

  5. FZU 1686 神龙的难题(DLX反复覆盖)

    FZU 1686 神龙的难题 题目链接 题意:中文题 思路:每个1看成列,每个位置作为左上角的矩阵看成行.dlx反复覆盖就可以 代码: #include <cstdio> #include ...

  6. Hadoop十岁!Doug Cutting成长史+他眼中大数据技术的未来

    上次见到(膜拜)Hadoop之父Doug Cutting是在2年前,2014中国大数据技术大会上.今年Hadoop10岁,刚看到他的Hadoop十周年贺词,感觉时间飞逝.最近CSDN和InfoQ都在制 ...

  7. 贪心 Codeforces Round #300 A Cutting Banner

    题目传送门 1 /* 2 贪心水题:首先,最少的个数为n最大的一位数字mx,因为需要用1累加得到mx, 3 接下来mx次循环,若是0,输出0:若是1,输出1,s[j]--: 4 注意:之前的0的要忽略 ...

  8. Hadoop之父Doug Cutting

    生活中,可能所有人都间接用过他的作品,他是Lucene.Nutch .Hadoop等项目的发起人.是他,把高深莫测的搜索技术形成产品,贡献给普罗大众:还是他,打造了目前在云计算和大数据领域里如日中天的 ...

  9. Cutting Sticks UVA - 10003

    题解:dp[ i ][ j ]=min { dp[ i ][ k ]+dp[ k ][ j ] }+a[ j ]-a [i ]. 和石子归并是一样的问题,枚举区间的长度,然后更新这个区间的值. 1 # ...

最新文章

  1. 数据库字符mysql_MySQL数据库之字符函数详解
  2. win10商店打不开_PS打不开Raw格式?更新ACR新方式!【第05期 三分钟聊摄影】
  3. ie6 span 换行IE6中float:right换行问题的替代解决方案
  4. 26个提升java性能需要注意的地方
  5. Apache Lucene中的并发查询执行
  6. 叮叮叮 重点之中的python必备英语单词(1)来啦!请记得查收
  7. php+mysql个人博客系统_推荐几个开源的个人独立博客系统
  8. C语言 VS输入输出字符设置
  9. Numpy np.random.RandomState()的简单用法
  10. Web移动开发基本概念
  11. 【管理】日报,周报,会议记录模板
  12. 1.1初识sakura语法
  13. Java识别获取pdf中文字信息
  14. Axure设置变量 做乘法计算
  15. eclipse 实用的快捷键
  16. 佛罗里达州立大学计算机专业排名,佛罗里达州立大学有哪些专业_专业排名(QS世界排名)...
  17. SHELL 内置变量
  18. itext7生成pdf页脚页码
  19. vue中Echart如何打包下载图片
  20. Hexo-Matery主题细致美化

热门文章

  1. 《七哥说道》第十六章:程序员,江湖见
  2. 网络接口卡更换为计算机网卡,电信宽带从100兆升200兆,需要换路由器和全部的网线吗?该如何处理呢?...
  3. idea pycharm 的注册方式
  4. Idea2018激活
  5. 智慧运维解决方案-最新全套文件
  6. quartus18.1和modelsim的下载安装
  7. 英伟达tegra210 连接电视/hifi,设置默认声卡HDMI,
  8. Cisco Packet Tracer思科模拟器交换机的VTP技术
  9. linux磁盘分区、挂盘
  10. 【顶】(与同事合作的快乐)技术人员也需要先学会做人,再学会做事,再是能成事,最后是成名得利