結果
問題 | No.1164 GCD Products hard |
ユーザー |
![]() |
提出日時 | 2020-08-15 12:17:45 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 843 bytes |
コンパイル時間 | 977 ms |
コンパイル使用メモリ | 71,284 KB |
最終ジャッジ日時 | 2025-01-13 01:21:50 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 TLE * 9 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:14:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 14 | scanf("%lld %lld %lld", &a, &b, &n); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #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 ret, num, x; for(int g=b;g>=2;g--){ ll tmp = b/g - a/g; ret = 1, num = tmp, x = n; for(;x;){ if(x&1) ret = (ret*num)%Q; num=(num*num)%Q; x>>=1; } cnt[g] = ret; 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); }