Sohsoh84's blog

By Sohsoh84, history, 5 weeks ago, In English,

Hi :), I was solving 1228C - Primes and Multiplication, I found a solution for that during the virtual contest, but it failed on third sample testcase

I think that my solution is correct, anyway, if you found a bug inside my code or you think that my solution is totally wrong, please tell me inside the comments section :)

here is my solution:

lets set the initial value of $$$ans$$$ to 1

for each $$$p$$$ in prime divisors of $$$x$$$, let's iterate over all powers of $$$p$$$ witch are less than $$$n$$$ ($$$p^1$$$, $$$p^2$$$, $$$p^3$$$, ...), for each number like $$$k$$$ witch $$$p^k <= n$$$, let's count all numbers $$$y$$$ less than or equal $$$n$$$ where $$$g(y, p) = p^k$$$ and call this number $$$c$$$, and multiply the $$$ans$$$ with $$$(p^k)^c$$$

this is how we can calculate $$$c$$$: $$$\lfloor n / p^k \rfloor - \lfloor n / p^{k + 1} \rfloor $$$

this is my code:

Code

My answer for sample test3: 532291087

The real answer for sample test3: 593574252

and sorry for my bad English :)

Read more »

Tags c++
 
 
 
 
  • Vote: I like it
  • +9
  • Vote: I do not like it

By Sohsoh84, history, 2 months ago, In English,

Hi :), I was solving 1278D - Segment Tree, I looped over all 2n cells once and I did an O(1) process inside the loop, then I looped again over them and in each index, I called either "Update" or "Sum" method of a Fenwick tree with size MAXN(about 1e6 in this problem), I think the final time complexity is going to be O(N log N) and my code should pass test cases with this time complexity, but I've got TLE on test 15

am I doing something wrong so it caused an undefined behavior ?? or Fenwick tree isn't good for this problem ??

My code: 83112181

and sorry for my bad English :)

Read more »

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

By Sohsoh84, history, 3 months ago, In English,

Hi :), I used exit(1) in one of my submissions and I've got "Runtime error" in a test case with "NO" answer and I think that it was the first test case witch the "exit(1)" line was called.

then I removed "exit(1)" from my code, and I didn't change anything(but adding some code for handling the "NO" answer without "exit(1)") and I've got "Accept".

I want to know if the runtime error was from the "exit(1)", can I use the "exit()" command in c++, if I can, is there ant special status code for exit or not...

and sorry for my bad English :)

problem: 1287D - Numbers on Tree

submission with Runtime error: 79037752

correct submission: 79038193

Read more »

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