Suneast & Yayamao(2062)
来源:互联网 发布:nba哪只球队好看 知乎 编辑:程序博客网 时间:2024/06/11 00:18
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
Output
Sample Input
Sample Output
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 <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> #include <ctype.h> int main() {double i,n;while(scanf("%lf",&n)!=EOF){for(i=0;;i++){if(n<pow(2,i)){printf("%.0lf",i);break;}}printf("\n");} return 0; }
- Suneast & Yayamao(2062)
- FZU Problem 2062 Suneast & Yayamao
- FZU-2239 Daxia & Yayamao's problem(斜率优化)
- FZU 2239 Daxia & Yayamao's problem 斜率优化
- FOJ 有奖月赛 2016-8 C Problem C Daxia & Suneast's problem
- FZU Problem 2240 Daxia & Suneast's problem(博弈+[单点更新,区间查询]线段树)
- 2062(hdu-子序列)
- URAL 2062 Ambitious Experiment(树状数组)
- HDU 2062 Subset sequence (xjb搞)
- URAL 2062 Ambitious Experiment (树状数组)
- HDU 2062 Subset sequence(思维,数学)
- hdu 2062
- hdu 2062
- hdu 2062
- poj 2062
- Ural 2062
- hdu 2062
- POJ 2062 完全背包
- shell 指定日期加减1
- tomcat部署web项目的3中方法
- ds1620混杂设备驱动
- UIView_UIWindow
- for update 和 for update nowait
- Suneast & Yayamao(2062)
- Oracle 11g安装问题总结
- PageAdmin CMS关键词链接的使用方法
- 恣意玩耍荒唐青睐新天龙1整年燃情起始
- 懒加载
- 基于消息队列的C/S通信
- org.apache.hadoop.io
- android中的ellipsize
- 第八周 项目2-Time中的运算符重载