結果

問題 No.1498 Factorization from -1 to 1
ユーザー uwiuwi
提出日時 2021-05-04 15:10:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 947 ms / 3,000 ms
コード長 1,257 bytes
コンパイル時間 3,867 ms
コンパイル使用メモリ 85,760 KB
実行使用メモリ 82,708 KB
最終ジャッジ日時 2023-09-30 16:48:59
合計ジャッジ時間 17,656 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 305 ms
67,320 KB
testcase_01 AC 305 ms
67,524 KB
testcase_02 AC 308 ms
67,008 KB
testcase_03 AC 777 ms
79,468 KB
testcase_04 AC 863 ms
78,680 KB
testcase_05 AC 947 ms
82,708 KB
testcase_06 AC 925 ms
82,232 KB
testcase_07 AC 934 ms
82,460 KB
testcase_08 AC 936 ms
81,884 KB
testcase_09 AC 947 ms
82,144 KB
testcase_10 AC 400 ms
67,996 KB
testcase_11 AC 404 ms
68,200 KB
testcase_12 AC 397 ms
68,264 KB
testcase_13 AC 391 ms
68,064 KB
testcase_14 AC 415 ms
68,104 KB
testcase_15 AC 312 ms
67,092 KB
testcase_16 AC 311 ms
67,376 KB
testcase_17 AC 288 ms
67,356 KB
testcase_18 AC 309 ms
67,636 KB
testcase_19 AC 318 ms
67,804 KB
testcase_20 AC 325 ms
67,884 KB
testcase_21 AC 302 ms
66,856 KB
testcase_22 AC 304 ms
67,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package extra;
import java.io.PrintWriter;
import java.util.*;

public class P1498 {
	static Scanner in;
	static PrintWriter out;
	static String INPUT = "";
	
	static void solve()
	{
		final int n = 100002;
		List<List<Long>> lists = new ArrayList<>();
		for(int i = 0;i < n;i++)lists.add(new ArrayList<>());

		long[] val = new long[n];
		for(int i = 1;i < n;i++){
			val[i] = (long)i*i+1;
		}
		for(int i = 1;i < n;i++){
			if(val[i] == 1)continue;
			long p = val[i];
			for(long j = i;j < n;j+=p){
				int jj = (int)j;
				while(val[jj] % p == 0){
					val[jj] /= p;
					lists.get(jj).add(p);
				}
			}
		}
		for(int Q = ni();Q > 0;Q--){
			List<Long> f = lists.get(ni());
			Collections.sort(f);
			for(long v : f){
				out.print(v + " ");
			}
			out.println();
		}
	}
	
	public static void main(String[] args) throws Exception
	{
		in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);
		
		solve();
		out.flush();
	}
	
	static int ni() { return Integer.parseInt(in.next()); }
	static long nl() { return Long.parseLong(in.next()); }
	static double nd() { return Double.parseDouble(in.next()); }
	static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }
}
0