### O--O's blog

By O--O, history, 7 weeks ago,

Hello, Codeforces!!!

We are happy to invite you to TheForces Round #5 (PerfectForces), which will take place on [contest_time:425963]

You will have 2 hours to solve 7 problems

Thanks for participating.

Winners are:

Editorial

Solutions are opened.

Here is a group archive of our previous contests

• +51

 » 7 weeks ago, # |   +10 I am waiting for nice problems!
 » 7 weeks ago, # |   0 is it rated ?
•  » » 7 weeks ago, # ^ |   +8
 » 7 weeks ago, # |   +4 is it rated? or just for practice purpose.
•  » » 7 weeks ago, # ^ |   +1 It's just for practice
 » 7 weeks ago, # |   +7 thanks for helping the community
 » 7 weeks ago, # |   +5 i am not able to register
•  » » 7 weeks ago, # ^ |   +6 Maybe something went wrong. Everyone can register.
 » 7 weeks ago, # |   +31 am I alone who received browser alert with this blog entry?
•  » » 7 weeks ago, # ^ |   +11 I also did
•  » » 7 weeks ago, # ^ |   +11 I did too.
 » 7 weeks ago, # |   0 what's the expected complexity of the round? like div2?
•  » » 7 weeks ago, # ^ |   +3 you will see...
•  » » » 7 weeks ago, # ^ |   0 fingers crossed then ig :_:
•  » » 7 weeks ago, # ^ |   0 It was most likely div 2.5, what do you think?
•  » » » 7 weeks ago, # ^ |   0 Div3 i would say, damn G is such a nice implementation problem! Loved it
 » 7 weeks ago, # |   +19 Did you like the contest?
•  » » 7 weeks ago, # ^ |   0 thanks man
•  » » 7 weeks ago, # ^ |   0 Yes. How to F though ??
•  » » 7 weeks ago, # ^ |   0 absolutely yes
•  » » 7 weeks ago, # ^ |   0 ya i liked the contest
•  » » 7 weeks ago, # ^ |   0 yes, good contest and will come for more :)
 » 7 weeks ago, # |   0 How to solve F?
•  » » 7 weeks ago, # ^ |   0 Hint: 2 * 3 * 5 * 7 * 11 * 13 * 17 * 19 * 23 has 512 divisors
•  » » 7 weeks ago, # ^ | ← Rev. 2 →   0 idk either but i found this [Your text to link here...](http://(https://stackoverflow.com/questions/31270226/how-to-calculate-smallest-number-with-certain-number-of-divisors))
 » 7 weeks ago, # |   0 How to solve Problem B Cube Sum for Perfect 100 points
