結果
| 問題 |
No.1022 Power Equation
|
| コンテスト | |
| ユーザー |
hanbei_dayo
|
| 提出日時 | 2020-08-31 21:25:34 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,017 ms / 2,000 ms |
| コード長 | 1,370 bytes |
| コンパイル時間 | 1,360 ms |
| コンパイル使用メモリ | 105,772 KB |
| 実行使用メモリ | 6,528 KB |
| 最終ジャッジ日時 | 2024-11-17 02:26:33 |
| 合計ジャッジ時間 | 5,909 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 8 |
ソースコード
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
#include <bitset>
#include <deque>
using namespace std;
#define N (1000000000+7)
//#define N 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> Q;
const int inf = (int)1e9;
ll gcd(ll a, ll b) {
if (b > a) {
ll tmp = b;
b = a;
a = tmp;
}
if (a%b == 0)return b;
else return gcd(b, a%b);
}
int main(void){
int T;
cin>>T;
for(int i=0;i<T;i++){
ll n;
cin>>n;
ll ans = n*(n-1)+n*n;
set<int>s;
for(ll i=2;i*i<=n;i++){
if(s.count(i)==1)continue;
vector<ll>p;
ll index = 1;
for(ll j=i;j<=n;j*=i){
s.insert(j);
p.push_back(index);
index++;
}
for(ll j=0;j<p.size();j++){
for(ll k=0;k<p.size();k++){
if(j==k)continue;
ll g = gcd(p[j],p[k]);
ll p1 = p[j]/g;
ll p2 = p[k]/g;
ll n1 = n/max(p1,p2);
ans+=n1;
}
}
}
cout<<ans<<endl;
}
return 0;
}
hanbei_dayo