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. 在laravel之外使用eloquent

    视频地址 https://laracasts.com/lessons/how-to-use-eloquent-outside-of-laravel

  2. zeromq测试

    debian sudo apt-get install libzmq3-dev pip install zmq client.py #coding: utf-8 import zmq context ...

  3. C#操作 iis启用父目录

    iis6实现: DirectoryEntry site = (DirectoryEntry)root.Invoke("Create", "IIsWebServer&quo ...

  4. Bootstrap-CL:导航元素

    ylbtech-Bootstrap-CL:导航元素 1.返回顶部 1. Bootstrap 导航元素 本章我们将讲解 Bootstrap 提供的用于定义导航元素的一些选项.它们使用相同的标记和基类 . ...

  5. JMS消息服务模型

    JMS--仅仅是一种规范,一种接口规约,一种编程模型.类似的JPA,JSR等 场景: 1.多个系统之间交互,实现可以采取RPC,但是交互复杂,基本就是点对点的方式 2.其实交互就是消息,而JMS就是消 ...

  6. 性能基准测试:KVM大战Xen

    编译自:http://major.io/2014/06/22/performance-benchmarks-kvm-vs-xen/作者: Major Hayden原创:LCTT https://lin ...

  7. solr统计只返回10或者100个数据的解决办法

    因为我所在的公司为政府做的项目[风险管理系统],其中涉及大量的统计展示,多数以整个市的区划,行业部门等方式返回,在昨天,我发现听过填报单位的方式返回时,始终只有100个数据.通过对比发现,在前辈的代码 ...

  8. uva-110-没有for循环的排序

    题意:看输出就懂了,暴力枚举题,字符串最大长度是8,所有长度等于8的长度是8!=1x2x3x4x5x6x7x8=40320,数据量比较小的.只是枚举的方向比较怪异,如下,长度等于3的串 a ab,ba ...

  9. Nginx 前后端分离配置 分发

    前端项目VUE  端口8081 , 后端项目JAVA 端口8080 # For more information on configuration, see: # * Official English ...

  10. JSF多列预选择

    <script type="text/javascript"> jQuery(document).ready(function () { preSelect(); }) ...