結果

問題 No.1966 Median of Divisors
ユーザー 沙耶花沙耶花
提出日時 2022-06-03 21:37:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 263 ms / 2,000 ms
コード長 533 bytes
コンパイル時間 3,833 ms
コンパイル使用メモリ 261,516 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 01:41:20
合計ジャッジ時間 6,526 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 3 ms
4,348 KB
testcase_03 AC 4 ms
4,348 KB
testcase_04 AC 219 ms
4,348 KB
testcase_05 AC 253 ms
4,348 KB
testcase_06 AC 263 ms
4,348 KB
testcase_07 AC 27 ms
4,348 KB
testcase_08 AC 161 ms
4,348 KB
testcase_09 AC 217 ms
4,348 KB
testcase_10 AC 216 ms
4,348 KB
testcase_11 AC 94 ms
4,348 KB
testcase_12 AC 121 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

mint get(mint n){
	return n * (n+1) / 2;
}

mint get2(mint n){
	mint r = n;
	r *= n+1;
	r *= 2*n+1;
	r /= 6;
	return r;
	
}

int main() {
	
	int _t;
	cin>>_t;
	
	rep(_,_t){
		long long n,m;
		cin>>n>>m;
		
		mint t = mint(n).pow(m);
		mint ans = get(t);
		ans -= get2(mint(n).pow(m/2));
		cout<<ans.val()<<endl;
	}
	
}
0