fork download
  1. /*----<Bồ tác phù hộ code không bị bug>--------
  2.   _oo0oo_
  3.   o8888888o
  4.   88" . "88
  5.   (| -_- |)
  6.   0\ = /0
  7.   ___/`---'\___
  8.   .' \| |// '.
  9.   / \||| : |||// \
  10.   / _||||| -:- |||||- \
  11.   | | \ - /// | |
  12.   | \_| ''\---/'' |_/ |
  13.   \ .-\__ '-' ___/-. /
  14.   ___'. .' /--.--\ `. .'___
  15.   ."" '< `.___\_<|>_/___.' >' "".
  16.  | | : `- \`.;`\ _ /`;.`/ - ` : | |
  17.  \ \ `_. \_ __\ /__ _/ .-` / /
  18. =====`-.____`.___ \_____/___.-`___.-'=====
  19.   `=---='
  20. ------------------<>-------------------------*/
  21.  
  22. #include <bits/stdc++.h>
  23.  
  24. #define int long long
  25. #define fi first
  26. #define se second
  27. #define all(x) x.begin(), x.end()
  28. #define rall(x) x.rbegin(), x.rend()
  29. #define fr(x, l, r) for (int x = l; x < r; x++)
  30. #define frr(x, l, r) for (int x = l; x <= r; x++)
  31. #define fd(x, l, r) for (int x = l; x >= r; x--)
  32. #define cs const
  33. #define TIME (1.0*clock() / CLOCKS_PER_SEC)
  34. #define RUNTIME cerr << "\n" << "Runtime: " << TIME << "s\n";
  35. #define Fastio ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  36.  
  37. typedef double db;
  38. typedef std::string str;
  39. typedef std::vector<int> vi;
  40. typedef std::greater<int> gi;
  41. typedef std::map<int, int> mii;
  42. typedef std::pair<int, int> ii;
  43.  
  44. cs int N = 1e6 + 5;
  45. cs int oo = 1e18;
  46.  
  47. using namespace std;
  48.  
  49. signed main(){
  50. Fastio;
  51. int n; cin >> n;
  52. int a[n];
  53. int chan = 0, le = 0;
  54. fr(i,0,n){
  55. cin >> a[i];
  56. if (a[i] % 2 == 0) ++chan;
  57. else ++le;
  58. }
  59. int sum = chan * (chan - 1)/2;
  60. int tong = le * (le - 1)/2;
  61. cout << sum + tong;
  62. RUNTIME;
  63. return 0;
  64. }
Success #stdin #stdout #stderr 0.04s 5220KB
stdin
Standard input is empty
stdout
8814815866748
stderr
Runtime: 0.037473s