Guest User

Untitled

a guest
Jul 5th, 2019
1,837
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma GCC optimize("O3")
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. typedef long double ld;
  5. typedef long long ll;
  6. int mod;
  7.  
  8. int sum(int a, int b) {
  9. int s = a + b;
  10. if (s >= mod) s -= mod;
  11. return s;
  12. }
  13.  
  14. int sub(int a, int b) {
  15. int s = a - b;
  16. if (s < 0) s += mod;
  17. return s;
  18. }
  19.  
  20. int mult(int a, int b) {
  21. return (1LL * a * b) % mod;
  22. }
  23.  
  24. int pw4(int x) {
  25. return mult(mult(x, x), mult(x, x));
  26. }
  27.  
  28. int n, p, k;
  29. map < int, int > mp;
  30. int main() {
  31. ios_base::sync_with_stdio(false);
  32. cin.tie(nullptr);
  33. //freopen("input.txt", "r", stdin);
  34. cin >> n >> mod >> k;
  35. ll ans = 0;
  36. for (int i = 0; i < n; i++) {
  37. int x;
  38. cin >> x;
  39. int val = sub(pw4(x), mult(k, x));
  40. ans += mp[val];
  41. mp[val]++;
  42. }
  43. cout << ans;
  44. return 0;
  45. }
RAW Paste Data