結果

問題 No.1156 Nada Picnic 2
ユーザー kpinkcatkpinkcat
提出日時 2023-08-27 19:53:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 862 ms / 2,000 ms
コード長 5,093 bytes
コンパイル時間 1,360 ms
コンパイル使用メモリ 111,044 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-27 19:53:56
合計ジャッジ時間 3,011 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<map>
#include<vector>
#include <algorithm>
#include<math.h>
#include <iomanip>
#include<set>
#include <numeric>
#include<string>
using namespace std;


int main()
{
    int a, b, c, d, e, f, g, h, i, j, n;
    cin >> n;
    set<int> st;
    if (n == 1){
        for (int a = 1; a <= 9; a++){
            for (int b = 0; b <= 9; b++){
                for (int c = 0; c <= 9; c++){
                    for (int d = 1; d <= 9; d++){
                        for (int e = 0; e <= 9; e++){
                            for (int f = 0; f <= 9; f++){
                                if((100*a + 10 + c) + (100*d + 10*e + f) == 1000 + 100*b + 10*c + 1){
                                    st.insert(a);
                                    st.insert(b);
                                    st.insert(c);
                                    st.insert(d);
                                    st.insert(e);
                                    st.insert(f);
                                    st.insert(1);
                                    if (st.size() == 7) cout << 1 << b << c << 1 << endl;
                                    st.clear();
                                } 
                            }
                        }
                    }
                }
            }
        }
    }
    if (n == 2){
        for (int a = 1; a <= 9; a++){
            for (int b = 0; b <= 9; b++){
                for (int c = 0; c <= 9; c++){
                    for (int d = 1; d <= 9; d++){
                        for (int e = 0; e <= 9; e++){
                            for (int f = 0; f <= 9; f++){
                                for (int g = 0; g <= 9; g++){
                                    for (int h = 0; h <= 9; h++){
                                        for (int i = 0; i <= 9; i++){
                                            if((1000*a + 100*a + 10*b + c) + (1000*d + 100*e + 10*f + g) == 10000 + 1000*h + 100*b + 10*c + i){
                                                st.insert(a);
                                                st.insert(b);
                                                st.insert(c);
                                                st.insert(d);
                                                st.insert(e);
                                                st.insert(f);
                                                st.insert(g);
                                                st.insert(h);
                                                st.insert(i);
                                                st.insert(1);
                                                if (st.size() == 10) cout << 1 << h << b << c << i << endl;
                                                st.clear();
                                            }
                                        }
                                    }
                                } 
                            }
                        }
                    }
                }
            }
        }
    }
    if (n == 3){
        for (int a = 1; a <= 9; a++){
            for (int b = 0; b <= 9; b++){
                if (b == a) continue;
                for (int c = 0; c <= 9; c++){
                    if (c == a || c == b) continue;
                    for (int d = 0; d <= 9; d++){
                        if (d == a || d == b || d == c) continue;
                        for (int e = 0; e <= 9; e++){
                            if (e == a || e == b || e == c || e == d) continue;
                            for (int f = 0; f <= 9; f++){
                                if (f == a || f == b || f == c || f == d || f == e) continue;
                                for (int g = 1; g <= 9; g++){
                                    if (g == a || g == b || g == c || g == d || g == e || g == f) continue;
                                    for (int h = 0; h <= 9; h++){
                                        if (h == a || h == b || h == c || h == d || h == e || h == f || h == g) continue;
                                        for (int i = 0; i <= 9; i++){
                                            if (i == a || i == b || i == c || i == d || i == e || i == f || i == g || i == h) continue;
                                            for (int j = 0; j <= 9; j++){
                                                if (j == a || j == b || j == c || j == d || j == e || j == f || j == g || j == h || j == i) continue;
                                                if((100000*a + 10000*b + 1000*c + 100*d + 10*e + f) + (10000*g + 1000*d + 100*f + 10*j + h) == 100000*b + 10000*d + 1000*i + 100*e + 10*d + i){
                                                    cout << b << d << i << e << d << i << endl;
                                                }
                                            }
                                        }
                                    }
                                } 
                            }
                        }
                    }
                }
            }
        }
    }
}
0