fork download
  1. #pragma GCC optimize("O3")
  2. #pragma GCC target("popcnt,lzcnt,bmi,bmi2,abm")
  3. #include <iostream>
  4. #include <vector>
  5. #include <cstring>
  6. #include <string.h>
  7. #include <algorithm>
  8. #include <iomanip>
  9. #include <math.h>
  10. #include <iomanip>
  11. #include <map>
  12. #include <set>
  13. #include <stack>
  14. #include <queue>
  15. #include <deque>
  16. #include <stdio.h>
  17. // #include <limits.h>
  18. // #include<bits/stdc++.h>
  19. using namespace std;
  20.  
  21. // template < typename A, typename B > ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
  22. // template < typename T_container, typename T = typename enable_if < !is_same<T_container, string>::value, typename T_container::value_type >::type > ostream & operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
  23. // void dbg_out() { cerr << '\n'; }
  24. // template<typename Head, typename... Tail>
  25. // void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
  26. // #define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
  27.  
  28. #define PI 3.141592653589793116
  29. // PI = acos(-1)
  30. #define ll long long
  31. #define ld long double
  32. #define fi first
  33. #define se second
  34. #define nl '\n'
  35. #define all(x) x.begin(), x.end()
  36. #define no cout << "NO" << nl
  37. #define yes cout << "YES" << nl
  38. #define siu ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  39. #define ms(x,y) memset(x,y,sizeof(x));
  40. #define pb push_back
  41.  
  42. const ll mod = 1e9 + 7;
  43. const int inf = 1e9;
  44. const int lim = 1e6 + 5;
  45. const int base = 311;
  46. const ll gh = 1005;
  47.  
  48. void file()
  49. {
  50. siu
  51. // #ifdef ONLINE_JUDGE
  52. // freopen("tongnn.INP","r",STdin);
  53. // freopen("tongnn.OUT","w",STdout);
  54. // #endif // ONLINE_JUDGE
  55. #ifndef ONLINE_JUDGE
  56. freopen("ahihi.INP","r",stdin);
  57. freopen("ahihi.OUT","w",stdout);
  58. #endif // ONLINE_JUDGE
  59. }
  60.  
  61. ll n,m,i,j,k,t,kq=0;
  62. ll x,y,z,maxa=-1e9,mina=1e9,l=1,r=1e9;
  63. ll a[lim],f[lim];
  64.  
  65. void solve()
  66. {
  67. cin>>n;
  68. for(i=1;i<=n;i++)
  69. {
  70. cin>>a[i];
  71. a[i]%=5;
  72. if(a[i]==0) a[i]=5;
  73. f[a[i]]++;
  74. }
  75. kq+=(f[1]*(f[1]-1)/2)*f[3];
  76. // cout<<kq<<nl;
  77. kq+=f[1]*(f[2]*(f[2]-1)/2);
  78. // cout<<kq<<nl;
  79. // kq+=f[1]*f[2]*f[3];
  80. // cout<<kq<<nl;
  81. kq+=f[1]*f[4]*f[5];
  82. // cout<<kq<<nl;
  83. kq+=f[2]*f[3]*f[5];
  84. // cout<<kq<<nl;
  85. kq+=f[2]*(f[4]*(f[4]-1)/2);
  86. // cout<<kq<<nl;
  87. kq+=f[4]*(f[3]*(f[3]-1)/2);
  88. // cout<<kq<<nl;
  89. kq+=(f[5]*(f[5]-1)*(f[5]-2))/6;
  90. cout<<kq;
  91. }
  92.  
  93. int main()
  94. {
  95. siu;
  96. // file();
  97. int casemiro=1;
  98. // cin>>casemiro;
  99. while(casemiro--)
  100. {
  101. solve();
  102. }
  103. }
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty