結果
問題 | No.1022 Power Equation |
ユーザー |
![]() |
提出日時 | 2020-04-10 23:24:49 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 1,183 bytes |
コンパイル時間 | 1,757 ms |
コンパイル使用メモリ | 168,144 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-16 01:06:40 |
合計ジャッジ時間 | 2,146 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
ソースコード
#include<bits/stdc++.h>#include<unordered_set>#include<unordered_map>using namespace std;#define int long long#define REP(i,m,n) for(int i=(m);i<(n);i++)#define rep(i,n) REP(i,0,n)#define pb push_back#define all(a) a.begin(),a.end()#define rall(c) (c).rbegin(),(c).rend()#define mp make_pair#define endl '\n'typedef long long ll;typedef pair<ll,ll> pll;typedef long double ld;const ll inf=1e9+7;const ll mod=1e9+7;ll gcd(ll a,ll b){if(a<b)swap(a,b);if(b==0)return a;return gcd(b,a%b);}signed main(){ll t;cin>>t;while(t){t--;ll n;cin>>n;ll ans=0;vector<ll>jou(35);jou[1]=n;REP(i,2,33){REP(j,2,sqrt(n)+1){ll res=1;rep(k,i){res*=(ll)j;}if(res<=n)jou[i]++;else break;}}ans+=n*(2*n-1);REP(i,1,33){REP(j,i+1,33){if(gcd(i,j)==1){ll lcm=(ll)i*(ll)j/gcd(i,j);ans+=n/(j/gcd(i,j))*jou[j]*2;}}}cout<<ans<<endl;}}