結果
問題 |
No.1281 Cigarette Distribution
|
ユーザー |
|
提出日時 | 2025-02-07 23:58:38 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 224 ms / 2,000 ms |
コード長 | 1,328 bytes |
コンパイル時間 | 14,230 ms |
コンパイル使用メモリ | 174,688 KB |
実行使用メモリ | 198,508 KB |
最終ジャッジ日時 | 2025-02-07 23:59:07 |
合計ジャッジ時間 | 19,082 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (102 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
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 c = NList; var (n, m) = (c[0], c[1]); var mod = 1_000_000_007; var ans = new long[m]; ans[0] = n; for (var i = 1; i < m; ++i) { var d = (n + 1) / (i + 1); var dpc = (n + 1) % (i + 1); var dzc = i - dpc; if (dpc == 0) { ans[i] = Exp(d, dzc, mod) * (d - 1) % mod; } else { ans[i] = Exp(d + 1, dpc, mod) * Exp(d, dzc, mod) % mod * (d - 1) % mod; } } WriteLine(string.Join("\n", ans)); } static long Exp(long n, long p, int mod) { long _n = n % mod; var _p = p; var result = 1L; if ((_p & 1) == 1) result *= _n; while (_p > 0) { _n = _n * _n % mod; _p >>= 1; if ((_p & 1) == 1) result = result * _n % mod; } return result; } }