結果

問題 No.2358 xy+yz+zx=N
ユーザー twooimptwooimp
提出日時 2023-06-23 21:58:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 1,055 bytes
コンパイル時間 1,734 ms
コンパイル使用メモリ 174,480 KB
実行使用メモリ 5,880 KB
最終ジャッジ日時 2023-09-14 10:07:02
合計ジャッジ時間 3,295 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 5 ms
4,376 KB
testcase_08 AC 123 ms
5,620 KB
testcase_09 AC 130 ms
5,880 KB
testcase_10 AC 80 ms
4,376 KB
testcase_11 AC 89 ms
4,668 KB
testcase_12 AC 55 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using T=tuple<ll,ll,ll>;

int main(){
  ll n;
  cin>>n;
  set<T> ans;
  for(ll z=0;z*z<=n;z++){
    for(ll y=0;y<=z;y++){
      if(y==0&&z==0){
        continue;
      }
      if((n-y*z)%(y+z)==0){
        ll x=(n-y*z)/(y+z);
        if(x*y+y*z+z*x==n){
          if(x==y&&y==z){
            ans.insert(T(x,y,z));
          }else if(x==y){
            ans.insert(T(x,y,z));
            ans.insert(T(x,z,y));
            ans.insert(T(z,x,y));
          }else if(y==z){
            ans.insert(T(x,y,z));
            ans.insert(T(y,x,z));
            ans.insert(T(y,z,x));
          }else{
            ans.insert(T(x,y,z));
            ans.insert(T(x,z,y));
            ans.insert(T(y,x,z));
            ans.insert(T(y,z,x));
            ans.insert(T(z,x,y));
            ans.insert(T(z,y,x));
          }
        }
      }
    }
  }
  cout<<ans.size()<<endl;
  auto itr=ans.begin();
  while(itr!=ans.end()){
    cout<<get<0>(*itr)<<" "<<get<1>(*itr)<<" "<<get<2>(*itr)<<endl;
    itr++;
  }
}
0