結果

問題 No.1252 数字根D
ユーザー keymoonkeymoon
提出日時 2021-01-18 12:08:59
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 892 bytes
コンパイル時間 3,302 ms
コンパイル使用メモリ 104,336 KB
実行使用メモリ 23,692 KB
最終ジャッジ日時 2023-08-20 19:34:37
合計ジャッジ時間 4,318 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
21,720 KB
testcase_01 AC 61 ms
21,584 KB
testcase_02 AC 62 ms
21,676 KB
testcase_03 AC 67 ms
19,592 KB
testcase_04 AC 73 ms
19,724 KB
testcase_05 AC 74 ms
21,516 KB
testcase_06 AC 74 ms
23,568 KB
testcase_07 AC 74 ms
21,612 KB
testcase_08 AC 74 ms
23,692 KB
testcase_09 AC 74 ms
21,664 KB
testcase_10 AC 72 ms
21,660 KB
testcase_11 AC 73 ms
19,720 KB
testcase_12 AC 73 ms
21,564 KB
testcase_13 AC 73 ms
21,544 KB
testcase_14 AC 60 ms
21,520 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int t = int.Parse(Console.ReadLine());
        for (int i = 0; i < t; i++) Solve();
    }
    static void Solve()
    {
        var dab = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var d = dab[0];
        long a = dab[1];
        long b = dab[2];
        Console.WriteLine(Solve(d, b) - Solve(d, a - 1));
    }
    static long Solve(long d, long a)
    {
        if (a <= 0) return 0;
        long loop = a / (d - 1);
        long remain = a % (d - 1);
        return (d * (d - 1) / 2) * loop + (remain * (remain + 1)) / 2;
    }
}
0