結果

問題 No.1164 GCD Products hard
ユーザー 蜜蜂蜜蜂
提出日時 2020-08-11 20:35:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,079 bytes
コンパイル時間 1,300 ms
コンパイル使用メモリ 165,484 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-17 17:35:05
合計ジャッジ時間 45,527 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
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 TLE -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 TLE -
testcase_22 AC 1 ms
6,944 KB
testcase_23 TLE -
testcase_24 TLE -
testcase_25 AC 1 ms
6,944 KB
testcase_26 WA -
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;

bool isprime(int num){
  if(num<2) return false;
  else if(num==2) return true;
  else if(num%2==0) return false;
  double sqrtNum=sqrt(num);
  for(int i=3;i<=sqrtNum;i+=2){
    if(num%i==0){
      return false;
    }
  }
  return true;
}
ll mpower(ll a,ll b,ll c){
  int z;
  if(b==0){
    z=1;
    z%=c;
    return z;
  }
  if(b==1){
    z=a;
    z%=c;
    return z;
  }
  else{
    return (((mpower(a,b/2,c))*(mpower(a,b/2,c))%c)*mpower(a,b%2,c)%c);
  }
}

int main(){
    ll a,b,n;
    cin>>a>>b>>n;
    ll ans=1,mod=1e9+7;
    for(int i=2;i<=b;i++){
        if(isprime(i)!=true){
            continue;
        }
        ll z=1,check=0,sum=0;
        while(z<=b){
            z*=i;
            check++;
        }
        z/=i;
        while(z>1){
          sum+=mpower(b/z-(a-1)/z,n,mod);
          sum%=mod;
          z/=i;
        }
        ans*=mpower(i,sum,mod);
        ans%=mod;
    }
    cout<<ans<<endl;
}
0