結果
| 問題 |
No.2452 Incline
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-09-01 22:22:00 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,172 bytes |
| コンパイル時間 | 2,461 ms |
| コンパイル使用メモリ | 107,776 KB |
| 実行使用メモリ | 27,904 KB |
| 最終ジャッジ日時 | 2025-01-03 09:21:32 |
| 合計ジャッジ時間 | 5,643 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 5 WA * 3 |
コンパイルメッセージ
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()
{
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;
}
}