結果

問題 No.1966 Median of Divisors
ユーザー polyesterpolyester
提出日時 2022-06-03 22:33:06
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 226 ms / 2,000 ms
コード長 883 bytes
コンパイル時間 4,108 ms
コンパイル使用メモリ 132,124 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 02:06:20
合計ジャッジ時間 6,667 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 3 ms
4,348 KB
testcase_03 AC 3 ms
4,348 KB
testcase_04 AC 200 ms
4,348 KB
testcase_05 AC 226 ms
4,348 KB
testcase_06 AC 222 ms
4,348 KB
testcase_07 AC 24 ms
4,348 KB
testcase_08 AC 134 ms
4,348 KB
testcase_09 AC 183 ms
4,348 KB
testcase_10 AC 187 ms
4,348 KB
testcase_11 AC 83 ms
4,348 KB
testcase_12 AC 110 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
ll modpow(ll x, ll n) {
  ll ans = 1;
  while(n > 0) {
    if(n % 2 == 1) {
      ans *= x;
      ans %= MOD;
    }
    x *= x;
    x %= MOD;
    n >>= 1;
  }
  return ans;
}
int main() {
  int t;
  cin >> t;
  while(t--) {
    ll n, m;
    cin >> n >> m;
    ll maxi = modpow(n, m);
    ll sum = maxi * (maxi + 1) % MOD * 500000004 % MOD;
    ll div = modpow(n, m / 2);
    cout << (sum -
             div % MOD * (div % MOD + 1) % MOD * (2 * div % MOD + 1) % MOD *
                 166666668 % MOD +
             MOD) %
                MOD
         << endl;
  }
  return 0;
}
0