結果

問題 No.1498 Factorization from -1 to 1
ユーザー kotatsugamekotatsugame
提出日時 2021-05-04 13:07:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 650 bytes
コンパイル時間 637 ms
コンパイル使用メモリ 70,604 KB
実行使用メモリ 8,756 KB
最終ジャッジ日時 2023-09-30 14:27:07
合計ジャッジ時間 18,370 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 TLE -
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 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;
const int LIM=100001;
bool isp[LIM+1];
vector<int>ps;
main()
{
	for(int i=2;i<=LIM;i++)if(!isp[i])
	{
		for(int j=i+i;j<=LIM;j+=i)isp[j]=true;
		bool fn=false;
		for(long k=0;k<i;k++)if((k*k+1)%i==0)
		{
			fn=true;
			break;
		}
		if(fn)ps.push_back(i);
	}
	int Q;
	cin>>Q;
	for(;Q--;)
	{
		long X;cin>>X;X=X*X+1;
		bool fst=true;
		for(int p:ps)
		{
			if((long)p*p>X)break;
			if(X%p==0)
			{
				while(X%p==0)
				{
					if(fst)fst=false;
					else cout<<' ';
					cout<<p;
					X/=p;
				}
			}
		}
		if(X>1)
		{
			if(fst)fst=false;
			else cout<<' ';
			cout<<X;
		}
		cout<<'\n';
	}
}
0