結果
| 問題 | No.1164 GCD Products hard |
| ユーザー |
tonegawa
|
| 提出日時 | 2020-08-15 11:44:11 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 666 bytes |
| 記録 | |
| コンパイル時間 | 821 ms |
| コンパイル使用メモリ | 70,000 KB |
| 最終ジャッジ日時 | 2025-01-13 01:17:49 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 15 TLE * 12 |
コンパイルメッセージ
main.cpp: In function ‘int main(int, const char**)’:
main.cpp:19:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
19 | scanf("%lld %lld %lld", &a, &b, &n);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <iostream>
#include <vector>
#define vll vector<ll>
using namespace std;
typedef long long int ll;
#define P 1000000007
inline ll mpow(ll a, ll b, ll p){
ll ret = 1, num = a;
for(;b;){
if(b%2) ret = (ret*num)%p;
num = (num*num)%p;
b/=2;
}
return ret;
}
int main(int argc, char const *argv[]) {
ll a, b, n, ans = 1;
scanf("%lld %lld %lld", &a, &b, &n);
ll cnt[b+1];
for(int g=b;g>=2;g--){
ll tmp = (b/g) - ((a-1)/g);
cnt[g] = mpow(tmp, n, P-1);
for(int k=2*g;k<=b;k+=g) {
cnt[g] = (cnt[g] - cnt[k]);
if(cnt[g]<0) cnt[g] += P-1;
}
ans = (ans * mpow(g, cnt[g], P))%P;
}
printf("%lld\n", ans);
}
tonegawa