Codeforces Round #268 (Div. 2) C 24 Game [构造]
来源:互联网 发布:网络交友新时空ppt 编辑:程序博客网 时间:2024/06/05 02:38
题目链接:http://codeforces.com/contest/469/problem/C
题意很简单,给你1 - n 的n和数,每次操作,随意的拿出来两个做+,-,*,然后放回原来的数列中。问,经过n-1次操作后,会不会等于24。。并输出其每次的操作。。
思路的xp提供的。。表示很好,很强大。。
我们观察发现,当n = 1,2,3,的时候是不可能的。。
我们知道当n = 4的时候,可以。
并且 2 * 3 = 6 6 * 4 = 24 24 * 1 = 24。
当 n = 5 的时候,也是可以的。。
当n = 6 的时候,我们可以看到 6,5 ,1可以组出来一个0,在利用n= 4 的结果。。也就可以得出来结果了。。
具体看
Code:
#include <iostream>using namespace std;const int N = 1e3 + 5;int main(){ int n; cin >> n; if(n <= 3){ cout << "NO" << endl; } else if(n == 4){ cout << "YES" << endl; cout << "2 * 3 = 6" << endl; cout << "4 * 6 = 24" << endl; cout << "1 * 24 = 24" << endl; } else if(n == 5){ cout << "YES" << endl; cout << "5 - 2 = 3" << endl; cout << "3 + 3 = 6" << endl; cout << "4 * 6 = 24" << endl; cout << "24 * 1 = 24" << endl; } else { cout << "YES" << endl; cout << "6 - 5 = 1" << endl; cout << "1 - 1 = 0" << endl; for(int i = 7; i <= n; i ++){ cout << i << " * 0 = 0" << endl; } cout << "2 * 3 = 6" << endl; cout << "6 * 4 = 24" << endl; cout << "24 + 0 = 24" << endl; } return 0;}
表示对xp的ym。。。
手上简单一模拟, 思路就出来了。。
对于一个问题的分析, 你应该怎样的去分析。。。你需要思考一下。。
0 0
- Codeforces Round #268 (Div. 2) C 24 Game [构造]
- Codeforces Round#268(Div 2)C 24 Game
- Codeforces Round #268 (Div. 2) C 24 Game
- Codeforces Round #268 (Div. 2)+24 Game
- Codeforces Round #287 (Div. 2) C. (构造)
- Codeforces Round #105 (Div. 2) C 构造
- Codeforces Round #287 (Div. 2) C 构造
- Codeforces Round #372 (Div. 2) C 构造
- Codeforces Round #419 (Div. 2) C.Karen and Game 思维
- Codeforces Round #419 (Div. 2) C. Karen and Game 题解
- (Codeforces Round #426 (Div. 2)) C.The Meaningless Game
- Codeforces Round #426 (Div. 2) C. The Meaningless Game
- Codeforces Round #426 (Div. 2)-C. The Meaningless Game
- Codeforces Round #426 (Div. 2) C The Meaningless Game
- Codeforces Round #426 (Div. 2) C. The Meaningless Game
- Codeforces Round #426 (Div. 2) C. The Meaningless Game
- Codeforces Round #419 (Div. 2) C. Karen and Game【贪心】
- Codeforces Round #426 (Div. 2) C The Meaningless Game
- ASP.NET 随笔
- 自学考试本科日语
- js中SetInterval与setTimeout用法
- oracle 的起源和发展
- codeblocks中设置gcc的链接方式
- Codeforces Round #268 (Div. 2) C 24 Game [构造]
- D层重构一《Sqlhelper》
- thinkphp文件上传与下载
- C++ rand,srand用法
- QT学习点滴记录(四)
- C++ explicit构造函数----禁止隐式格式转换
- js笔记之Math random()、ceil()、floor()、round()
- Explicit——谨慎定义隐式类型转换函数
- UNIX基本命令-目录及文件操作