結果

問題 No.1022 Power Equation
ユーザー たたき@競プロたたき@競プロ
提出日時 2023-10-08 11:38:46
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 839 bytes
コンパイル時間 4,719 ms
コンパイル使用メモリ 306,756 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-08 11:38:52
合計ジャッジ時間 5,727 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint=modint998244353; //1000000007;
using ll=unsigned long long;
using pp=pair<int,int>;
#define sr string 
#define vc vector
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define pque priority_queue
#define bpc(a) __builtin_popcount(a)
void sol(){
  ll n;cin>>n;
  ll d=sqrt(n)+10;
  d=min(d,n);
  vc<bool>bo(d+1,true);
  ll ans=n*n+(n-1)*n;
  for(ll i=2;i<=d;i++)if(bo[i]){
    ll mx=0;
    for(ll j=i*i;j<=d;j*=i)bo[j]=false;
    for(ll j=i;j<=n;j*=i)mx++;
    //cout<<i<<' '<<mx<<"\n";
    for(ll j=2;j<=mx;j++)for(ll k=1;k<j;k++){
      ll x=j/gcd(j,k);
      ans+=n/x*2;
    }
  }
  cout<<ans<<"\n";
}
int main(){
  int t;cin>>t;
  rep(z,t)sol();
}
0