結果

問題 No.1498 Factorization from -1 to 1
ユーザー monnumonnu
提出日時 2021-05-07 23:48:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 815 bytes
コンパイル時間 1,763 ms
コンパイル使用メモリ 167,640 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2023-10-13 15:08:23
合計ジャッジ時間 7,857 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 3 ms
4,352 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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';
  }
}
0