fork download
  1. /*
  2. " وَكَانَ فَضْلُ اللَّهِ عَلَيْكَ عَظِيمًا "
  3.  
  4. ╔░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╗
  5. ║ ║
  6. ║ ███╗ ███╗ ██████╗ ██╗ ██╗ █████╗ ███╗ ███╗ ███████╗ ██████╗ ║
  7. ║ ████╗ ████║██╔═══██╗██║ ██║ ██╔══██╗ ████╗ ████║ ██╔════╝ ██╔══██╗ ║
  8. ║ ██╔████╔██║██║ ██║███████║ ███████║ ██╔████╔██║ █████╗ ██║ ██║ ║
  9. ║ ██║╚██╔╝██║██║ ██║██╔══██║ ██╔══██║ ██║╚██╔╝██║ ██╔══╝ ██║ ██║ ║
  10. ║ ██║ ╚═╝ ██║╚██████╔╝██║ ██║ ██║ ██║ ██║ ╚═╝ ██║ ███████╗ ██████╔╝ ║
  11. ║ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝ ╚═════╝ ║
  12. ║ ║
  13. ║ ██╗ ██╗ ██████╗ ███████╗ ███████╗ █████╗ ███╗ ███╗ ║
  14. ║ ██║ ██║ ██╔═══██╗ ██╔════╝ ██╔════╝ ██╔══██╗ ████╗ ████║ ║
  15. ║ ███████║ ██║ ██║ ███████╗ ███████╗ ███████║ ██╔████╔██║ ║
  16. ║ ██╔══██║ ██║ ██║ ╚════██║ ╚════██║ ██╔══██║ ██║╚██╔╝██║ ║
  17. ║ ██║ ██║ ╚██████╔╝ ███████║ ███████║ ██║ ██║ ██║ ╚═╝ ██║ ║
  18. ║ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ║
  19. ║ ║
  20. ╚░░░░░░░░░░░░░░░░░░░░░░░ MOHAMED HOSSAM | SOFTWARE ENGINEER ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╝
  21. */
  22.  
  23. #include"bits/stdc++.h"
  24. using namespace std;
  25. #define el '\n'
  26. #define ll long long
  27. #define int long long
  28. #define yes cout << "YES\n"
  29. #define no cout << "NO\n"
  30. #define all(x) (x).begin(), (x).end()
  31. #define rall(x) x.rbegin(), x.rend()
  32. #define sz(x) ((int)(x).size())
  33.  
  34. template<class T, class U>
  35. T GCD(T a, U b) { return (!b ? a : GCD(b, a % b)); }
  36.  
  37. template<class T, class U>
  38. T LCM(T a, U b) { return ((a / GCD(a, b)) * b); }
  39.  
  40. template<class Ta, class Tb>
  41. bool chmax(Ta &a, Tb b) {
  42. if (a >= b) return false;
  43. a = b;
  44. return true;
  45. }
  46.  
  47. template<class Ta, class Tb>
  48. bool chmin(Ta &a, Tb b) {
  49. if (a <= b) return false;
  50. a = b;
  51. return true;
  52. }
  53.  
  54. constexpr ll MAX = 300000, MOD = 998244353, MAXN = 2e5 + 10, inf = 1e18;
  55. using vi = vector<int>;
  56.  
  57. inline void free_palestine() {
  58. ios_base::sync_with_stdio(false);
  59. cin.tie(NULL);
  60. cout.tie(NULL);
  61.  
  62. #ifndef ONLINE_JUDGE
  63. freopen("inputs.txt", "r", stdin);
  64. freopen("output.txt", "w", stdout);
  65. #endif
  66. }
  67.  
  68. template<typename T>
  69. istream &operator>>(istream &in, vector<T> &v) {
  70. for (auto &x: v) in >> x;
  71. return in;
  72. }
  73.  
  74. template<typename T>
  75. ostream &operator<<(ostream &out, const vector<T> &v) {
  76. for (const auto &x: v) out << x << ' ';
  77. return out;
  78. }
  79. void solve(int tc) {
  80. int n ,x;cin>>n>>x;
  81. unordered_map<int, int> freq;
  82.  
  83. int sum=0,ans=0;
  84.  
  85. freq[0] = 1;
  86.  
  87. for (int i=0;i<n;i++) {
  88. int a;cin>>a;
  89. sum += a;
  90. sum %= x;
  91. ans += freq[sum];
  92.  
  93. freq[sum]++;
  94. }
  95.  
  96. cout<<ans<<el;
  97.  
  98.  
  99.  
  100.  
  101. }
  102.  
  103. int32_t main() {
  104. free_palestine();
  105. // freopen("collectingofficer.in", "r", stdin);// freopen("palindrome.out", "w", stdout);
  106. int tc = 1;
  107.  
  108. //cin >> tc;
  109. for (int i = 1; i <= tc; ++i) {
  110. solve(i);
  111. }
  112.  
  113. /*
  114.   ⢸⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⡷⠀⠀
  115.   ⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠢⣀⠀⠀
  116.   ⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇ Did you get accepted, son?
  117.   ⢸⠀⠀⠀⠀ ⠖⠒⠒⠒⢤⠀⠀⠀⠀⠀⡇⠀⠀
  118.   ⢸⠀⠀⣀⢤⣼⣀⡠⠤⠤⠼⠤⡄⠀⠀⡇⠀
  119.   ⢸⠀⠀⠑⡤⠤⡒⠒⠒⡊⠙⡏⠀⢀⠀⡇⠀
  120.   ⢸⠀⠀⠀⠇⠀⣀⣀⣀⣀⢀⠧⠟⠁ ⡇
  121.   ⢸⠀⠀⠀⠸⣀⠀⠀⠈⢉⠟⠓⠀⠀⠀⢀⡇⠀⠀
  122.   ⢸⠀⠀⠀⠀⠈⢱⡖⠋⠁⠀⠀⠀⠀⠀⡇⠀⡇
  123.   ⢸⠀⠀⠀⠀⣠⢺⠧⢄⣀⠀⠀⣀⣀⠀⡇⠀⡇
  124.   ⢸⠀⠀⠀⣠⠃⢸⠀⠀⠈⠉⡽⠿⠯⡆⡇
  125.   ⢸⠀⠀⣰⠁⠀⢸⠀⠀⠀⠀⠉⠉⠉⠀⡇⠀⡇
  126.   ⢸⠀⠀⠣⠀⠀⢸⢄⠀⠀⠀⠀⠀⠀⠀⡇⠀⡇⠀
  127.   ⢸⠀⠀⠀⠀⠀⢸⠀⢇⠀⠀⠀⠀⠀⠀⡇⠀⡇
  128.   ⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉
  129.   */
  130. }
  131.  
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
0