結果

問題 No.10 +か×か
ユーザー koyoprokoyopro
提出日時 2015-09-28 10:27:06
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,559 bytes
コンパイル時間 821 ms
コンパイル使用メモリ 79,360 KB
実行使用メモリ 38,284 KB
最終ジャッジ日時 2023-09-26 17:05:22
合計ジャッジ時間 4,181 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
12,696 KB
testcase_01 AC 11 ms
12,908 KB
testcase_02 AC 11 ms
12,840 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 66 ms
12,648 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 WA -
testcase_09 RE -
testcase_10 AC 15 ms
12,960 KB
testcase_11 AC 14 ms
12,820 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];
        REP(j,MAX) {
            string s = m[j];
            if (s.size() != i) continue;
            if (j * a < MAX) {
                m[j*a] = s + "*";
            }
            if (j + a < MAX) {
                m[j+a] = s + "+";
            }
            if (m[j].size() == i) {
                m[j] = "";
            }
        }
    }
    
    cout << m[total].substr(1) << endl;
    
    return 0;
}

0