結果

問題 No.2358 xy+yz+zx=N
ユーザー MAHAYANA
提出日時 2023-10-28 11:26:40
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 771 bytes
コンパイル時間 1,559 ms
コンパイル使用メモリ 176,088 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-25 16:16:52
合計ジャッジ時間 6,086 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 3 WA * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 = x; y <= N; y += x){
            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