Need help with 1345C

Правка en1, от qhung312, 2020-05-07 02:52:27

1345C - Hilbert's Hotel requires you to check if all (i + arr[i]) % n is distinct, so I did:

for (int i = 0; i < n; i++) {
  ll x;
  cin >> x;
  arr[i] = (i + x) % n;
  s.insert(arr[i]);
}
cout << ((s.size() == n) ? "YES" : "NO") << '\n';

This got WA on test 2, whereas if I change it to:

arr[i] = ((i + x) % n + n) % n;

This got AC. But aren't (i + x) % n and ((i + x) % n + n) % n the same thing?

Теги #number theory

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский qhung312 2020-05-07 02:53:36 0 (published)
en1 Английский qhung312 2020-05-07 02:52:27 460 Initial revision (saved to drafts)