fzu-2268
来源:互联网 发布:js删除指定class的div 编辑:程序博客网 时间:2024/06/07 06:30
E - Cutting Game
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.
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.
For each case, output the case number first, and then output the number of the gold pieces they need to cut.
13
Case 1: 2
题意:求解一个数可以分成几个连续的数,比如3,分成1 2,如4 分成1 2 1这里题目要求求解切几刀
思路:找规律,写一些数观察到切几下相当于求这个数的二进制有几位。
代码:
#include<cstdio>using namespace std;int main(){ int t,cas; scanf("%d",&t); for(int cas=1; cas<=t; cas++) { int n,sum=0; scanf("%d",&n); while(n) { sum++; n>>=1; } printf("Case %d: %d\n",cas,sum); } return 0;}
- fzu-2268
- FZU
- FZU
- FZU
- FZU
- FZU
- FZU
- FZU
- FZU
- FZU
- FZU
- FZU
- FZU
- FZU
- FZU
- FZU
- FZU
- FZU
- 欢迎使用CSDN-markdown编辑器
- 以太坊go-ethereum常见问题汇总
- viewpager无限轮播加点
- java 多继承
- mybatis分页查询
- fzu-2268
- Oracle数据库改密码
- 请实现一个函数用来找出字符流中第一个只出现一次的字符。例如,当从字符流中只读出前两个字符"go"时,第一个只出现一次的字符是"g"。当从该字符流中读出前六个字符“google"时,第一个只出现一次的字
- EntityValidationErrors
- spark环境搭建
- 数据结构实验之查找七:线性之哈希表
- win7建立无线网共享internet连接给其它设备
- CDQ分治正确的入门姿势
- 滤波电容的大小的选取