Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

Wrong answer on 526C

Revision en1, by newbie_forever_at_cp, 2017-12-13 21:23:46

hi guys, Am trying to solve this problem (http://codeforces.com/problemset/problem/526/C). My approach is find the lcm of w1 and w2. Now on reaching lcm(w1, w2) if(lcm/w1*h1 > lcm/w2*h2) then we prefer h1 upto the lcm. else we prefer h2 Now for the remaining i.e from c/lcm to c, Just iterate and check which is the optimal answer. My code is https://ide.geeksforgeeks.org/zh4C5tHJPG . But i get wrong answer on test 3. I couldnot figure out what is wrong. Could you help me.

Tags greedy, #math

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English newbie_forever_at_cp 2017-12-13 21:23:46 497 Initial revision (published)