結果
| 問題 |
No.1164 GCD Products hard
|
| ユーザー |
tonegawa
|
| 提出日時 | 2020-08-15 12:16:37 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 805 bytes |
| コンパイル時間 | 1,038 ms |
| コンパイル使用メモリ | 70,136 KB |
| 最終ジャッジ日時 | 2025-01-13 01:19:42 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 14 TLE * 13 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | 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
#define Q 1000000006
int main() {
ll a, b, n, ans = 1;
scanf("%lld %lld %lld", &a, &b, &n);
a--;
ll cnt[b+1];
ll mp[b+1];
ll ret, num, x;
for(int i=0;i<=b;i++){
ret = 1, num = i, x = n;
for(;x;){
if(x&1) ret = (ret*num)%Q;
num= (num*num)%Q;
x>>=1;
}
mp[i] = ret;
}
for(int g=b;g>=2;g--){
ll tmp = b/g - a/g;
cnt[g] = mp[tmp];
for(int k=2*g;k<=b;k+=g) cnt[g] -= cnt[k];
ll t = abs(cnt[g])/Q + 1;
cnt[g] = (cnt[g] + t*Q)%Q;
ret = 1, num = g, x = cnt[g];
for(;x;){
if(x&1) ret = (ret*num)%P;
num=(num*num)%P;
x>>=1;
}
ans = (ans * ret)%P;
}
printf("%lld\n", ans);
}
tonegawa