結果

問題 No.1966 Median of Divisors
ユーザー MasKoaTSMasKoaTS
提出日時 2022-01-17 18:53:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 251 ms / 2,000 ms
コード長 563 bytes
コンパイル時間 5,062 ms
コンパイル使用メモリ 260,680 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-18 06:36:36
合計ジャッジ時間 6,616 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 4 ms
4,376 KB
testcase_04 AC 209 ms
4,380 KB
testcase_05 AC 248 ms
4,376 KB
testcase_06 AC 251 ms
4,380 KB
testcase_07 AC 26 ms
4,380 KB
testcase_08 AC 153 ms
4,376 KB
testcase_09 AC 201 ms
4,376 KB
testcase_10 AC 202 ms
4,376 KB
testcase_11 AC 91 ms
4,380 KB
testcase_12 AC 121 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mint = modint1000000007;
using ll = long long;
#define rep(i, l, n) for (int i = (l); i < (n); i++)

int main(void) {
	int t;	cin >> t;
	mint two = 2;	mint rev2 = two.inv();
	mint six = 6;	mint rev6 = six.inv();

	rep(i, 0, t) {
		ll n, m;	cin >> n >> m;
		mint N = (mint)n;

		mint a = N.pow(m);	mint b = N.pow(m / 2);
		mint s = rev2 * a * (a + 1);
		mint t = rev6 * b * (b + 1) * (b * 2 + 1);

		mint ans = s - t;
		cout << ans.val() << endl;
	}

	return 0;
}
0