結果

問題 No.1498 Factorization from -1 to 1
ユーザー kotatsugamekotatsugame
提出日時 2021-05-04 13:12:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 567 bytes
コンパイル時間 656 ms
コンパイル使用メモリ 69,084 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-30 14:57:44
合計ジャッジ時間 5,340 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,760 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 3 ms
4,376 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 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
		if(i%4!=3)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