結果

問題 No.1312 Snake Eyes
ユーザー さかぽんさかぽん
提出日時 2020-12-15 11:26:03
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 554 bytes
コンパイル時間 3,436 ms
コンパイル使用メモリ 102,632 KB
実行使用メモリ 22,908 KB
最終ジャッジ日時 2023-08-20 11:26:20
合計ジャッジ時間 12,767 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
20,728 KB
testcase_01 AC 57 ms
22,756 KB
testcase_02 AC 57 ms
20,728 KB
testcase_03 AC 59 ms
20,772 KB
testcase_04 AC 60 ms
22,712 KB
testcase_05 AC 58 ms
20,668 KB
testcase_06 AC 57 ms
22,640 KB
testcase_07 AC 60 ms
20,752 KB
testcase_08 AC 59 ms
20,692 KB
testcase_09 AC 57 ms
20,740 KB
testcase_10 AC 57 ms
20,700 KB
testcase_11 AC 56 ms
20,612 KB
testcase_12 AC 57 ms
20,816 KB
testcase_13 AC 57 ms
22,724 KB
testcase_14 AC 56 ms
20,824 KB
testcase_15 AC 57 ms
20,688 KB
testcase_16 AC 57 ms
20,756 KB
testcase_17 AC 57 ms
22,820 KB
testcase_18 AC 58 ms
20,860 KB
testcase_19 AC 57 ms
20,760 KB
testcase_20 AC 58 ms
22,828 KB
testcase_21 AC 59 ms
22,908 KB
testcase_22 AC 57 ms
20,764 KB
testcase_23 AC 58 ms
20,676 KB
testcase_24 AC 58 ms
20,668 KB
testcase_25 AC 56 ms
20,680 KB
testcase_26 AC 58 ms
20,704 KB
testcase_27 AC 57 ms
22,668 KB
testcase_28 AC 57 ms
22,752 KB
testcase_29 AC 59 ms
22,728 KB
testcase_30 AC 57 ms
20,680 KB
testcase_31 AC 57 ms
20,744 KB
testcase_32 AC 59 ms
18,624 KB
testcase_33 AC 60 ms
20,748 KB
testcase_34 AC 60 ms
20,728 KB
testcase_35 AC 59 ms
20,692 KB
testcase_36 AC 60 ms
22,868 KB
testcase_37 AC 60 ms
22,724 KB
testcase_38 AC 60 ms
22,720 KB
testcase_39 AC 60 ms
22,696 KB
testcase_40 AC 60 ms
20,668 KB
testcase_41 AC 58 ms
20,664 KB
testcase_42 AC 57 ms
20,672 KB
testcase_43 AC 59 ms
22,660 KB
testcase_44 AC 58 ms
20,740 KB
testcase_45 AC 60 ms
20,776 KB
testcase_46 AC 58 ms
20,668 KB
testcase_47 AC 58 ms
20,664 KB
testcase_48 AC 90 ms
20,680 KB
testcase_49 AC 86 ms
20,672 KB
testcase_50 AC 80 ms
22,780 KB
testcase_51 AC 69 ms
20,616 KB
testcase_52 AC 95 ms
22,768 KB
testcase_53 AC 84 ms
20,788 KB
testcase_54 AC 90 ms
22,708 KB
testcase_55 AC 72 ms
20,696 KB
testcase_56 AC 77 ms
22,772 KB
testcase_57 AC 78 ms
20,600 KB
testcase_58 AC 85 ms
22,660 KB
testcase_59 AC 68 ms
20,700 KB
testcase_60 AC 78 ms
20,660 KB
testcase_61 AC 92 ms
20,668 KB
testcase_62 AC 70 ms
22,704 KB
testcase_63 AC 57 ms
22,672 KB
testcase_64 AC 58 ms
20,744 KB
testcase_65 AC 58 ms
22,760 KB
testcase_66 AC 57 ms
20,700 KB
testcase_67 AC 59 ms
20,788 KB
testcase_68 AC 56 ms
20,824 KB
testcase_69 AC 56 ms
18,628 KB
testcase_70 AC 56 ms
20,688 KB
testcase_71 AC 57 ms
22,660 KB
testcase_72 AC 57 ms
20,660 KB
testcase_73 AC 57 ms
22,764 KB
testcase_74 AC 58 ms
20,624 KB
testcase_75 AC 56 ms
20,828 KB
testcase_76 AC 93 ms
22,716 KB
testcase_77 AC 94 ms
22,768 KB
testcase_78 AC 94 ms
22,788 KB
testcase_79 AC 57 ms
22,816 KB
testcase_80 AC 91 ms
18,552 KB
testcase_81 AC 82 ms
20,772 KB
testcase_82 AC 58 ms
22,728 KB
testcase_83 AC 93 ms
20,736 KB
testcase_84 AC 93 ms
22,716 KB
testcase_85 AC 57 ms
20,796 KB
testcase_86 AC 56 ms
22,664 KB
testcase_87 AC 74 ms
20,696 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