CSU 1727: The Fake Coin
来源:互联网 发布:js与java aes 编辑:程序博客网 时间:2024/05/16 04:44
题目:
Description
There are n coins,one of them is fake.The fake coin is heavier than a genuine one.If you have a balance,how many times at least you need to use it to find the fake coin?
Input
The first line contains an integer T (T<=100), means there are T test cases.
For each test case, there is only one line with an integer n (1 <= n <= 10000). The num of coins.
Output
For each test case, output the least times you need.
Sample Input
3234
Sample Output
112
这个题目,为了加快速度,直接硬编码了。原理就不说了。。。小学生都会。
代码:
#include<iostream>;using namespace std; int main(){ int t; cin >> t; int n; while (t--) { cin >> n; if (n > 6561)cout << 9; else if (n > 2187)cout << 8; else if (n > 729)cout << 7; else if (n > 243)cout << 6; else if (n > 81)cout << 5; else if (n > 27)cout << 4; else if (n > 9)cout << 3; else if (n > 3)cout << 2; else if (n > 1)cout << 1; else cout << 0; cout << endl; } return 0;}
1 0
- CSU 1727: The Fake Coin
- csuoj-1727-The Fake Coin
- HOJ 2519 Fake coin
- Hoj 2519 Fake coin
- The Coin Change Problem
- the difference of real and fake fingerprint
- csu 1326 The contest
- 5 Drease-and-Conquer Fake-Coin Problem(减治法求假币问题)
- POJ 3260 The Fewest Coin
- [Hackerrank] The Coin Change Problem
- CSU 1513 Kick the ball!
- csu 1469 Change The Handles
- CSU 1513 Kick the ball!
- CSU 1566The Maze Makers
- CSU 1908: The Big Escape
- CSU 1566The Maze Makers
- .Coin
- Coin
- CodeForces 385E
- PAT 1086
- 嵌入式常用算法:时间触发下的嵌入式软件设计模式
- Android开发之Intent.Action
- 二叉搜索树
- CSU 1727: The Fake Coin
- C++学习笔记——Mat类详解及元素的遍历方法
- tjut 4612
- UVA 10518
- 嵌入式学习-驱动开发-lesson1-字符设备驱动模型
- C++ hdoj 2007 平方和与立方和
- 浅析android事件分发机制
- 欢迎使用CSDN-markdown编辑器
- CSU 1729: 齿轮传动