結果
問題 |
No.1022 Power Equation
|
ユーザー |
|
提出日時 | 2020-04-15 12:11:38 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 13 ms / 2,000 ms |
コード長 | 625 bytes |
コンパイル時間 | 870 ms |
コンパイル使用メモリ | 70,264 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-01 18:41:32 |
合計ジャッジ時間 | 1,235 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 8 | main() | ^~~~
ソースコード
#include<iostream> #include<vector> #include<algorithm> using namespace std; int gcd(int a,int b){return b?gcd(b,a%b):a;} int T; long N; main() { cin>>T; for(;T--;) { cin>>N; long ans=0; int pre=1; for(int k=32;--k;) { long l=pre,r=N+1; while(r-l>1) { long m=(l+r)/2; long t=1; for(int j=0;j<k;j++) { t*=m; if(t>N)break; } if(t>N)r=m; else l=m; } int now=l; long tmp=0; for(int i=1;i<=k;i++)for(int j=1;j<=k;j++) { if(gcd(i,j)>1)continue; long t=N/max(i,j); tmp+=t; } ans+=tmp*(now-pre); pre=now; } cout<<ans+N*N<<endl; } }