結果

問題 No.2452 Incline
ユーザー 👑 kakel-sankakel-san
提出日時 2023-09-01 22:22:00
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,172 bytes
コンパイル時間 2,536 ms
コンパイル使用メモリ 106,496 KB
実行使用メモリ 27,392 KB
最終ジャッジ日時 2024-06-11 04:14:07
合計ジャッジ時間 5,866 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
19,456 KB
testcase_01 AC 23 ms
18,944 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 264 ms
27,264 KB
testcase_05 AC 249 ms
27,392 KB
testcase_06 WA -
testcase_07 AC 243 ms
27,392 KB
testcase_08 AC 225 ms
27,136 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 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()
    {
        var t = NN;
        var ans = new long[t];
        for (var u = 0; u < t; ++u)
        {
            var c = NList;
            var (n, m, l, r) = ((int)c[0], c[1], c[2], c[3]);
            ans[u] = Incline(n, m, l, r);
        }
        WriteLine(string.Join("\n", ans));
    }
    static readonly int mod = 998_244_353;
    static long Incline(int n, long m, long l, long r)
    {
        var ans = F(n, m, r);
        if (l > 0) ans = (ans + mod - F(n, m, l - 1)) % mod;
        return ans;
    }
    static long F(int n, long m, long r)
    {
        return (m / (n - 1) % mod * (r % mod + 1) % mod + G(n, m, r)) % mod;
    }
    static long G(int n, long m, long r)
    {
        return ((r ) / (n - 1) % mod * (m % (n - 1) + 1) % mod + Math.Min(r % (n - 1), m % (n - 1)) % mod + 1) % mod;
    }
}
0