結果
問題 |
No.1164 GCD Products hard
|
ユーザー |
|
提出日時 | 2020-08-14 03:11:19 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 560 bytes |
コンパイル時間 | 2,070 ms |
コンパイル使用メモリ | 192,024 KB |
最終ジャッジ日時 | 2025-01-12 22:20:26 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 19 TLE * 8 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:17:25: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 17 | int a,b,n; scanf("%d%d%d",&a,&b,&n); | ~~~~~^~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; using lint=long long; const int MOD=1e9+7; lint modpow(lint a,lint k,int m){ lint r=1; for(lint x=a%m;k>0;k>>=1,x=x*x%m) if(k&1) r=r*x%m; return r; } int main(){ int a,b,n; scanf("%d%d%d",&a,&b,&n); static int f[10000001]; for(int g=b;g>=2;g--){ f[g]=modpow(b/g-(a-1)/g,n,MOD-1); for(int h=2*g;h<=b;h+=g){ f[g]-=f[h]; if(f[g]<0) f[g]+=MOD-1; } } int ans=1; for(int g=2;g<=b;g++) ans=ans*modpow(g,f[g],MOD)%MOD; printf("%d\n",ans); return 0; }