結果
| 問題 |
No.2249 GCDistance
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-03-18 14:19:25 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 336 ms / 5,000 ms |
| コード長 | 5,372 bytes |
| コンパイル時間 | 1,788 ms |
| コンパイル使用メモリ | 197,148 KB |
| 最終ジャッジ日時 | 2025-02-11 15:04:32 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 10 |
ソースコード
/*
Lighting up the path with no end ♪ ♫ ♪ (kirari to hate no nai michi wo)
The twinkling starlight ♪ ♫ ♪ (terashi teku starlight)
I can't see anything ♪ ♫ ♪ (nani mo mienai keredo)
But I continue my way ♪ ♫ ♪ (boku wa susunde yuku)
Like the lucid wind of twilight ♪ ♫ ♪ (suki tooru kaze no yooni)
If I could soar across the night sky ♪ ♫ ♪ (kono yozora wo tobeta nara)
I wonder if my voice dirtied with sand ♪ ♫ ♪ (suna ni mamireta koe mo)
Can shine again ♪ ♫ ♪ (mata hikareru no kana)
Artist:- Divela
Song:- Meteor
*/
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define fastio() \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
//typedef __int128 bigll;
typedef long long ll;
#define ull unsigned long long
#define ld long double
#define pow power
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define siz(a) int((a).size())
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define Forl(i,a,b) for(ll (i)=(a);(i) < (b); ++(i))
#define Forn(i,a,b) for(int (i)=(a);(i) >= (b); --(i))
#define Fornl(i,a,b) for(ll (i)=(a);(i) >= (b); --(i))
#define endl "\n"
#define pi 3.14159265
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
const ll mod = 1000 * 1000 * 1000 + 7;
const ll mod1 = 998244353;
const ll INF = 1ll*1000*1000*1000*1000*1000*1000 + 7;
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll power(ll x, ll y)
{
ll res = 1;
while (y > 0)
{
if (y & 1)
res = (long long)(res*x); // adding powers wherever bit is set
y = y>>1;
x = (long long)(x*x); // increasing power by 2
//cout<<x<<'\n';
}
return res;
}
// Stolen Templates
template<typename F, typename S>
ostream& operator <<(ostream& ostream, pair<F, S>& p) {
cout << p.first << " " << p.second;
return ostream;
}
template<typename T>
ostream& operator <<(ostream& ostream, vector<T>& v) {
for(auto& element : v) {
cout << element << " ";
}
return ostream;
}
template<typename T>
ostream& operator <<(ostream& ostream, vector<vector<T>>& v) {
for(auto& row : v) {
for(auto& cell : row) {
cout << cell << " ";
}
cout << "\n";
}
return ostream;
}
template<typename F, typename S>
istream& operator >>(istream& istream, pair<F, S>& p) {
cin >> p.first >> p.second;
return istream;
}
template<typename T>
istream& operator >>(istream& istream, vector<T>& v) {
for(auto& element : v) {
cin >> element;
}
return istream;
}
void print() {
cout << endl;
}
template <typename T> void print(const T& t) {
cout << t << endl;
}
template <typename First, typename... Rest> void print(const First& first, const Rest&... rest) {
cout << first << " ";
print(rest...); // recursive call using pack expansion syntax
}
void dbg() {
cerr << endl;
}
template <typename T> void dbg(const T& t) {
cerr << t << endl;
}
template <typename First, typename... Rest> void dbg(const First& first, const Rest&... rest) {
cerr << first << " ";
dbg(rest...); // recursive call using pack expansion syntax
}
// Stolen Templates end here
// ostream& operator << (ostream&, bigll val) {
// string temp;
// while (val > 0) { temp.pb(val % 10 + '0'); val /= 10; }
// for(int i = siz(temp) - 1; i >= 0; i--)cout<<temp[i];
// return cout;
// } // inside class
// istream& operator >> (istream&, bigll & val) {
// string temp; cin>>temp; val = 0;
// for(int i = 0; i < siz(temp); i++)val = val * 10 + temp[i] - '0';
// return cin;
// } // for cin we use & because we want the original object we are sending not a copy of it
const ll n = 1e7l;
vector<int> phi(n + 1);
void phi_1_to_n() {
for (int i = 0; i <= n; i++)
phi[i] = i;
for (int i = 2; i <= n; i++) {
if (phi[i] == i) {
for (int j = i; j <= n; j += i)
phi[j] -= phi[j] / i;
}
}
}
int main()
{
// #ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// #endif
// If you plan on using set / map do check if it will TLE or not
fastio();
phi_1_to_n();
vector <ll> ans(n + 1);
for(ll i = 2; i <= n; i++) {
ans[i] += ans[i - 1] + 2 * (i - 1) - phi[i];
//cout<<ans[i]<<endl;
}
ll T;
cin>>T;
while(T--)
{
ll x;
cin>>x;
cout<<ans[x]<<endl;
}
return 0;
}
// check all product based operations for integer overflow
// careful of renamed variables especially in loops
//python interactive_runner.py python local_testing_tool.py 0 -- c.exe