結果
| 問題 | No.1498 Factorization from -1 to 1 |
| ユーザー |
monnu
|
| 提出日時 | 2021-05-07 23:48:27 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2,941 ms / 3,000 ms |
| コード長 | 815 bytes |
| 記録 | |
| コンパイル時間 | 1,237 ms |
| コンパイル使用メモリ | 184,132 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-04 19:35:41 |
| 合計ジャッジ時間 | 12,054 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll=long long;
using Graph=vector<vector<pair<int,ll>>>;
#define MAX 100001
#define INF 1000000000000000000
#define MOD 1000000007
vector<int> p;
vector<bool> p_table(MAX+1,true);
void prime(){
p_table.at(0)=false,p_table.at(1)=false;
for(int i=2;i<=MAX;i++){
if(p_table.at(i)){
p.push_back(i);
for(int j=2;i*j<=MAX;j++){
p_table.at(i*j)=false;
}
}
}
}
int main(){
prime();
int n=p.size();
int Q;
cin>>Q;
for(int i=0;i<Q;i++){
ll q;
cin>>q;
q=q*q+1;
int j=0;
while(j<n&&j*j<=q){
while(q%(ll)p[j]==0){
cout<<p[j]<<" ";
q/=(ll)p[j];
}
j++;
}
if(q>1){
cout<<q<<" ";
}
cout<<'\n';
}
}
monnu