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;
}
}

Problem 2062 Suneast & Yayamao 二进制(多重背包的理解基础)的更多相关文章

  1. FZU Problem 2062 Suneast & Yayamao

    http://acm.fzu.edu.cn/problem.php?pid=2062 题目大意: 给你一个数n,要求求出用多少个数字可以表示1~n的所有数. 思路: 分解为二进制. 对于一个数n,看它 ...

  2. FZU - 2062 - Suneast & Yayamao

    先上题目: Problem 2062 Suneast & Yayamao Accept: 146    Submit: 319Time Limit: 1000 mSec    Memory L ...

  3. QDUOJ ycb的ACM进阶之路 二进制多重背包

    ycb的ACM进阶之路 发布时间: 2017年5月22日 14:30   最后更新: 2017年5月22日 14:31   时间限制: 1000ms   内存限制: 128M 描述 ycb是个天资聪颖 ...

  4. FZU Problem 2062 Suneast &amp; Yayamao

    http://acm.fzu.edu.cn/problem.php?pid=2062 标题效果: 给你一个数n,要求求出用多少个数字能够表示1~n的全部数. 思路: 分解为二进制. 对于一个数n.看它 ...

  5. 【二进制】FZU 2062 Suneast & Yayamao

    题意:给出n,问最少需要多少个数字,这些数字能组成1~n的所有数: 分析:n=1; 1; 1个 n=2; 1,1;  2个 1 = 1; 2 = 1+1;   n=3; 1,2; 2个 1 = 1; ...

  6. 51nod 1086 背包问题 V2 【二进制/多重背包】

    1086 背包问题 V2  基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题  收藏  关注 有N种物品,每种物品的数量为C1,C2......Cn.从中任选若干件放 ...

  7. POJ1742Coins(多重背包)

    Coins Time Limit: 3000MS   Memory Limit: 30000K Total Submissions: 32309   Accepted: 10986 Descripti ...

  8. HDU 5445 Food Problem(多重背包+二进制优化)

    http://acm.hdu.edu.cn/showproblem.php?pid=5445 题意:现在你要为运动会提供食物,总共需要提供P能量的食物,现在有n种食物,每种食物能提供 t 能量,体积为 ...

  9. hdu 2191 (多重背包+二进制优化)

    Problem Description 急!灾区的食物依然短缺!为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大米,每种大米都是袋装产品, ...

随机推荐

  1. Tornado模板

    --------------------静态文件-------------------- 1.static_path:通过向web.Application类的构造函数传递一个名为static_path ...

  2. django模板(过滤器)

    -------------------django内建的过滤器-------------------1.add 使用形式为:{{ value | add: "2"}} 意义:将va ...

  3. MongoDB基本shell操作

    ---------------------MongoDB基本操作--------------------- 1.MongoDB创建数据库     use 数据库名:切换到指定的数据库中,在插入第一个条 ...

  4. lucene&solr-day1

        全文检索课程 Lucene&Solr(1) 1.   计划 第一天:Lucene的基础知识 1.案例分析:什么是全文检索,如何实现全文检索 2.Lucene实现全文检索的流程 a)   ...

  5. java 8 总结 之lambda

    lambda表达式 目的:行为参数化 Lambda表达式是简洁地表示可传递的匿名函数的一种方式:它没有名称,但它有参数列表.函数主体.返回类型,可能还有一个可以抛出的异常列表. Lambda的基本语法 ...

  6. Android学习记录:线程

    在Java中,线程的建立方法如下. 新建一个类,接口Runnable,重载 run方法 import javax.swing.JTextField; public class test impleme ...

  7. Run Logic

    1.lr_output_message()函数,其作用是将内容输出到Replay Log中: 如果输出整数型内容,应该这样写; int x; x=10; lr_output_message(" ...

  8. 转: 【Java并发编程】之十七:深入Java内存模型—内存操作规则总结

    转载请注明出处:http://blog.csdn.net/ns_code/article/details/17377197 主内存与工作内存 Java内存模型的主要目标是定义程序中各个变量的访问规则, ...

  9. oop作业二—circle

    oop作业-circle 题目描述 编写一个程序,要求根据给定的圆的半径求圆的面积,并将求得的结果打印出来. 要求: 输入输出采用cin和cout. 建立一个工程,将程序写成两个.cpp和一个.h的形 ...

  10. 团队作业4——第一次项目冲刺(Alpha版本) 日志集合处

    第一天(2017.4.23) http://www.cnblogs.com/1413none/p/6752325.html 第二天(2017.4.24) http://www.cnblogs.com/ ...