結果

問題 No.3235 巡回減算
ユーザー SnowBeenDiding
提出日時 2025-08-15 21:59:18
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
MLE  
実行時間 -
コード長 972 bytes
コンパイル時間 5,725 ms
コンパイル使用メモリ 335,008 KB
実行使用メモリ 784,648 KB
最終ジャッジ日時 2025-08-15 22:00:58
合計ジャッジ時間 47,777 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other MLE * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#include <atcoder/all>
#define rep(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
using namespace atcoder;
using namespace std;

typedef long long ll;

vector<int> f(int x) {
    vector<int> ret;
    rep(i, 0, 8) {
        x = (x % 10) * 10000000 + (x / 10);
        ret.push_back(x);
    }
    return ret;
}

void solve() {
    int n;
    cin >> n;
    vector<int> dp(100000000);
    dp[n] = 1;
    rep(i, 0, 7) {
        vector<int> ndp(100000000);
        int x;
        cin >> x;
        auto xs = f(x);
        rep(j, 0, 100000000) {
            if (dp[j] == 0) continue;
            rep(k, 0, 8) {
                if (j >= xs[k]) {
                    ndp[j - xs[k]] = 1;
                }
            }
        }
        swap(dp, ndp);
    }
    cout << (dp[0] ? "Yes" : "No") << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(12);
    int t = 1;
    while (t--) solve();
}
0