結果

問題 No.2177 Recurring ab
ユーザー 👑 kakel-sankakel-san
提出日時 2023-09-04 21:45:36
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 1,266 bytes
コンパイル時間 1,010 ms
コンパイル使用メモリ 68,332 KB
実行使用メモリ 22,892 KB
最終ジャッジ日時 2023-09-04 21:45:40
合計ジャッジ時間 3,108 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
20,740 KB
testcase_01 AC 52 ms
22,760 KB
testcase_02 AC 54 ms
22,852 KB
testcase_03 AC 53 ms
22,712 KB
testcase_04 AC 54 ms
20,776 KB
testcase_05 AC 55 ms
22,696 KB
testcase_06 AC 55 ms
22,884 KB
testcase_07 AC 54 ms
22,832 KB
testcase_08 AC 53 ms
20,768 KB
testcase_09 AC 54 ms
20,780 KB
testcase_10 AC 53 ms
20,756 KB
testcase_11 AC 53 ms
20,736 KB
testcase_12 AC 53 ms
20,760 KB
testcase_13 AC 53 ms
22,732 KB
testcase_14 AC 54 ms
22,812 KB
testcase_15 AC 53 ms
22,788 KB
testcase_16 AC 53 ms
20,792 KB
testcase_17 AC 53 ms
20,772 KB
testcase_18 AC 54 ms
20,788 KB
testcase_19 AC 54 ms
20,712 KB
testcase_20 AC 54 ms
22,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static int NN => int.Parse(ReadLine());
    static long[] NList => ReadLine().Split().Select(long.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        long n = NN;
        WriteLine(Recur(n));
    }
    static long Recur(long n)
    {
        var ans = 0L;
        for (var p = 2; p <= 20; ++p) for (var a = 0; a < p && a < 10; ++a) for (var b = 0; b < p && b < 10; ++b)
        {
            if (a == b) continue;
            if ((a * p + b) < p * p - 1 && n * (a * p + b) > p * p - 1)
            {
                ++ans;
            }
        }
        for (var a = 0; a < 10; ++a) for (var b = 0; b < 10; ++b)
        {
            if (a == b) continue;
            if (n * (a * 21 + b) <= 21 * 21 - 1) continue;
            var ok = 21L;
            var ng = 1_000_000_001L;
            while (ng - ok > 1)
            {
                var mid = (ok + ng) / 2;
                if (n * (a * mid + b) > mid * mid - 1) ok = mid;
                else ng = mid;
            }
            ans += ok - 20;
        }
        return ans;
    }
}
0