結果

問題 No.1156 Nada Picnic 2
ユーザー CleyLCleyL
提出日時 2024-01-20 23:08:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 664 bytes
コンパイル時間 848 ms
コンパイル使用メモリ 77,844 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-20 23:08:41
合計ジャッジ時間 1,596 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 28 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int n;cin>>n;
  if(n==1){
    cout << 1521 << endl;
  }else if(n==2){
    cout << 10649 << endl;
  }else{
    vector<int> x = {0,1,2,3,4,5,6,7,8,9};
    vector<int> k = {100000, 10000-100000, 1000, 1100-10010, 10, 101, 10000, 10-100, 1, -1001};
    do{
      if(x[0] == 0 || x[1] == 0 || x[6] == 0)continue;
      int cur = 0;
      for(int i = 0; 10 > i; i++){
        cur += x[i]*k[i];
      }
      if(cur == 0){
        cout << x[1] << x[3] << x[9] << x[7] << x[3] << x[9] << endl;
        return 0;
      }

    }while(next_permutation(x.begin(), x.end()));
  }
}
0