AJAYHAYAGREEVE's blog

By AJAYHAYAGREEVE, history, 18 hours ago, In English,

hi every one. im having a doubt in codeforces problem 440 C. here is the link http://codeforces.com/problemset/problem/440/C. My approach was

A number x can be represented by having the number with only ones which is less than the given number. for eg if number is 40 one approach is taking 11. 

     Another is having the number with only ones which is greater than the given number. i.e. 111 for 40 then take absolute difference between the number and the given number i.e abs(11 – 40) = 29 and abs(111 – 40) which is 71.

     Now call the function again for the new n. in this case fun(29) and fun(49).

     Now added with the number of ones take the min of these two i.e min(fun(29) + 2, fun(71) + 3). that is the answer. Also if we can represent the number with the ones alone. for eg 11 then return 2 just. i.e without computing min(fun(11-11) + 2, fun(111- 11) + 3);

 But i got wrong answer in test 14. the input is 81924761239462. and the expected output is 321. And my output is 395. Can you please tell me what is wrong.

here is the link: http://ide.geeksforgeeks.org/kRLASR. And even in diagnostics it is not showing anything.

Read more »

 
 
 
 
  • Vote: I like it  
  • -4
  • Vote: I do not like it  

By AJAYHAYAGREEVE, history, 7 days ago, In English,

hi every one. im having a doubt in codeforces problem 440 C. here is the link http://codeforces.com/problemset/problem/440/C. My approach was

A number x can be represented by having the number with only ones which is less than the given number. for eg if number is 40 one approach is taking 11.

Another is having the number with only ones which is greater than the given number. i.e. 111 for 40 then take absolute difference between the number and the given number i.e abs(11 – 40) = 29 and abs(111 – 40) which is 71.

Now call the function again for the new n. in this case fun(29) and fun(49).

Now added with the number of ones take the min of these two i.e min(fun(29) + 2, fun(71) + 3). that is the answer. Also if we can represent the number with the ones alone. for eg 11 then return 2 just. i.e without computing min(fun(11-11) + 2, fun(111- 11) + 3);

But i got wrong answer in test 14. the input is 81924761239462. and the expected output is 321. And my output is 395. Can you please tell me what is wrong.

here is the link: http://ide.geeksforgeeks.org/kRLASR. THanks in advance

Read more »

 
 
 
 

By AJAYHAYAGREEVE, history, 4 weeks ago, In English,

hi everyone. I'm having a doubt in problem 839D. The link is here http://codeforces.com/problemset/problem/839/D
I submitted a solution which gives me wrong answer on test 44. The link is here. https://ideone.com/tJhWMt

But i just modified the line number 57 from ans[i] = gcd[i] * p2[max(gcd[i] — 1, (int)0)]; to
ans[i] = (gcd[i] * p2[max(gcd[i] — 1, (int)0)]) % mod; where mod is 10^9 + 7. And it got accepted

My question is even though we don't take the mod value in line 59, in line number 60 after the execution of the 1st inner for on line 59, it will automatically take modulus and by any means ans[i*j], on line 60 wont be greater than 10^9 + 6. So why is the mod on line 57 even necessary. Plz help. Thanks in advance

Read more »

 
 
 
 
  • Vote: I like it  
  • -13
  • Vote: I do not like it