ABC Problem 285

Revision en2, by VaeKnt, 2023-04-01 09:55:31

Hello — I am very new so I'm not sure if I'm not having proper etiquette — please inform me if I'm being rude etc.

The problem is about finding the numerical ID of a string. So A = 1, B = 2, etc. AA = 27 (since it goes to Z then it becomes AA — kind of like an excel sheet.)

I thought I solved this, ([my code](https://codeforces.com/a7a3e1/Screenshot 2023-04-01 at 2.36.14 pm.png) is the first screenshot) - I just thought that the ID is: eg ABC — the 'A' spot is 26^2, and the value of A is 1, 'B' spot is the 26^1 spot, and the value of B is 2, etc. Just like a normal number so the ID would be ABC = 26^2*1 + 26^1 * 2 + 26^3 * 0.

I did this in C++ and my code is above. It passes all but 3 test cases. And these are very close to the cut off of BRUTMHYHIIZP = 10^16, and my answer and the output differ by 1.

Is this because of the pow() function that I used? Or am I just wrong?

P.s: I read the atcoder editorial and they "initialise" by 26^1 + 26^2 .... 26^l-1. where l is the length of the string and then go on to just count where along the list the specific string is and then add it to the sum above so I know we did it different ways (sort of).

I just don't know why mine is wrong. I've spent a lot of time on it, and even tried using round(pow()) but I don't know why it's still wrong

AtCoder's solution

Tags simple math, atcoder

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English VaeKnt 2023-04-01 09:56:49 95 Tiny change: 'ved this, ([my code](' -> 'ved this, [my code]('
en2 English VaeKnt 2023-04-01 09:55:31 175
en1 English VaeKnt 2023-04-01 09:48:28 1298 Initial revision (published)