結果

問題 No.1312 Snake Eyes
ユーザー さかぽんさかぽん
提出日時 2020-12-15 11:21:03
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 560 bytes
コンパイル時間 1,539 ms
コンパイル使用メモリ 109,496 KB
実行使用メモリ 23,796 KB
最終ジャッジ日時 2023-10-20 05:53:53
合計ジャッジ時間 5,575 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
23,796 KB
testcase_01 AC 23 ms
23,796 KB
testcase_02 AC 23 ms
23,796 KB
testcase_03 AC 23 ms
23,796 KB
testcase_04 AC 23 ms
23,796 KB
testcase_05 AC 23 ms
23,796 KB
testcase_06 AC 22 ms
23,796 KB
testcase_07 AC 23 ms
23,796 KB
testcase_08 AC 23 ms
23,796 KB
testcase_09 AC 24 ms
23,796 KB
testcase_10 AC 23 ms
23,796 KB
testcase_11 AC 23 ms
23,796 KB
testcase_12 AC 22 ms
23,796 KB
testcase_13 AC 23 ms
23,796 KB
testcase_14 AC 23 ms
23,796 KB
testcase_15 AC 22 ms
23,796 KB
testcase_16 AC 23 ms
23,796 KB
testcase_17 AC 23 ms
23,796 KB
testcase_18 AC 23 ms
23,796 KB
testcase_19 AC 23 ms
23,796 KB
testcase_20 AC 22 ms
23,796 KB
testcase_21 AC 23 ms
23,796 KB
testcase_22 AC 23 ms
23,796 KB
testcase_23 AC 23 ms
23,796 KB
testcase_24 AC 23 ms
23,796 KB
testcase_25 AC 23 ms
23,796 KB
testcase_26 AC 25 ms
23,796 KB
testcase_27 AC 23 ms
23,796 KB
testcase_28 AC 23 ms
23,796 KB
testcase_29 AC 23 ms
23,796 KB
testcase_30 AC 23 ms
23,796 KB
testcase_31 AC 22 ms
23,796 KB
testcase_32 AC 22 ms
23,796 KB
testcase_33 AC 22 ms
23,796 KB
testcase_34 AC 23 ms
23,796 KB
testcase_35 AC 23 ms
23,796 KB
testcase_36 AC 24 ms
23,796 KB
testcase_37 AC 24 ms
23,796 KB
testcase_38 AC 24 ms
23,796 KB
testcase_39 AC 24 ms
23,796 KB
testcase_40 AC 24 ms
23,796 KB
testcase_41 AC 24 ms
23,796 KB
testcase_42 AC 24 ms
23,796 KB
testcase_43 AC 24 ms
23,796 KB
testcase_44 AC 23 ms
23,796 KB
testcase_45 AC 23 ms
23,796 KB
testcase_46 AC 24 ms
23,796 KB
testcase_47 AC 23 ms
23,796 KB
testcase_48 RE -
testcase_49 RE -
testcase_50 RE -
testcase_51 RE -
testcase_52 RE -
testcase_53 RE -
testcase_54 RE -
testcase_55 RE -
testcase_56 RE -
testcase_57 RE -
testcase_58 RE -
testcase_59 RE -
testcase_60 RE -
testcase_61 RE -
testcase_62 RE -
testcase_63 AC 23 ms
23,796 KB
testcase_64 AC 23 ms
23,796 KB
testcase_65 AC 23 ms
23,796 KB
testcase_66 AC 23 ms
23,796 KB
testcase_67 AC 23 ms
23,796 KB
testcase_68 AC 23 ms
23,796 KB
testcase_69 AC 22 ms
23,796 KB
testcase_70 AC 23 ms
23,796 KB
testcase_71 AC 23 ms
23,796 KB
testcase_72 AC 23 ms
23,796 KB
testcase_73 AC 24 ms
23,796 KB
testcase_74 AC 23 ms
23,796 KB
testcase_75 AC 24 ms
23,796 KB
testcase_76 RE -
testcase_77 RE -
testcase_78 RE -
testcase_79 AC 22 ms
23,796 KB
testcase_80 RE -
testcase_81 RE -
testcase_82 RE -
testcase_83 RE -
testcase_84 RE -
testcase_85 AC 24 ms
23,796 KB
testcase_86 AC 22 ms
23,796 KB
testcase_87 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 * p; d <= p * (n + 1); d *= p)
			{
				var q = (d - 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