Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
34638 沈仲恩 【S】T1 C++ 通过 100 0 MS 256 KB 830 2024-11-12 13:57:12

Tests(11/11):


// 前两发被逆天极限数据叉了,强烈谴责低素质hacker! #include <bits/stdc++.h> #define int long long using namespace std; const int mod = 1e9 + 7, m2 = 500000004; inline int calc(int x) { int l = sqrt(x), r = sqrt(x) + 1; l *= l, r *= r; int mid = ((l + r) >> 1); int res = 0; if (mid < x) { res -= (mid + 1 + x) % mod * (x - mid) % mod * m2 % mod; res += mod; res %= mod; res += (l + mid) % mod * (mid - l + 1) % mod * m2 % mod; } else { res += (l + x) % mod * (x - l + 1) % mod * m2 % mod; } return (int)sqrt(l) % 2 == 0 ? (-res + 2 * mod) % mod : res; } signed main() { int l, r; scanf("%lld %lld", &l, &r); printf("%lld\n", (calc(r) - calc(l - 1) + 2 * mod) % mod); return 0; }


测评信息: