yashbihany's blog

By yashbihany, 13 months ago, In English

Problem A — Submission Bait II

Author: wuhudsm

Preparer: Banis

Hint
Solution
Code (C++)
Rate the Problem

Problem B — Subtractonacci

Author: imranakki

Hint
Solution
Code (C++)
Rate the Problem

Problem C — Kaosar loves Polynomials

Author: Davy_D._Kaosar

Hint
Solution
Code (C++)
Rate the Problem

Problem D — Array Forge

Author: wuhudsm

Hint 1
Hint 2
Solution
Code (C++)
Rate the Problem

Problem E — GCD and LCM in Perfect Sync

Author: wuhudsm

Solution
Code (C++)
Rate the Problem

Problem F — Mega Polynomial

Author: wuhudsm

Solution
Code (C++)
Rate the Problem

Problem G — Max-Min Madness

Author: wuhudsm

Solution
Code (C++)
Rate the Problem

Hope you enjoyed the round. If anything is unclear or missing, please let me know in the comments.

  • Vote: I like it
  • +42
  • Vote: I do not like it

»
13 months ago, hide # |
 
Vote: I like it +5 Vote: I do not like it

Code for E is incorrect, it's same as G

»
13 months ago, hide # |
Rev. 3  
Vote: I like it 0 Vote: I do not like it

In problem F, I used the following code to find the value of k which satisfies the inequality:

a.d.(n-k) = n.b.c ~~~~~ ll l=-1,r=n; while(r-l>1){ /*TTTFFF*/ ll m=(r+l)/2; if(a*d*(n-m)>=n*b*c){ l=m; } else { r=m; } } if(l==-1){ cout << n+1 << endl; return; } ll p1=a*d*(n-l); ll p2=n*b*c; if(p1>p2){ cout << n+1 << endl; return; }

This binary search code seems correct to me for finding the correct value of k (here l) which satisfies the equation , but it gives wrong answer on test 5 , while if i directly find the value of k(here l) using : ~~~~~ ll a,b,c,d; ll n; cin >> a >> b >> c >> d >> n; if((n*b*c)%(a*d)!=0){ cout << n+1 << endl; return; } ll l=n-(n*b*c)/(a*d); if(l<0){ cout << n+1 << endl; return; }

It gives AC , can anyone please explain what is wrong with my binary search logic , as i think it is pretty much the same thing , since i am checking for the equality in the end . Please someone help me , i am stuck in this for hours :(

EDIT: Nevermind , i got the issue :|

»
13 months ago, hide # |
 
Vote: I like it +11 Vote: I do not like it

YashBihany orz? Revived just to upvote.

»
13 months ago, hide # |
Rev. 3  
Vote: I like it 0 Vote: I do not like it

please point to which of the points related to problem E are incorrect

-> we need ai to satisfy 1 <= ai <= a1 * a1

-> we cannot take any ai, such that gcd(a1, ai) = 1 except ai = 1

-> lcm is determined by terms of type ai = a1 * d (d is some divisor of a1)

-> gcd is determined by terms of type ai = d (d is some divisor of a1)

-> lcm will be the maximum value in the form (a1 * d) as mentioned

-> gcd will be the smallest value in the form d

-> so i will make sure 2 terms exist. a1 * d and d so that lcm/gcd = a1

-> for the remaining n — 3 terms i will fill terms in a way a1 * d is greatest and d is the least.

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

In D problem , how can we calculate inverse factorials in O(1e6+logp)