Advertisement
varun1729

Untitled

Apr 19th, 2023
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. using ll = long long;
  5. using ld = long double;
  6.  
  7. ll MOD = 1000000007;
  8. const int SINF = 1000000009;
  9. const ll INF = 1000000000000000018;
  10.  
  11. #define MAXN 100001
  12. #define nl "\n"
  13. #define nlf "\n", cout.flush()
  14. #define inv(a) powr((a), (MOD - 2))
  15. #define all(c) (c).begin(),(c).end()
  16. #define gfor(t) rep(_, 1, (t) + 1)
  17. #define caseprint cout << "Case #" << _ << ": ";
  18. #define rep(i,a,b) for(ll i = (a); i < (b); i ++)
  19. #define prec(n) cout << fixed << setprecision(n)
  20. #define PI 3.14159265358979323846264338327951
  21. #define ifalse ios_base::sync_with_stdio(false), cin.tie(NULL)
  22.  
  23. template<typename T> void toInt(string s, T &a) { istringstream(s) >> a; }
  24. ll gcd(ll a, ll b) { ll t; while(a) { t = a; a = b%a; b = t; } return b; }
  25. ll sub(ll a, ll b) { a -= b; a = (a + MOD) % MOD; return a; }
  26. ll mul(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }
  27. ll add(ll a, ll b) { a += b; a %= MOD; return a; }
  28. ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
  29.  
  30. ll powr(ll a, ll b) {
  31. ll x = 1LL;
  32. while(b) {
  33. if(b & 1) x = mul(x, a);
  34. a = mul(a, a), b >>= 1;
  35. }
  36. return x%MOD;
  37. }
  38.  
  39. template <typename T, typename U, typename V> class triple {
  40. public:
  41. T first;
  42. U second;
  43. V third;
  44. triple() {}
  45. triple(T a, U b, V c) : first(a), second(b), third(c) {}
  46. };
  47. using tlll = triple<ll, ll, ll>;
  48.  
  49. // #define PRM
  50. #ifdef PRM
  51. vector<int> primes;
  52. bitset<MAXN> isprm;
  53. vector<int> spf(MAXN);
  54.  
  55. void sieve(){
  56. for(int i = 0;i < MAXN; ++i){
  57. spf[i] = -1;
  58. }
  59. spf[0] = 0;
  60. spf[1] = 1;
  61. spf[2] = 2;
  62. for(int i = 4;i < MAXN; i += 2) isprm[i] = 1, spf[i] = 2;
  63. primes.push_back(2);
  64. isprm[0] = isprm[1] = 1;
  65. for(int i = 3;i < MAXN; i += 2){
  66. if(isprm[i]) continue;
  67. spf[i] = i;
  68. primes.push_back(i);
  69. for(int j = 2*i;j < MAXN; j += i){
  70. if(spf[j] == -1) spf[j] = i;
  71. isprm[j] = 1;
  72. }
  73. }
  74. }
  75. #endif
  76.  
  77. void solve() {
  78. ll l,r;
  79. cin>>l>>r;
  80. ll ans=0;
  81. ll sum=0;
  82. vector<ll> v(r+1,0);
  83. int k=1;
  84. for(int j=1;j<=r;j+=2)
  85. {
  86. k=1;
  87. while(j*k <= r )
  88. {
  89. v[j*k]+=j;
  90. k++;
  91. }
  92. }
  93.  
  94.  
  95. for(int i=l;i<=r;i++) sum+=v[i];
  96. cout<<sum<<endl;
  97.  
  98. }
  99.  
  100. int main(){
  101. ifalse;
  102.  
  103. int t = 0;
  104. if(!t) cin >> t;
  105. gfor(t){
  106. // caseprint;
  107. solve();
  108. }
  109. return 0;
  110. }
  111.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement