fork download
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #ifdef LOCAL
  6. #include "algo/debug.h"
  7. #else
  8. #define debug(...) 42
  9. #endif
  10.  
  11. template<class X, class Y>bool maximize(X &x, const Y &y){if(x < y) return x = y, true; return false;}
  12. template<class X, class Y>bool minimize(X &x, const Y &y){if(x > y) return x = y, true; return false;}
  13.  
  14. #define ll long long
  15. #define fi first
  16. #define se second
  17. #define pb push_back
  18. #define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; i++)
  19. #define FORD(i, b, a) for(int i = (b), _a = (a); i >= _a; i--)
  20. #define REP(i, n) for(int i = 0, _n = (n); i < _n; i++)
  21. #define C make_pair
  22. #define MASK(i) (1LL << (i))
  23. #define TURN_ON(i, x) ((x) | MASK(i))
  24. #define TURN_OFF(i, x) ((x) & ~MASK(i))
  25. #define CNT(x) (__builtin_popcountll(x))
  26. #define get_bit(i, x) ((x) & MASK(i))
  27. #define REV(i, x) ((x) ^ MASK(i))
  28.  
  29. const ll mod = 1e9 + 7;
  30. const ll INF = 1e15;
  31. const int maxn = 1e5 + 5;
  32. typedef pair<int, int> pi;
  33. typedef pair<int, pair<int,int>> pii;
  34. typedef pair<ll, ll> pl;
  35. typedef pair<ll, pair<ll,ll>>pll;
  36.  
  37. const int MAXN = (int)1e5 + 5;
  38.  
  39. int n, a[MAXN], b[40], cnt[30][30];
  40. ll ans;
  41.  
  42. void nhap(){
  43. cin >> n;
  44. FOR(i, 1, n) cin >> a[i];
  45. }
  46. void process(){
  47. ll mn1 = INT_MAX, mn2 = INT_MAX, cnt1 = 0, cnt2 = 0;
  48. FOR(i, 1, n){
  49. if(b[i]) cnt2++;
  50. else cnt1++;
  51. }
  52. if(!cnt1 || !cnt2) return;
  53. FOR(i, 1, n){
  54. if(b[i]) minimize(mn2, a[i]);
  55. else minimize(mn1, a[i]);
  56. }
  57. cnt[mn1][mn2]++;
  58. ans = (ans + mn1 * mn2 % mod) % mod;
  59. }
  60. void BackTrack(int i){
  61. REP(j, 2){
  62. b[i] = j;
  63. if(i == n) process();
  64. else BackTrack(i + 1);
  65. }
  66. }
  67. void solve(){
  68. BackTrack(1);
  69. cout << ans;
  70. FOR(i, 3, 11) cout << cnt[2][i] << '\n';
  71. }
  72. int main(){
  73. //freopen("DIVTEAMS.INP", "r", stdin);
  74. //freopen("DIVTEAMS.OUT", "w", stdout);
  75. ios_base::sync_with_stdio(0);
  76. cin.tie(0); cout.tie(0);
  77. nhap();
  78. solve();
  79. return 0;
  80. }
  81.  
Success #stdin #stdout 0.01s 5288KB
stdin
11
7 3 9 4 2 5 6 10 11 8 39
stdout
16436512
256
128
64
32
16
8
4
2