HDU 5308 I Wanna Become A 24-Point Master(2015多校第二场)
I Wanna Become A 24-Point Master
Time Limit: 2000/1000 MS (Java/Others) Memory
Limit: 65536/65536 K (Java/Others)
Total Submission(s): 485 Accepted Submission(s): 191
Special Judge
Quickly, Rikka solved almost all of the problems but the remained one is really difficult:
In this problem, you need to write a program which can get 24 points with
rev=2.4-beta-2" alt="" style=""> numbers,
which are all equal to .
rev=2.4-beta-2" alt="" style="">
rev=2.4-beta-2" alt="" style="">
rev=2.4-beta-2" alt="" style="">
rev=2.4-beta-2" alt="" style="">.
Each testcase contains only one integer
rev=2.4-beta-2" alt="" style="">
rev=2.4-beta-2" alt="" style="">
rev=2.4-beta-2" alt="" style="">
rev=2.4-beta-2" alt="" style="">
If there is not any way to get 24 points, print a single line with -1.
Otherwise, let be
an array with
rev=2.4-beta-2" alt="" style="">
rev=2.4-beta-2" alt="" style="">
rev=2.4-beta-2" alt="" style=""> numbers
and at firsrt
rev=2.4-beta-2" alt="" style="">
rev=2.4-beta-2" alt="" style="">
rev=2.4-beta-2" alt="" style="">
rev=2.4-beta-2" alt="" style="">
rev=2.4-beta-2" alt="" style="">.
You need to print lines
and the th
line contains one integer ,
one char and
then one integer c, where
rev=2.4-beta-2" alt="" style="">
rev=2.4-beta-2" alt="" style="">
rev=2.4-beta-2" alt="" style="">
rev=2.4-beta-2" alt="" style=""> and is
"+","-","*" or "/". This line means that you let and do
the operation
rev=2.4-beta-2" alt="" style=""> and
store the answer into
rev=2.4-beta-2" alt="" style="">
rev=2.4-beta-2" alt="" style="">.
If your answer satisfies the following rule, we think your answer is right:
1.
rev=2.4-beta-2" alt="" style="">
rev=2.4-beta-2" alt="" style="">
rev=2.4-beta-2" alt="" style="">
rev=2.4-beta-2" alt="" style="">
2. Each position of the array is
used at most one tine.
3. The absolute value of the numerator and denominator of each element in array
rev=2.4-beta-2" alt="" style=""> is
no more than
rev=2.4-beta-2" alt="" style="">
rev=2.4-beta-2" alt="" style="">
4
1 * 2
5 + 3
6 + 4
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
using namespace std;
int N;
int main()
{
while(scanf("%d", &N)!=EOF)
{
if(N == 1 || N == 2 || N == 3 ) printf("-1\n");
else if(N == 4)
{
printf("1 * 2\n");
printf("5 + 3\n");
printf("6 + 4\n");
}
else if(N == 5)
{
printf("1 * 2\n");//6 25
printf("3 * 6\n");//7 125
printf("7 - 4\n");//8 120
printf("8 / 5\n");//9 24
}
else if(N == 6)
{
printf("1 * 2\n");//7 36
printf("7 - 3\n");//8 30
printf("8 - 4\n");//9 24
printf("9 + 5\n");//10 30
printf("10 - 6\n");//11 24
}
else if(N == 7)
{
printf("1 / 2\n");//8 1
printf("3 + 8\n");//9 8
printf("4 + 5\n");//10 14
printf("10 + 6\n");//11 21
printf("11 / 7\n");//12 3
printf("12 * 9\n");//13 24
}
else if(N == 8)
{
printf("1 + 2\n");//9 16
printf("3 + 9\n");//10 24
printf("4 - 5\n");//11 0
printf("11 * 6\n");//12 0
printf("12 * 7\n");//13 0
printf("13 * 8\n");//14 0
printf("14 + 10\n");//15 24
}
else if(N == 9)
{
printf("1 + 2\n");//10 18
printf("10 + 3\n");//11 27
printf("11 * 4\n");//12 243
printf("12 / 5\n");//13 27
printf("6 + 7\n");//14 18
printf("14 + 8\n");//15 27
printf("15 / 9\n");//16 3
printf("13 - 16\n");//17 24
}
else if(N == 10)
{
printf("1 + 2\n");//11 20
printf("3 + 4\n");//12 20
printf("12 + 5\n");//13 30
printf("13 + 6\n");//14 40
printf("14 / 7\n");//15 4
printf("11 + 15\n");//16 24
printf("8 - 9\n");//17 0
printf("17 / 10\n");//18 0
printf("16 + 18\n");//19 24
}
else if(N == 11)
{
printf("1 + 2\n");//12 22
printf("12 / 3\n");//13 2
printf("13 + 4\n");//14 13
printf("14 + 5\n");//15 24
printf("15 + 6\n");//16 35
printf("16 + 7\n");//17 46
printf("17 + 8\n");//18 57
printf("18 - 9\n");//19 46
printf("19 - 10\n");//20 35
printf("20 - 11\n");//21 24
}
else if(N >= 12 && N % 2 == 0)
{
printf("1 + 2\n");//N+1 2*N
printf("%d + 3\n",N+1);//N+2 3*N
printf("4 + 5\n");//N+3 2*N
printf("%d + 6\n",N+3);//N+4 3*N
printf("%d + 7\n",N+4);//N+5 4*N
printf("8 + 9\n");//N+6 2*N
printf("%d / 10\n",N+2);//N+7 3
printf("%d / 11\n",N+5);//N+8 4
printf("%d / 12\n",N+6);//N+9 2
printf("%d * %d\n",N+7,N+8);//N+10 12
printf("%d * %d\n",N+9,N+10);//N+11 24
for(int i=0;i<(N-12)/2;i++)
{
printf("%d + %d\n",N+11+2*i,13+i*2);//N+12+2*i
printf("%d - %d\n",N+12+2*i,14+i*2);//N+13+2*i
}
}
else if(N>=13 && N % 2 == 1)
{
printf("1 + 2\n");//N+1 2*N
printf("%d + 3\n",N+1);//N+2 3*N
printf("4 + 5\n");//N+3 2*N
printf("%d + 6\n",N+3);//N+4 3*N
printf("%d + 7\n",N+4);//N+5 4*N
printf("%d + 8\n",N+5);//N+6 5*N
printf("%d + 9\n",N+6);//N+7 6*N
printf("%d + 10\n",N+7);//N+8 7*N
printf("%d + 11\n",N+8);//N+9 8*N
printf("%d / 12\n",N+2);//N+10 3
printf("%d / 13\n",N+9);//N+11 8
printf("%d * %d\n",N+10,N+11);//N+12 24
for(int i=0;i<(N-13)/2;i++)
{
printf("%d + %d\n",N+12+2*i,14+i*2);//N+13+2*i
printf("%d - %d\n",N+13+2*i,15+i*2);//N+14+2*i
} }
}
}
HDU 5308 I Wanna Become A 24-Point Master(2015多校第二场)的更多相关文章
- hdu 5308 (2015多校第二场第9题)脑洞模拟题,无语
题目链接:http://acm.hdu.edu.cn/listproblem.php?vol=44 题意:给你n个n,如果能在n-1次运算之后(加减乘除)结果为24的输出n-1次运算的过程,如果不能输 ...
- hdu 5305 Friends(2015多校第二场第6题)记忆化搜索
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5305 题意:给你n个人,m条关系,关系可以是online也可以是offline,让你求在保证所有人on ...
- hdu 5301 Buildings (2015多校第二场第2题) 简单模拟
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5301 题意:给你一个n*m的矩形,可以分成n*m个1*1的小矩形,再给你一个坐标(x,y),表示黑格子 ...
- HDU 5301 Buildings(2015多校第二场)
Buildings Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Tota ...
- HDU 5303 Delicious Apples (2015多校第二场 贪心 + 枚举)
Delicious Apples Time Limit: 5000/3000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Other ...
- hdu 5742 It's All In The Mind(2016多校第二场)
It's All In The Mind Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Oth ...
- HDU 5308 I Wanna Become A 24-Point Master
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5308 题面: I Wanna Become A 24-Point Master Time Limit ...
- 2015多校联合训练赛 hdu 5308 I Wanna Become A 24-Point Master 2015 Multi-University Training Contest 2 构造题
I Wanna Become A 24-Point Master Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 ...
- 2015 Multi-University Training Contest 2 hdu 5308 I Wanna Become A 24-Point Master
I Wanna Become A 24-Point Master Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 ...
随机推荐
- Android获取屏幕的大小与密度的代码
Android项目开发中很多时候需要获取手机屏幕的宽高以及屏幕密度来进行动态布局,这里总结了三种获取屏幕大小和屏幕密度的方法 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ...
- cc.AudioSource
cc.AudioSource1:AudioSource组件是音频源组件, 发出声音的源头2: AudioSource组件面板: clip: 声源的播放的音频对象: AudioClip, mp3, wa ...
- python3.x Day6 socketserver
socketserver是啥? 简化了编写网络服务器,就是对于socket的再一次封装sockerserver包含4个类可以使用:A=socketserver.TCPServer() #用于TCP/I ...
- wamp下mysql错误提示乱码的解法
出处:http://blog.csdn.net/jsship/article/details/42914217 运行mysql命令时,出现的错误提示是乱码 : [Err] 1064 - Erre ...
- (十)python3 生成器
生成器(generator):在 Python 中,不必创建完整的 list,从而节省大量的空间.一边循环一边计算的机制. 创建一个 generator,有很多种方法.第一种方法很简单,只要把一个列表 ...
- keil mdk uvision使用技巧
语法检测&代码提示 中文友好: tab 可以选中一大块代码,一起缩进 快速注释 先选中你要注释的代码区,然后右键,选择Advanced,Comment Selection 就可以了 查找替换 ...
- Django开发:(3.2)ORM:多表操作
表关系总结: 一对多:在多的表中建立关联字段 多对多:创建第三张表(关联表):id 和 两个关联字段 一对一:在两张表中的任意一张表中建立关联字段(关联字段一定要加 unique 约束) 子查询:一次 ...
- Thinkphp5.0 的使用模型Model更新数据
Thinkphp5.0 的使用模型Model更新数据 (1)使用update()方法进行更新数据 一.where条件写在更新数据中 (这种情况更新的数据,必须含主键) $res = User::upd ...
- DOM节点是啥玩意?
在 HTML DOM 中,所有事物都是节点.DOM 是被视为节点树的 HTML. DOM 节点 根据 W3C 的 HTML DOM 标准,HTML 文档中的所有内容都是节点: 整个文档是一个文档节点 ...
- 使用maven时,如何修改JVM的配置参数;maven命令执行时到底消耗多少内存?
maven是使用java启动的,因此依赖JVM,那么如何修改JVM参数? MAVEN_OPTS 在系统的环境变量中,设置MAVEN_OPTS,用以存放JVM的参数,具体设置的步骤,参数示例如下: MA ...