結果

問題 No.2358 xy+yz+zx=N
ユーザー nononnonon
提出日時 2023-07-13 20:24:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 876 bytes
コンパイル時間 2,019 ms
コンパイル使用メモリ 206,600 KB
実行使用メモリ 5,744 KB
最終ジャッジ日時 2023-10-13 09:22:46
合計ジャッジ時間 4,295 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,356 KB
testcase_07 AC 4 ms
4,348 KB
testcase_08 AC 81 ms
5,640 KB
testcase_09 AC 86 ms
5,744 KB
testcase_10 AC 43 ms
4,352 KB
testcase_11 AC 50 ms
4,532 KB
testcase_12 AC 27 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin>>N;
    set<pair<int,pair<int,int>>> ans;
    for(int x=0; x*x<=N; x++){
        for(int y=x; y*y<=N; y++){
            if(x+y>0 && (N-x*y)%(x+y)==0){
                int z=(N-x*y)/(x+y);
                if(y<=z){
                    ans.insert(make_pair(x,make_pair(y,z)));
                    ans.insert(make_pair(x,make_pair(z,y)));
                    ans.insert(make_pair(y,make_pair(x,z)));
                    ans.insert(make_pair(y,make_pair(z,x)));
                    ans.insert(make_pair(z,make_pair(x,y)));
                    ans.insert(make_pair(z,make_pair(y,x)));
                }
            }
        }
    }
    cout << ans.size() << endl;
    for(auto _ans:ans){
        cout << _ans.first << " " << _ans.second.first << " " << _ans.second.second << endl;
    }
    return 0;
}
0