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. WinForm应用程序中实现自动更新功能

    WinForm应用程序中实现自动更新功能 编写人:左丘文 2015-4-20 近来在给一客户实施ECM系统,但他们使用功能并不是我们ECM制造版提供的标准功能,他们要求对系统作一些定制功能,为了避免因 ...

  2. hihocoder-1080题解

    一.题目链接 http://hihocoder.com/problemset/problem/1080 二.题意 一维区间,需要做区间增加和区间置值,以及对整个区间求和. 三.思路 显然线段树是个利器 ...

  3. c#中var类型用法同dynamic,object区别

    1.object万能对象:object只是个对象,是个强类型,在编译的时候确定类型了,只能用对象本身的方法属性等等,object想使用动态属性方法只能用反射. 2.var万能强类型. 3.dynami ...

  4. 在 ubuntu1604 中 搭建 i 屁 sec 虚拟专用连接服务器

    1.wget https://git.io/vpnsetup -O vpnsetup.sh 2.vim vpnsetup.sh 修改一些内容: 主要有三个参数:IPSEC的预共享秘钥,用户名,密码 3 ...

  5. jsp 学习 第2步 - tag 使用

    tag  类似 asp.net 用户控件,用于动态显示HTML 我首先在项目 /WebContent/WEB-INF/  建立 tags目录 用于存放 tag文件 新建一个message.tag 文件 ...

  6. asp.net,C#操作数据库DataTable关于空null的判断

    double d=0;if(!Convert.IsDBNull(DataTable.Rows[i][m])){    string str=DataTable.Rows[i][m].ToString( ...

  7. CB XE7 C11 64位编译器 成员变量初始化

    看到了C++11,看到了XE7的64位,想实现下面方便的类成员初始化,失望. 一.64位用法 clang3,64位编译器,不支持中文变量名,编写代码提示没有32位快,风格简单不用写单独的赋值语句函数, ...

  8. C++如何实现DNS域名解析<转>

    C++如何实现DNS域名解析 这片文章介绍了C++如何实现DNS域名解析,还有对相关技术的介绍,代码很详细,需要的朋友可以参考下   一.概述 现在来搞定DNS域名解析,其实这是前面一篇文章C++实现 ...

  9. sql server2008本地连接选择windows身份验证无法登陆的解决办法

    1.安装完sqlserver数据库,本地连接登录不了 解决办法:进入cmd,输入net start mssqlserver 服务启动后,再次用windows身份验证就可以登陆本地数据库了

  10. tr th td

    <table>     <caption></caption>     <thead>         <tr>             & ...