难题
难题
题意
定义
思路
显然
若
可以枚举
化简一下可以得到:
代码
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e6 + 5;
const int mod = 1e9 + 7;
signed main() {
freopen("math.in", "r", stdin);
freopen("math.out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int T; cin >> T;
while (T --) {
int n, ans, l = 1; cin >> n;
ans = 2 * n % mod;
for (int i = 2; ; i ++) {
l = lcm(l, i);
ans += (n / l), ans %= mod;
if (l > n) break;
}
cout << ans << "\n";
}
return 0;
}
本文来自博客园,作者:maniubi,转载请注明原文链接:https://www.cnblogs.com/maniubi/p/18526240,orz
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】