Little X used to play a card game called "24 Game", but recently he has found it too easy. So he invented a new game.

Initially you have a sequence of n integers: 1, 2, ..., n. In a single step, you can pick two of them, let's denote them a and b, erase them from the sequence, and append to the sequence either a + b, or a - b, or a × b.

After n - 1 steps there is only one number left. Can you make this number equal to 24?

Input

The first line contains a single integer n (1 ≤ n ≤ 105).

Output

If it's possible, print "YES" in the first line. Otherwise, print "NO" (without the quotes).

If there is a way to obtain 24 as the result number, in the following n - 1 lines print the required operations an operation per line. Each operation should be in form: "a op b = c". Where a and b are the numbers you've picked at this operation; op is either "+", or "-", or "*"; c is the result of corresponding operation. Note, that the absolute value of c mustn't be greater than 1018. The result of the last operation must be equal to 24. Separate operator sign and equality sign from numbers with spaces.

If there are multiple valid answers, you may print any of them.

Examples

Input
1
Output
NO
Input
8
Output
YES
8 * 7 = 56
6 * 5 = 30
3 - 4 = -1
1 - 2 = -1
30 - -1 = 31
56 - 31 = 25
25 + -1 = 24 题意:24点游戏,给出了你一个数字n,你需要在1-n的数字序列中选择两个数进行加,减,或乘法运算,然后运算出的结果也加入序列中,再选择两个数,进行同样的操作,问你能不能使得最后只剩下一个数,且那个数是24。若可以,输出YES以及每一步的运算公式。否则输出NO。

思路:
一开始被这题给吓到了,第一眼看起来很难,实际上却很简单。。。只要确保了一个24和一个0就行了。 比如8,可以是4*6 = 24,1+2=3,3-3=0,这样就确保了 24 和 0 了,然后剩下的数都可以和 0 做乘法运算等到0(5*0=0,7*0=0,8*0=0),最后24+0=24就行了。 所以,若n大于等于6,那一定可以通过上面的方法得出24,因为最小需要4*6=24。然后特判一下1-5就行了。 1-3肯定是凑不出24的,然而4和5却可以,具体怎么凑的看代码:
 #include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#define eps 1e-7
#define ll long long
#define inf 0x3f3f3f3f
#define pi 3.141592653589793238462643383279
using namespace std;
int main()
{
int n;
while(cin>>n)
{
if(n >= )
{
cout<<"YES"<<endl;
cout<<"1 + 2 = 3"<<endl;
cout<<"3 - 3 = 0"<<endl;
for(int i = ; i<=n; ++i)
{
if(i== || i== || i== || i== || i==)
continue;
else
cout<<i<<" * 0 = 0"<<endl;
}
cout<<"0 + 4 = 4"<<endl;
cout<<"4 * 6 = 24"<<endl;
}
else if(n == )
{
cout<<"YES"<<endl;
cout<<"1 * 2 = 2"<<endl;
cout<<"2 * 3 = 6"<<endl;
cout<<"6 * 4 = 24"<<endl;
}
else if(n == )
{
cout<<"YES"<<endl;
cout<<"3 * 5 = 15"<<endl;
cout<<"2 * 4 = 8"<<endl;
cout<<"1 + 8 = 9"<<endl;
cout<<"9 + 15 = 24"<<endl;
}
else cout<<"NO"<<endl;
}
return ;
}

CodeForces - 468A ——(思维题)的更多相关文章

  1. Codeforces 424A (思维题)

    Squats Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Statu ...

  2. Vova and Trophies CodeForces - 1082B(思维题)

    Vova has won nn trophies in different competitions. Each trophy is either golden or silver. The trop ...

  3. CodeForces - 417B (思维题)

    Crash Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status ...

  4. CodeForces - 417A(思维题)

    Elimination Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit  ...

  5. B - Sonya and Exhibition CodeForces - 1004B (思维题)

    B. Sonya and Exhibition time limit per test 1 second memory limit per test 256 megabytes input stand ...

  6. codeforces ~ 1009 B Minimum Ternary String(超级恶心的思维题

    http://codeforces.com/problemset/problem/1009/B B. Minimum Ternary String time limit per test 1 seco ...

  7. 贪心/思维题 Codeforces Round #310 (Div. 2) C. Case of Matryoshkas

    题目传送门 /* 题意:套娃娃,可以套一个单独的娃娃,或者把最后面的娃娃取出,最后使得0-1-2-...-(n-1),问最少要几步 贪心/思维题:娃娃的状态:取出+套上(2),套上(1), 已套上(0 ...

  8. C. Nice Garland Codeforces Round #535 (Div. 3) 思维题

    C. Nice Garland time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  9. CodeForces - 631C ——(思维题)

    Each month Blake gets the report containing main economic indicators of the company "Blake Tech ...

  10. CodeForces - 1102A(思维题)

    https://vjudge.net/problem/2135388/origin Describe You are given an integer sequence 1,2,-,n. You ha ...

随机推荐

  1. 介绍一个开源的 C++ 开发框架 openFrameworks 。

    作为一个图形图像方向的研究生,我经常都在和 OpenGL .OpenCV 等多种 C++ 库打交道.这些库遵循着不同的规则和用法:另外,为了让自己的程序具有更多的交互能力,编写界面也是一个家常便饭的工 ...

  2. 关于Class.getResource和ClassLoader.getResource的路径问题(转)

    参考博客:http://www.cnblogs.com/yejg1212/p/3270152.html Class.getResource(String path) 当path以/开头,如/a/b/c ...

  3. Java 简单UDP通信

    Java手册 java.net Class DatagramSocket java.lang.Object java.net.DatagramSocket All Implemented Interf ...

  4. 深入浅出spring IOC中三种依赖注入方式

    深入浅出spring IOC中三种依赖注入方式 spring的核心思想是IOC和AOP,IOC-控制反转,是一个重要的面向对象编程的法则来消减计算机程序的耦合问题,控制反转一般分为两种类型,依赖注入和 ...

  5. mysql-5null值处理

    值为null遇到的问题: 1.使用select对数据进行处理时,如果有格值为null,该命令会无法正常工作.如示例一 2.使用where限定条件时,null值不能处理.如示例二 -- 新建一张表,并填 ...

  6. 20181205_C#窗体监听键盘事件

    1. 需要设置窗体的   KeyPreview = true; 2. 如果窗体上有获取的了焦点的button按钮, 则监听不到 Enter事件, 需要取消按钮的焦点

  7. 第八章(三)基于Listcheck适配器的访问控

    denier适配器访问控制比较死板.Listchecker的适配器更加灵活. 定义handler: apiVersion: config.istio.io/v1alpha2 kind: listche ...

  8. JVM实例以及内存的分配机制

    JVM:一台用来模拟计算机执行计算指令的虚拟计算机,拥有自己的指令,指令执行环境,虚拟内存等. 下面介绍虚拟机(JVM)--cpu,寄存器,内存,指令 ======================== ...

  9. css字体中px和em的区别

    2015-05-28 昨天看到一个不错的纯css3表格样式,看到代码后注意到了作者用的都是em在控制大小.顿时想到了自己习惯使用的px长度单位,就查了关于两者的区别.综合前辈们的总结记录整理下来,以供 ...

  10. eclipse Android 开发基础 Activity 窗体 界面

    eclipse Android 开发基础 新建工程 新建布局layout,new Android Activity就相当于窗体Form. 新建Activity自动生成src下同名的java代码. pu ...