結果
問題 | No.1966 Median of Divisors |
ユーザー |
![]() |
提出日時 | 2024-12-01 12:55:29 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 270 ms / 2,000 ms |
コード長 | 511 bytes |
コンパイル時間 | 2,117 ms |
コンパイル使用メモリ | 196,348 KB |
最終ジャッジ日時 | 2025-02-26 09:57:36 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 12 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/modint>using namespace std;using namespace atcoder;using mint = modint1000000007;const mint INV2 = ((mint)2).inv();const mint INV6 = ((mint)6).inv();int main(){int t; cin >> t;for(int i = 0; i < t; ++i){int n, m; cin >> n >> m;mint x = ((mint)n).pow(m);mint y = ((mint)n).pow(m / 2);mint ans = INV2 * x * (x + 1) - INV6 * y * (y + 1) * (2 * y + 1);cout << ans.val() << endl;}return 0;}