結果

問題 No.2358 xy+yz+zx=N
ユーザー MAHAYANAMAHAYANA
提出日時 2023-10-28 11:29:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 656 ms / 2,000 ms
コード長 770 bytes
コンパイル時間 5,582 ms
コンパイル使用メモリ 175,624 KB
実行使用メモリ 5,992 KB
最終ジャッジ日時 2023-10-28 11:29:57
合計ジャッジ時間 6,167 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 7 ms
4,348 KB
testcase_08 AC 656 ms
5,824 KB
testcase_09 AC 637 ms
5,992 KB
testcase_10 AC 591 ms
4,484 KB
testcase_11 AC 575 ms
4,736 KB
testcase_12 AC 448 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:27:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   27 |     for(auto [x,y,z] : ans){
      |              ^

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,m,n) for(int i=m; i<n; ++i)
#define repl(i,m,n) for(ll i=m; i<n; ++i)

int main(){
    int N;
    cin >> N;

    set<tuple<int,int,int>> ans;
    for(int x = 1; x <= N; ++x){
        for(int y = 1; y*x <= N; y++){
            int w = N - x*y;
            if(w < 0 || w % (x + y) != 0) continue;
            int z = w / (x + y);
            ans.insert({x, y, z});
            ans.insert({x, z, y});
            ans.insert({y, x, z});
            ans.insert({y, z, x});
            ans.insert({z, x, y});
            ans.insert({z, y, x});
        }
    }

    cout << ans.size() << endl;
    for(auto [x,y,z] : ans){
        cout << x << ' ' << y << ' ' << z << endl;
    }

    return 0;
}
0