結果
| 問題 |
No.1156 Nada Picnic 2
|
| ユーザー |
forest3
|
| 提出日時 | 2020-12-22 01:37:44 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 16 ms / 2,000 ms |
| コード長 | 1,079 bytes |
| コンパイル時間 | 1,749 ms |
| コンパイル使用メモリ | 170,892 KB |
| 実行使用メモリ | 6,940 KB |
| 最終ジャッジ日時 | 2024-09-21 13:38:59 |
| 合計ジャッジ時間 | 2,132 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main()
{
int N;
cin >> N;
int ans = 0;
if( N == 1 ) ans = 1491;
else if( N == 2 ) {
int od[9] = { 0, 2, 3, 4, 5, 6, 7, 8, 9 };
vector<int> a( od, od + 9 );
do {
if( a[4] == 0 || a[5] == 0 ) continue;
int b = a[4] * 1000 + a[4] * 100 + a[1] * 10 + a[2];
int c = a[5] * 1000 + a[6] * 100 + a[7] * 10 + a[8];
int d = 10000 + a[0] * 1000 + a[1] * 100 + a[2] * 10 + a[3];
if( b + c == d ) {
ans = d;
break;
}
} while( next_permutation( a.begin(), a.end() ) );
}
else {
int od[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
vector<int> a( od, od + 10 );
do {
if( a[3] == 0 || a[6] == 0 || a[9] == 0 ) continue;
int b = a[3] * 100000 + a[9] * 10000 + a[4] * 1000 + a[0] * 100 + a[2] * 10 + a[5];
int c = a[6] * 10000 + a[0] * 1000 + a[5] * 100 + a[7] * 10 + a[8];
int d = a[9] * 100000 + a[0] * 10000 + a[1] * 1000 + a[2] * 100 + a[0] * 10 + a[1];
if( b + c == d ) {
ans = d;
break;
}
} while( next_permutation( a.begin(), a.end() ) );
}
cout << ans << endl;
}
forest3