Java Solution of D- Divisible Pairs CF Round 925

Правка en1, от KiZamaDo17, 2024-02-14 07:54:23

I attempted the D problem in JAVA 21 64bit with the simple logic of storing the remainder of a[i] in pairs along with their frequency in HashMap and check if (x-(a[i]%x)),(a[i]%y)), adding 1 to answer if it happens. I also make the remainder equal to x if it comes out to be zero.

Heres my solution

My Answer

but for some reason it fails the 12th test. I don't know what on God's Earth it is, but I then just convert the same logic to C++ and its accepted.

Where am I going wrong? What seems to be the problem here? Is there an alternative? A friend of mine suggested using a @D array instead of a map an hence saving the trouble of creating pair class in JAVA but I could not fully grasp his concept. Please help me out here.

Теги contest #925, contest, java, c++, problem d, divisible pairs, 925, submissions, wrong answer, wa

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский KiZamaDo17 2024-02-14 07:56:28 19 Tiny change: ',(a[i]%y)), adding 1' -> ',(a[i]%y)) is already present, adding 1'
en2 Английский KiZamaDo17 2024-02-14 07:55:18 2 Tiny change: 'd using a @D array in' -> 'd using a 2D array in'
en1 Английский KiZamaDo17 2024-02-14 07:54:23 846 Initial revision (published)