結果

問題 No.1161 Many Powers
ユーザー umezoumezo
提出日時 2020-08-12 13:56:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 621 bytes
コンパイル時間 2,101 ms
コンパイル使用メモリ 195,620 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-18 00:28:32
合計ジャッジ時間 3,326 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
5,248 KB
testcase_01 AC 15 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 5 ms
5,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 52 ms
5,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 7 ms
5,376 KB
testcase_24 AC 7 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

ll MOD;

ll modpow(ll x,ll n){
  ll ans=1;
  while(n){
    if(n&1) ans=ans*x %MOD;
    x=x*x %MOD;
    n/=2;
  }
  return ans;
}

int main(){
  ll a,b,c,x,y;
  cin>>a>>b>>c;
  MOD=c;
  x=a/c;
  y=a%c;
  a%=c;
  b%=c;
  
  vector<ll> A(100010);
  for(int i=1;i<=100000;i++) A[i]=modpow(i,b);
  
  ll sum=0;
  for(int i=1;i<c;i++){
    if(i<=y) sum=(sum+modpow(i,b)*(x+1)%MOD)%MOD;
    else sum=(sum+modpow(i,b)*x%MOD)%MOD;
  }
  
  cout<<sum<<endl;
  
  return 0;
}
0