### 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 Comments (46)
 » I am waiting for nice problems!
 » is it rated ?
•  » »
 » is it rated? or just for practice purpose.
•  » » It's just for practice
 » thanks for helping the community
 » i am not able to register
•  » » Maybe something went wrong. Everyone can register.
 » am I alone who received browser alert with this blog entry?
•  » » I also did
•  » » I did too.
 » what's the expected complexity of the round? like div2?
•  » » you will see...
•  » » » fingers crossed then ig :_:
•  » » It was most likely div 2.5, what do you think?
•  » » » Div3 i would say, damn G is such a nice implementation problem! Loved it
 » Did you like the contest?
•  » » thanks man
•  » » Yes. How to F though ??
•  » » absolutely yes
•  » » ya i liked the contest
•  » » yes, good contest and will come for more :)
 » How to solve F?
•  » » Hint: 2 * 3 * 5 * 7 * 11 * 13 * 17 * 19 * 23 has 512 divisors
•  » » 7 weeks ago, # ^ | ← Rev. 2 →   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))
 » How to solve Problem B Cube Sum for Perfect 100 points
•  » » 7 weeks ago, # ^ | ← Rev. 2 →   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 →   Can u share the code Upd:- Thanks for Code
•  » » » » 7 weeks ago, # ^ | ← Rev. 2 →   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 = cubes; 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;; } } 
•  » » 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 →   $1^3 + 2^3 + ... + n^3 = (\frac{n * (n + 1)}{2}) ^ 2$
•  » » » Yeah I have also come up with this formula but it was running for only samples :(
•  » » » » 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; } 
•  » » 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) 
 » The problems were pretty interesting to approach and educative. Thanks for this beautiful round.
 » Why Pratice Mode isn't enabled? I had to give virtual contest to submit $G$. I failed G by few minutes :(
•  » » Anyways... Nice Problems. Enjoyed solving G :D
•  » » » how to solve F
•  » » » » 7 weeks ago, # ^ | ← Rev. 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
•  » » » » » Got it thanks
 » 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.
 » Auto comment: topic has been updated by E404_Not_Found (previous revision, new revision, compare).
 » 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
•  » » Done.
 » It is very hard to participate in your rounds i am very active on codeforces but still could not see your blog.
 » Very interesting gym, enjoyed it. Thanks to the organizers. If they need tester, I would help them with pleasure (never was tester before).