Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: gay69
Problemset: ผลรวมตัวเลข
Language: cpp
Time: 0.002 second
Submitted On: 2025-07-27 00:06:46
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
ll solve(ll x) {
return 2 * (((x / 2) * (x / 2 + 1)) / 2) + 3 * (((x / 3) * (x / 3 + 1)) / 2) - 6 * (((x / 6) * (x / 6 + 1)) / 2);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
ll l, r;
cin >> l >> r;
cout << solve(r - 1) - solve(l - 1) << "\n";
return 0;
}