結果
| 問題 | No.2177 Recurring ab | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-09-04 21:45:36 | 
| 言語 | C#(csc) (csc 3.9.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 25 ms / 2,000 ms | 
| コード長 | 1,266 bytes | 
| コンパイル時間 | 857 ms | 
| コンパイル使用メモリ | 111,536 KB | 
| 実行使用メモリ | 25,932 KB | 
| 最終ジャッジ日時 | 2024-06-22 19:13:21 | 
| 合計ジャッジ時間 | 2,148 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 18 | 
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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;
    }
}
            
            
            
        