結果

問題 No.1022 Power Equation
ユーザー auauaauaua
提出日時 2020-04-10 23:24:49
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 1,183 bytes
コンパイル時間 2,217 ms
コンパイル使用メモリ 166,480 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-14 05:48:57
合計ジャッジ時間 2,371 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 4 ms
4,368 KB
testcase_02 AC 4 ms
4,372 KB
testcase_03 AC 4 ms
4,368 KB
testcase_04 AC 7 ms
4,372 KB
testcase_05 AC 8 ms
4,368 KB
testcase_06 AC 8 ms
4,368 KB
testcase_07 AC 8 ms
4,368 KB
testcase_08 AC 5 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
    }
}
0