結果

問題 No.1498 Factorization from -1 to 1
ユーザー tko919tko919
提出日時 2021-05-04 11:27:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,090 bytes
コンパイル時間 2,165 ms
コンパイル使用メモリ 208,296 KB
実行使用メモリ 23,652 KB
最終ジャッジ日時 2023-09-30 07:50:32
合計ジャッジ時間 9,100 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
23,336 KB
testcase_01 AC 106 ms
23,288 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 105 ms
23,332 KB
testcase_11 AC 110 ms
23,328 KB
testcase_12 AC 107 ms
23,284 KB
testcase_13 AC 112 ms
23,348 KB
testcase_14 AC 112 ms
23,280 KB
testcase_15 AC 104 ms
23,280 KB
testcase_16 AC 104 ms
23,280 KB
testcase_17 WA -
testcase_18 AC 103 ms
23,284 KB
testcase_19 AC 104 ms
23,316 KB
testcase_20 AC 104 ms
23,524 KB
testcase_21 AC 106 ms
23,344 KB
testcase_22 AC 109 ms
23,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
using ll=long long int;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

const int L=101010;
ll a[L];
map<int,int> ds[L];

int main(){
   rep(x,1,L)a[x]=1LL*x*x+1;
   rep(x,1,L)if(a[x]!=1){
      ll p=a[x];
      for(ll y=x;y<L;y+=p){
         while(a[y]%p==0){
            a[y]/=p;
            ds[y][p]++;
         }
      }
      for(ll y=p-x;y<L;y+=p){
         while(a[y]%p==0){
            a[y]/=p;
            ds[y][p]++;
         }
      }
   }
   
   int q;
   cin>>q;
   while(q--){
      int x;
      cin>>x;
      vector<int> res;
      for(auto& [p,c]:ds[x]){
         rep(_,0,c)res.push_back(p);
      }
      rep(i,0,res.size())cout<<res[i]<<(i==(int)res.size()-1?'\n':' ');
   }
   return 0;
}
0