Description

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: "aopb = 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.

Sample Input

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
  • using namespace std;
  • int main()
  • {
  • int n;
  • while(~scanf("%d",&n))
  • {
  • if (n < 4)
  • {
  • printf("NO");
  • continue;
  • }
  • printf("YES\n");
  • if (n&1)//奇数
  • {
  • printf("3 + 4 = 7\n");
  • printf("7 + 5 = 12\n");
  • printf("12 * 2 = 24\n");
  • printf("24 * 1 = 24\n");
  • }
  • else
  • {
  • printf("1 * 2 = 2\n");
  • printf("2 * 3 = 6\n");
  • printf("6 * 4 = 24\n");
  • }
  • for (int i = n; i > 5; i -= 2)//全部转化为1
  • {
  • printf("%d - %d = 1\n",i,i-1);
  • printf("24 * 1 = 24\n");
  • }
  • }
  • return 0;
  • }

CodeForces 468A Program F的更多相关文章

  1. Codeforces #541 (Div2) - F. Asya And Kittens(并查集+链表)

    Problem   Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Inp ...

  2. Educational Codeforces Round 40 F. Runner's Problem

    Educational Codeforces Round 40 F. Runner's Problem 题意: 给一个$ 3 * m \(的矩阵,问从\)(2,1)$ 出发 走到 \((2,m)\) ...

  3. codeforces Gym 100187F F - Doomsday 区间覆盖贪心

    F. Doomsday Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/problem/F ...

  4. Codeforces gym 100685 F. Flood bfs

    F. FloodTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/F Desc ...

  5. Codeforces Gym 100513F F. Ilya Muromets 线段树

    F. Ilya Muromets Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513/probl ...

  6. Educational Codeforces Round 61 F 思维 + 区间dp

    https://codeforces.com/contest/1132/problem/F 思维 + 区间dp 题意 给一个长度为n的字符串(<=500),每次选择消去字符,连续相同的字符可以同 ...

  7. Educational Codeforces Round 51 F. The Shortest Statement(lca+最短路)

    https://codeforces.com/contest/1051/problem/F 题意 给一个带权联通无向图,n个点,m条边,q个询问,询问两点之间的最短路 其中 m-n<=20,1& ...

  8. Codeforces Gym 100513F F. Ilya Muromets 水题

    F. Ilya Muromets Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513/probl ...

  9. Educational Codeforces Round 12 F. Four Divisors 求小于x的素数个数(待解决)

    F. Four Divisors 题目连接: http://www.codeforces.com/contest/665/problem/F Description If an integer a i ...

随机推荐

  1. Java Date与SimpleDateFormat

    最近在弄一些涉及到时间处理的项目.本来自己写了一个时间转换函数,虽然能用但是过于麻烦而且不够规范,于是学习了下java自带的时间处理的类. public class Timechg { public ...

  2. C# Web中Session的使用

    1. 关于使用之前要注意的: 在使用session之前,一定要注意继承自System.Web.UI.Page,或在使用session时加上System.Web.HttpContext.Current: ...

  3. phalcon count统计

    单表count: //How many robots are there? $number = Robots::count(); echo "There are ", $numbe ...

  4. Selenium解决页面元素不在视野范围内的问题

    当需要使用滚动条才能使页面元素显示在视野范围内时,必须用代码处理下,才能对其进行操作. 处理其实也很简单,就是调用JS函数. driver.executeScript("arguments[ ...

  5. 【BZOJ 2818】Gcd - 筛法求素数&phi()

    题目描述 给定整数,求且为素数的数对有多少对. 分析 首先筛出所有的素数. 我们考虑枚举素数p,统计满足的个数,等价于统计的个数,即统计以内满足互质的有序数对个数. 不难发现,也就是说,我们只要预处理 ...

  6. 父类中“this” 指向问题

    “this.字段”如果出现在父类代码中,指的就是父类属性. “this.方法”不管出现在父类还是子类代码中,指的都是子类方法. “this.字段”如果出现在子类代码中,指的就是子类属性. 在程序的时候 ...

  7. 关于64位WIN7下正确建立JAVA开发环境(转

    1.下载并安装JDK(地址:http://www.oracle.com/technetwor ... ownload-400750.html     先在“Accept License Agreeme ...

  8. hdu 3635 Dragon Balls (带权并查集)

    Dragon Balls Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  9. Objective-C:Foundation框架-常用类-NSMutableArray

    NSMutableArray是NSArray对的子类,它是可变的,可以随意添加或者删除元素.与Array,也有静态和动态两种创建方法.也可已使用NSArray的方法来创建NSMutableArray. ...

  10. 继承多态绕点 C#篇

    最近在看博客的时候看到一块很绕的地方,有点类似于以前学习C语言是的i++,++i组合到一起使用的情况,很坑b的,绝对会比i++,++i这种情况更有用,虽然实际代码里面确实很少出现. 面对象像三大特点不 ...