結果
問題 |
No.3235 巡回減算
|
ユーザー |
![]() |
提出日時 | 2025-08-16 00:18:08 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 10,000 ms |
コード長 | 765 bytes |
コンパイル時間 | 3,666 ms |
コンパイル使用メモリ | 305,136 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-08-16 00:18:13 |
合計ジャッジ時間 | 5,002 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
#pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #define rep(i, n) for(int i = 0; i < n; ++i) #include <bits/stdc++.h> using namespace std; int f(int a){ int res = 0; while(a) res += a%10, a/=10; return res; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int x, y[7][8]; cin >> x; rep(i,7) cin >> y[i][0]; int cnt = f(x); rep(i,7) cnt -= f(y[i][0]); if(cnt){ cout << "No\n"; return 0; } rep(i,7)rep(j,7) y[i][j+1] = y[i][j]%10*10000000 + y[i][j]/10; bool ans = false; rep(a,8)rep(b,8)rep(c,8)rep(d,8)rep(e,8)rep(f,8)rep(g,8){ if(y[0][a]+y[1][b]+y[2][c]+y[3][d]+y[4][e]+y[5][f]+y[6][g]==x) ans = true; } cout << (ans?"Yes\n":"No\n"); return 0; }