結果

問題 No.1498 Factorization from -1 to 1
ユーザー uwiuwi
提出日時 2021-05-04 15:09:43
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,315 bytes
コンパイル時間 3,569 ms
コンパイル使用メモリ 83,332 KB
実行使用メモリ 82,656 KB
最終ジャッジ日時 2023-09-30 16:48:20
合計ジャッジ時間 16,029 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 286 ms
67,516 KB
testcase_01 AC 298 ms
67,556 KB
testcase_02 AC 319 ms
67,612 KB
testcase_03 AC 714 ms
77,912 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 293 ms
67,304 KB
testcase_16 AC 287 ms
67,888 KB
testcase_17 AC 307 ms
67,408 KB
testcase_18 AC 288 ms
67,584 KB
testcase_19 AC 314 ms
67,260 KB
testcase_20 AC 309 ms
67,204 KB
testcase_21 AC 294 ms
67,284 KB
testcase_22 AC 286 ms
67,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package extra;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

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());
			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