結果

問題 No.10 +か×か
ユーザー koyoprokoyopro
提出日時 2015-09-28 10:37:08
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,578 bytes
コンパイル時間 894 ms
コンパイル使用メモリ 79,948 KB
実行使用メモリ 38,848 KB
最終ジャッジ日時 2023-09-26 17:07:11
合計ジャッジ時間 5,689 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
12,796 KB
testcase_01 AC 10 ms
12,792 KB
testcase_02 AC 10 ms
12,744 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 64 ms
12,816 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 65 ms
18,860 KB
testcase_10 AC 16 ms
12,904 KB
testcase_11 AC 14 ms
13,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <math.h>
#include <vector>
#include <array>
#include <algorithm>
#include <queue>
#include <numeric>
#include <map>
#include <set>
#include <bitset>

using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define SUM(a) accumulate(ALL(a), 0)
#define array2(type, x, y) array<array<type, y>, x>
#define vector2(type) vector<vector<type> >
#define out(...) printf(__VA_ARGS__)

typedef pair<int, int> pos;
int pos::*x = &pos::first;
int pos::*y = &pos::second;

int dxy[] = {0, 1, 0, -1, 0};

/*================================*/

int MAX = 200000;
int N, total;
vector<int> A;
string m[300000];


signed main()
{
    cin >> N >> total;
    A.resize(N);
    REP(i,N) cin >> A[i];
    
    REP(i,MAX) m[i] = "";
    m[A[0]] = "+";
    FOR(i,1,N) {
        int a = A[i];
        RREP(j,MAX) {
            string s = m[j];
            if (s.size() != i) continue;
            if (j + a < MAX) {
                m[j+a] = s + "+";
            }
            if ((j+a) != (j*a) && j * a < MAX) {
                m[j*a] = s + "*";
            }
            if (m[j].size() == i) {
                m[j] = "";
            }
        }
    }
    
    cout << m[total].substr(1) << endl;
    
    return 0;
}

0