結果

問題 No.1498 Factorization from -1 to 1
ユーザー 👑 kmjpkmjp
提出日時 2021-05-04 00:33:26
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 227 ms / 3,000 ms
コード長 1,313 bytes
コンパイル時間 2,552 ms
コンパイル使用メモリ 206,344 KB
実行使用メモリ 12,908 KB
最終ジャッジ日時 2023-09-30 14:55:59
合計ジャッジ時間 5,922 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
12,652 KB
testcase_01 AC 38 ms
12,588 KB
testcase_02 AC 37 ms
12,876 KB
testcase_03 AC 180 ms
12,600 KB
testcase_04 AC 205 ms
12,612 KB
testcase_05 AC 219 ms
12,608 KB
testcase_06 AC 219 ms
12,596 KB
testcase_07 AC 219 ms
12,660 KB
testcase_08 AC 222 ms
12,908 KB
testcase_09 AC 227 ms
12,656 KB
testcase_10 AC 42 ms
12,576 KB
testcase_11 AC 42 ms
12,688 KB
testcase_12 AC 42 ms
12,596 KB
testcase_13 AC 42 ms
12,656 KB
testcase_14 AC 41 ms
12,732 KB
testcase_15 AC 38 ms
12,588 KB
testcase_16 AC 38 ms
12,604 KB
testcase_17 AC 39 ms
12,692 KB
testcase_18 AC 39 ms
12,588 KB
testcase_19 AC 38 ms
12,596 KB
testcase_20 AC 39 ms
12,664 KB
testcase_21 AC 41 ms
12,604 KB
testcase_22 AC 41 ms
12,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

ll X[1010101];
vector<ll> V[101010];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	for(i=1;i<=100001;i++) X[i]=1LL*i*i+1;
	for(i=1;i<=100001;i++) if(X[i]>1) {
		ll p=X[i];
		
		for(ll x=i;x<=100001;x+=p) {
			while(X[x]%p==0) X[x]/=p, V[x].push_back(p);
		}
		for(ll x=p-i;x<=100001;x+=p) {
			while(X[x]%p==0) X[x]/=p, V[x].push_back(p);
		}
	}
	
	int Q;
	cin>>Q;
	while(Q--) {
		cin>>x;
		sort(ALL(V[x]));
		FOR(i,V[x].size()) {
			cout<<V[x][i];
			if(i<V[x].size()-1) cout<<" ";
		}
		cout<<endl;
	}
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0