結果
| 問題 |
No.1498 Factorization from -1 to 1
|
| ユーザー |
tko919
|
| 提出日時 | 2021-05-04 11:29:41 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 360 ms / 3,000 ms |
| コード長 | 1,088 bytes |
| コンパイル時間 | 2,061 ms |
| コンパイル使用メモリ | 202,032 KB |
| 最終ジャッジ日時 | 2025-01-21 06:41:13 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 17 |
ソースコード
#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;
}
tko919