結果

問題 No.1312 Snake Eyes
ユーザー さかぽんさかぽん
提出日時 2020-12-15 11:26:03
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 554 bytes
コンパイル時間 737 ms
コンパイル使用メモリ 104,192 KB
実行使用メモリ 25,952 KB
最終ジャッジ日時 2024-05-07 18:15:51
合計ジャッジ時間 4,866 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
23,516 KB
testcase_01 AC 20 ms
25,436 KB
testcase_02 AC 21 ms
23,636 KB
testcase_03 AC 20 ms
24,116 KB
testcase_04 AC 20 ms
21,556 KB
testcase_05 AC 20 ms
23,988 KB
testcase_06 AC 20 ms
23,768 KB
testcase_07 AC 21 ms
23,984 KB
testcase_08 AC 20 ms
25,944 KB
testcase_09 AC 20 ms
23,772 KB
testcase_10 AC 21 ms
23,768 KB
testcase_11 AC 20 ms
23,644 KB
testcase_12 AC 19 ms
25,684 KB
testcase_13 AC 20 ms
23,508 KB
testcase_14 AC 20 ms
21,940 KB
testcase_15 AC 21 ms
23,724 KB
testcase_16 AC 20 ms
23,776 KB
testcase_17 AC 20 ms
24,024 KB
testcase_18 AC 20 ms
23,772 KB
testcase_19 AC 21 ms
23,896 KB
testcase_20 AC 21 ms
23,780 KB
testcase_21 AC 21 ms
25,808 KB
testcase_22 AC 19 ms
22,064 KB
testcase_23 AC 21 ms
23,732 KB
testcase_24 AC 21 ms
23,768 KB
testcase_25 AC 21 ms
23,644 KB
testcase_26 AC 20 ms
21,812 KB
testcase_27 AC 21 ms
23,644 KB
testcase_28 AC 21 ms
23,776 KB
testcase_29 AC 20 ms
21,940 KB
testcase_30 AC 20 ms
23,512 KB
testcase_31 AC 21 ms
23,776 KB
testcase_32 AC 21 ms
23,764 KB
testcase_33 AC 20 ms
23,852 KB
testcase_34 AC 19 ms
23,776 KB
testcase_35 AC 21 ms
23,912 KB
testcase_36 AC 20 ms
23,512 KB
testcase_37 AC 21 ms
23,784 KB
testcase_38 AC 22 ms
25,816 KB
testcase_39 AC 21 ms
23,776 KB
testcase_40 AC 22 ms
25,816 KB
testcase_41 AC 21 ms
23,648 KB
testcase_42 AC 21 ms
25,564 KB
testcase_43 AC 21 ms
22,068 KB
testcase_44 AC 21 ms
23,980 KB
testcase_45 AC 21 ms
23,644 KB
testcase_46 AC 21 ms
23,652 KB
testcase_47 AC 21 ms
23,644 KB
testcase_48 AC 50 ms
23,768 KB
testcase_49 AC 46 ms
23,772 KB
testcase_50 AC 41 ms
24,116 KB
testcase_51 AC 31 ms
23,520 KB
testcase_52 AC 51 ms
23,508 KB
testcase_53 AC 43 ms
23,768 KB
testcase_54 AC 48 ms
23,388 KB
testcase_55 AC 34 ms
23,524 KB
testcase_56 AC 39 ms
23,516 KB
testcase_57 AC 37 ms
23,984 KB
testcase_58 AC 43 ms
23,776 KB
testcase_59 AC 29 ms
25,568 KB
testcase_60 AC 37 ms
23,652 KB
testcase_61 AC 53 ms
25,560 KB
testcase_62 AC 33 ms
25,816 KB
testcase_63 AC 20 ms
23,392 KB
testcase_64 AC 20 ms
23,988 KB
testcase_65 AC 21 ms
25,952 KB
testcase_66 AC 21 ms
23,652 KB
testcase_67 AC 21 ms
23,516 KB
testcase_68 AC 20 ms
23,384 KB
testcase_69 AC 21 ms
25,680 KB
testcase_70 AC 21 ms
23,644 KB
testcase_71 AC 20 ms
23,648 KB
testcase_72 AC 19 ms
21,556 KB
testcase_73 AC 21 ms
23,644 KB
testcase_74 AC 20 ms
21,684 KB
testcase_75 AC 20 ms
23,652 KB
testcase_76 AC 53 ms
25,816 KB
testcase_77 AC 54 ms
25,692 KB
testcase_78 AC 53 ms
23,856 KB
testcase_79 AC 19 ms
21,680 KB
testcase_80 AC 51 ms
23,644 KB
testcase_81 AC 45 ms
23,644 KB
testcase_82 AC 21 ms
23,384 KB
testcase_83 AC 52 ms
23,640 KB
testcase_84 AC 54 ms
23,640 KB
testcase_85 AC 20 ms
23,640 KB
testcase_86 AC 19 ms
21,684 KB
testcase_87 AC 37 ms
23,644 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

class I
{
	static void Main() => Console.WriteLine(Solve());
	static object Solve()
	{
		var n = long.Parse(Console.ReadLine());
		if (n <= 2) return n + 1;

		var r = long.MaxValue;

		for (long p = 2; p * p <= n + 1; p++)
		{
			// 3桁以上
			for (long d = p * p; d <= n + 1; d *= p)
			{
				var q = (d * p - 1) / (p - 1);
				if (n % q == 0 && 0 < n / q && n / q < p) return p;
			}

			// 2桁
			if (n % p == 0)
			{
				var q = n / p - 1;
				if (p < q) r = Math.Min(r, q);
			}
		}
		return r == long.MaxValue ? n - 1 : r;
	}
}
0