•  » » 7 weeks ago, # ^ | ← Rev. 2 →   0 Prefix sum + Binary search after precalculation upto 1e6. My code-#include #include #include using namespace std; #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) #define sz(x) (ll)x.size() #define Ouput2DVector(mat,n,m){for(int i=0;i void __print(const pair &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';} template void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""),__print(i); cerr << "}";} void _print() {cerr << "]\n";} template void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);} #ifndef ONLINE_JUDGE #define debug(x...) cerr << "[" << #x << "] = ["; _print(x) #else #define debug(x...) #endif template istream& operator>>(istream& is, vector& v){for (auto& i : v) is >> i;return is;} template ostream& operator<<(ostream& os, vector& v){for (auto& i : v) os << i << ' ';return os;} const ll inf = 1e18, maxn = 1e6 + 1, mod = 1e9 + 7; ll add(ll a, ll b) {a = a % mod; b = b % mod; return (((a + b) % mod) + mod) % mod;} ll sub(ll a, ll b) {a = a % mod; b = b % mod; return (((a - b) % mod) + mod) % mod;} vector P, pre; void Solve(){ ll L, R; cin >> L >> R; auto lst = upper_bound(all(P), R) - P.begin(); auto fst = lower_bound(all(P), L) - P.begin(); // for(ll i = 0; i < 5; i++) cout << P[i] << ' '; // cout << '\n'; if(P[fst] >= L) fst--; // debug(lst - 1, fst, pre[lst - 1], pre[fst]); cout << (sub(pre[lst - 1] , (fst >= 0 ? pre[fst] : 0))) << '\n'; } int main(){ ios_base::sync_with_stdio(false);cin.tie(nullptr); cout.tie(nullptr); ll t = 1; cin>>t; for(ll i = 1; i < maxn; i++){ P.push_back(i * i * i); pre.push_back((pre.empty() ? i * i * i : (add(pre.back(), i * i * i)))); } for(ll i=0;i
•  » » » 7 weeks ago, # ^ | ← Rev. 2 →   0 Can u share the code Upd:- Thanks for Code
•  » » » » 7 weeks ago, # ^ | ← Rev. 2 →   0 Code#include "bits/stdc++.h" using namespace std; using ll = long long; const ll mod = 1e9 + 7; ll add(ll a, ll b) {a = a % mod; b = b % mod; return (((a + b) % mod) + mod) % mod;} ll mul(ll a, ll b) {a = a % mod; b = b % mod; return (((a * b) % mod) + mod) % mod;} ll sub(ll a, ll b) {a = a % mod; b = b % mod; return (((a — b) % mod) + mod) % mod;} signed main(){ ll x = 1, cube = 0; vector cubes; while(cube < 1e18){ cube = x * x * x, x++, cubes.push_back(cube); } vector pre(1e6 + 5); pre[0] = cubes[0]; for(ll i = 1; i < cubes.size(); i++) pre[i] = add(pre[i - 1], cubes[i]); int t; cin >> t; while(t--){ ll l, r; cin >> l >> r; auto low = lower_bound(cubes.begin(), cubes.end(), l) - cubes.begin(); auto high = upper_bound(cubes.begin(), cubes.end(), r) - cubes.begin(); high--; ll sum = 0; if(low > 0) sum = sub(pre[high], pre[low - 1]); else sum = pre[high]; cout << (sum) << endl;; } } 
•  » » 7 weeks ago, # ^ |   0 Precompute the cubes of each numbers till 1e6 and also store prefix sum of the cubes. Now for query part use binary search to find indexes of l and r in cubes array and use prefix array to find the sum.My solution
•  » » 7 weeks ago, # ^ | ← Rev. 2 →   0 $1^3 + 2^3 + ... + n^3 = (\frac{n * (n + 1)}{2}) ^ 2$
•  » » » 7 weeks ago, # ^ |   0 Yeah I have also come up with this formula but it was running for only samples :(
•  » » » » 7 weeks ago, # ^ |   0 It works! Codell binpow(ll a, ll b, ll m=mod) { a %= m; long long res = 1; while (b > 0) { if (b & 1) res = res * a % m; a = a * a % m; b >>= 1; } return res; } void solve() { ll l, r; cin >> l >> r; --l; l = cbrtl(l); r = cbrtl(r); ll ans = binpow((r * (r + 1) / 2),2); ll mini = binpow((l * (l + 1) / 2),2); cout << (ans - mini + mod) % mod << endl; } 
•  » » 7 weeks ago, # ^ |   0 Take the cube root of l and r , let it be lc and rc respectively. Then required ans is (rc*(rc+1)//2)**2 — (lc*(lc+1)//2)**2 . As sum of cubes from 1 to n is (n*(n+1)//2)**2 .My Code : def perfect_cube(n): x = int(n**(1/3)) while True: if x * x * x <= n: break x -= 1 while True: if x * x * x >= n: break x += 1 return x - 1 def is_perfect_cube(n): x = int(n**(1/3)) while True: if x * x * x <= n: break x -= 1 while True: if x * x * x >= n: break x += 1 return x * x * x == n mod = int(1e9)+7 for _ in range(ii()): l,r=li() lc,rc=perfect_cube(l),perfect_cube(r) if is_perfect_cube(l) and is_perfect_cube(r): # lc+=1 rc+=1 elif is_perfect_cube(r) and not(is_perfect_cube(l)): rc+=1 # print(lc, rc) # lc-=1 ans = ((pow(rc*(rc+1)//2,2,mod)%mod - pow(lc*(lc+1)//2,2,mod)%mod)%mod) print(ans) 
 » 7 weeks ago, # |   0 The problems were pretty interesting to approach and educative. Thanks for this beautiful round.
 » 7 weeks ago, # |   0 Why Pratice Mode isn't enabled? I had to give virtual contest to submit $G$. I failed G by few minutes :(
•  » » 7 weeks ago, # ^ |   0 Anyways... Nice Problems. Enjoyed solving G :D
•  » » » 7 weeks ago, # ^ |   +3 how to solve F
•  » » » » 7 weeks ago, # ^ | ← Rev. 3 →   +3 I precomputed primes upto 1e7 using Linear seive. and made a set of pairs $($ no of divisors, smallest number $)$ and did a single loop [upto 1e7] and taken the number into account, whose no of divisors are greater than max no of divisors present in the set. Codeconst int SZ = 1e7 + 1; Seive ps(SZ); set se; void pre(){ rep(i, 1, SZ){ int p = ps.divisors(i); auto it = se.ub({p, 0}); if (it == se.end()){ se.in({p, i}); } } } void solve(){ /* JAI SHREE RAM */ int n; cin >> n; cout << (*se.ub({n, -1})).ss << endl; } Submission
•  » » » » » 7 weeks ago, # ^ |   +3 Got it thanks
 » 7 weeks ago, # |   +4 Thanks a lot for the contest bro, I really liked it. I'd recommend you make a facebook page where you can announce the contest date.
 » 7 weeks ago, # |   +3 Auto comment: topic has been updated by E404_Not_Found (previous revision, new revision, compare).
 » 7 weeks ago, # |   +3 can you guys please make a discord server or some other type of group that we can join so that we get notified ...as most of the times blogs don't show up and we miss these contests
•  » » 6 weeks ago, # ^ |   +6 Done.
 » 6 weeks ago, # |   +3 It is very hard to participate in your rounds i am very active on codeforces but still could not see your blog.
 » 6 weeks ago, # |   0 Very interesting gym, enjoyed it. Thanks to the organizers. If they need tester, I would help them with pleasure (never was tester before).