Codeforces Round #520 (Div. 2) D. Fun with Integers(数学+规律)

题目链接
在这里插入图片描述
思路:对于一个因子a和它的合数b来说,他们其实可以存在循环的,所以枚举因子乘4就是答案了。

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,ans;
int main()
{
	scanf("%lld",&n);
	for(ll i=2;i<=n;++i)
	for(ll j=2*i;j<=n;j+=i)
	ans+=4*(j/i);
	printf("%lld\n",ans);
}
发布了171 篇原创文章 · 获赞 0 · 访问量 5772

猜你喜欢

转载自blog.csdn.net/qq_42479630/article/details/104683762