fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int N = 1e5 + 9, mod = 998244353;
  5. vector<int> v[2];
  6. int dp[2][N];
  7. int a[N];
  8. int32_t main() {
  9. ios_base::sync_with_stdio(0);
  10. cin.tie(0);
  11. int t; cin >> t;
  12. while (t--) {
  13. int n; cin >> n;
  14. for (int i = 1; i <= n; i++) {
  15. cin >> a[i];
  16. }
  17. long long ans = 0;
  18. for (int i = n; i >= 1; i--) {
  19. int k = i & 1;
  20. v[k].push_back(a[i]);
  21. dp[k][a[i]] = 1;
  22. int last = a[i];
  23. for (auto x: v[k ^ 1]) {
  24. int y = dp[k ^ 1][x];
  25. int split = (a[i] + x - 1) / x;
  26. int st = a[i] / split;
  27. ans += 1LL * (split - 1) * y * i;
  28. dp[k][st] += y;
  29. if (last != st) {
  30. v[k].push_back(st), last = st;
  31. }
  32. }
  33. for (auto x: v[k ^ 1]) dp[k ^ 1][x] = 0;
  34. v[k ^ 1].clear();
  35. ans %= mod;
  36. }
  37. cout << ans << '\n';
  38. for (auto x: v[0]) dp[0][x] = 0;
  39. for (auto x: v[1]) dp[1][x] = 0;
  40. v[0].clear(); v[1].clear();
  41. }
  42. return 0;
  43. }
Success #stdin #stdout 0s 5304KB
stdin
Standard input is empty
stdout
Standard output is empty