Codeforces|Leetcode|Codechef free solutions
Kanalga Telegramβda oβtish
Free codeforces, Codechef, Leetcode solutions are available ππππππ Helped More than 200+ students to crack coding round in 2022 and helped placed them in Good companies. π₯³π₯³π₯³π€©π€©π€© Dm @Cpsoln if you want help in coding round.
Ko'proq ko'rsatish4 317
Obunachilar
Ma'lumot yo'q24 soatlar
-137 kunlar
-5230 kunlar
Postlar arxiv
Do you want today's leetcode biweekly contest codes for free?
De shaw
subarray done β
β
β
weighed directed tree β
β
β
Pattern of Amazon ML summer school:
2 coding ques
30 mcqs
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T>
using o_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
typedef pair<int, int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define PB push_back
#define F first
#define S second
#define ALL(a) a.begin(), a.end()
#define SET(a, b) memset(a, b, sizeof(a))
#define SZ(a) (int)(a.size())
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL)
#define endl "\n"
const long long mod = 1e9 + 7;
#define MAXN (int)1e6 + 5
vector<int> primes;
bitset<MAXN + 5> isPrime;
vector<int> spf(MAXN + 5, 1e9);
void getPrimes() {
iota(ALL(spf), 0);
isPrime.set();
isPrime[0] = isPrime[1] = 0;
for (int i = 2; i <= sqrt(MAXN) + 2; i++) {
if (isPrime[i]) {
primes.push_back(i);
for (int j = i * i; j <= MAXN; j += i) {
isPrime[j] = 0;
spf[j] = min(spf[j], i);
}
}
}
FOR(i, sqrt(MAXN) + 3, MAXN)
if (isPrime[i])
primes.PB(i);
}
VI pf;
void solve() {
int n;
cin >> n;
int indx = upper_bound(ALL(primes), spf[n]) - primes.begin();
indx--;
int prod = n * (pf[indx]);
cout << prod << endl;
}
signed main() {
fast_io;
int totalTests;
cin >> totalTests;
getPrimes();
pf.assign(SZ(primes), 0);
FOR(i, 0, SZ(primes)) {
pf[i] = primes[i];
if (i) pf[i] += pf[i - 1];
}
for (int testNo = 1; testNo <= totalTests; testNo++) {
solve();
}
return 0;
}
