【构造】 Codeforces 468A 24 Game

先搞一个4的和5的

然后如果是偶数就是由4的来构造

奇数就是由5的来构造

比如n(偶数)  6-5=1 可以形成(n-4)/ 2 个1 都乘于 24   还是=24

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <math.h>
using namespace std;
#include <queue>
#include <stack>
#include <vector>
#include <deque>
#include <map>
#define cler(arr, val)    memset(arr, val, sizeof(arr))
#define IN     freopen ("in.txt" , "r" , stdin);
#define OUT  freopen ("out.txt" , "w" , stdout);
typedef long long  LL;
const int MAXN = 5040;//点数的最大值
const int MAXM = 20006;//边数的最大值
const int INF = 0x3f3f3f3f;
const int mod = 10000007;
int main()
{
    //IN;
    int n,a,b;
    cin>>n;
    if(n<=3)
        puts("NO");
    else if((n-4)%2==0)
    {
        puts("YES");
        puts("2 * 4 = 8");
        puts("3 * 1 = 3");
        puts("8 * 3 = 24");
        for(int i=5; i<=n; i+=2)
            printf("%d - %d = 1\n",i+1,i);
        for(int i=0; i<(n-4)/2; i++)
            printf("%d * %d = %d\n",24,1,24);
    }
    else if((n-5)%2==0)
    {
        puts("YES");
        puts("3 + 5 = 8");
        puts("4 - 2 = 2");
        puts("2 + 1 = 3");
        puts("3 * 8 = 24");
        for(int i=6; i<=n; i+=2)
            printf("%d - %d = 1\n",i+1,i);
        for(int i=0; i<(n-5)/2; i++)
            printf("%d * %d = %d\n",24,1,24);
    }
}


posted @ 2014-09-21 19:09  kewowlo  阅读(196)  评论(0编辑  收藏  举报