Poj 3210 Coins(推理)
来源:互联网 发布:freenom域名怎么用 编辑:程序博客网 时间:2024/06/09 18:59
题目:http://poj.org/problem?id=3210
Description
Snoopy has three coins. One day he tossed them on a table then and tried to flip some of them so that they had either all heads or all tails facing up. After several attempts, he found that regardless of the initial configuration of the coins, he could always achieve the goal by doing exactly two flippings, under the condition that only one coin could be flipped each time and a coin could be flipped more than once. He also noticed that he could never succeed with less than two flippings.
Snoopy then wondered, if he had n coins, was there a minimum number x such that he could do exactly x flippings to satisfy his requirements?
Input
The input contains multiple test cases. Each test case consists of a single positive integern (n < 10,000) on a separate line. A zero indicates the end of input and should not be processed.
Output
For each test case output a single line containing your answer without leading or trailing spaces. If the answer does not exist, output “No Solution!
”
Sample Input
230
Sample Output
No Solution!2
/*如果硬币的数目是偶数,那么初始不同面的硬币数a,b有两种情况:1.a是偶数,b是偶数,那么最小的翻转数就是偶数.2.a是奇数,b是奇数,那么最小的翻转数就是奇数.所以最小的翻转数十不存在的(不确定的)如果硬币的数目是奇数,那么初始不同面的硬币数a,b的情况:a是偶数,b是奇数(反之一样),要让硬币满足要求:全部面朝上或朝下(下和上都能做到)那么极限情况下最小的异面数就是一个。所以要满足"(下和上都能做到)"的翻转数就是n-1.*/#include <iostream>#include <cstdio>using namespace std;int main(){ int n; while(cin>>n&&n){ if(n&1) printf("%d\n",n-1); else puts("No Solution!"); } return 0;}
- Poj 3210 Coins(推理)
- poj 3210 Coins
- poj 3210 Coins
- POJ 3210 : Coins
- POJ-3210-Coins-解题报告
- POJ Coins
- POJ Coins
- HDU2401 Baskets of Gold Coins【水题】【推理】
- POJ 3210 Coins (很好的想法题)
- POJ 2128 ----推理
- poj 1742 Coins
- POJ 2000 Gold Coins
- poj 2000 Gold Coins
- POJ 1742 Coins
- POJ 1742 Coins
- poj 1742 Coins
- poj 2000 Gold Coins
- poj 1742 Coins
- 自学Java系列 笔记4 多线程 1
- 新手dp
- 自学Java系列 笔记4 多线程 2
- OC中多线程的使用、概念、创建方式、生命周期、使用注意等
- [笔记][Java7并发编程实战手册]4.9-4.10在执行器中控制任务的完成和取消任务FutureTask
- Poj 3210 Coins(推理)
- 自学Java系列 笔记4 线程安全
- mpstat
- android目录结构
- 文件操作
- Python 异常处理
- 自学Java系列 笔记5 Java学习之HashMap和Hashtable的区别
- html 杂
- mysql主从复制(个人实验记录)