Problem 2062 Suneast & Yayamao 二进制(多重背包的理解基础)
2024-09-28 03:07:14
Problem 2062 Suneast & Yayamao
Accept: 143 Submit: 313
Time Limit: 1000 mSec Memory Limit : 32768 KB
Problem Description
Yayamao is so cute that people loves it so much.
Everyone wants to buy Yayamao from Suneast (a business man who sells Yayamao).
Suneast is a strange business man. He sells Yayamao in a random price from 1, 2, 3, 4, 5…, n.
Suneast is also a lazy business man. He never looks for a change. But people can’t but Yayamao with a lower price, that say people must pay exact money for Yayamao.
Now, we want to know how many pieces of money people should bring with to buy a Yayamao with the exactly price.
Input
There are multiple test cases. Each test case has an integer n(1<=n<=2147483647) in a single line.
Output
For each case, output a single integer in a line indicate the number of pieces of money people should bring with to buy a Yayamao whose price is random from 1 to n.
Sample Input
1 2 5
Sample Output
1 2 3
Hint
In test case 1: people can bring 1 piece of money: 1
In test case 2: people can bring 2 pieces of money: (1, 1) or (1, 2)
In test case 3: people can bring 3 pieces of money: (1, 1, 3) or (1, 2, 2) ….
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main()
{
int n,sum;
while(cin>>n)
{
sum=;
while(n)
{
n>>=;
sum++;
}
cout<<sum<<endl;
}
}
最新文章
- Andriod学习笔记2:“Your content must have a ListView whose id attribute is &#39;android.R.id.list&#39;”问题的解决办法
- Uva1398 Meteor
- Filestream复制视频文件
- GRE词汇3-4 +
- 简述 Ruby 与 DSL 在 iOS 开发中的运用
- 设置textView或者label的行间距方法
- mysql tcp 4层负载
- cocos2d-x3.0数据结构
- 顺序表----java实现
- 团队开发冲刺2-----1day
- java的logcat的简单使用
- Oracle_SQL92_连接查询
- Web前端学习(4):显示图片、url与文件路径
- oracle数据库密码过期修改注意事项
- Difference between hash() and id()
- Vue学习目录
- 最短路(SPFA)
- Fiddler抓包使用教程-基本功能介绍
- Git中使用amend解决提交冲突
- 40. Linux下7-zip解压到当前目录的命令