結果

問題 No.1498 Factorization from -1 to 1
ユーザー tko919tko919
提出日時 2021-05-04 11:29:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 368 ms / 3,000 ms
コード長 1,088 bytes
コンパイル時間 2,149 ms
コンパイル使用メモリ 207,436 KB
実行使用メモリ 28,356 KB
最終ジャッジ日時 2023-09-30 14:57:53
合計ジャッジ時間 7,943 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
28,060 KB
testcase_01 AC 103 ms
28,080 KB
testcase_02 AC 111 ms
28,096 KB
testcase_03 AC 272 ms
28,220 KB
testcase_04 AC 320 ms
28,356 KB
testcase_05 AC 368 ms
28,172 KB
testcase_06 AC 358 ms
28,112 KB
testcase_07 AC 368 ms
28,148 KB
testcase_08 AC 362 ms
28,164 KB
testcase_09 AC 357 ms
28,136 KB
testcase_10 AC 116 ms
28,140 KB
testcase_11 AC 113 ms
28,080 KB
testcase_12 AC 118 ms
28,084 KB
testcase_13 AC 108 ms
28,060 KB
testcase_14 AC 109 ms
28,088 KB
testcase_15 AC 106 ms
28,096 KB
testcase_16 AC 108 ms
28,160 KB
testcase_17 AC 119 ms
28,092 KB
testcase_18 AC 100 ms
28,084 KB
testcase_19 AC 107 ms
28,080 KB
testcase_20 AC 100 ms
28,084 KB
testcase_21 AC 111 ms
28,152 KB
testcase_22 AC 100 ms
28,080 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<ll,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<ll> 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