gcd的和
来源:互联网 发布:c 游戏编程基础 编辑:程序博客网 时间:2024/06/17 22:08
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=1e5;
typedef long long ll;
int gcd(int a,int b){
return !b?a:gcd(b,a%b);
}
ll n,ans=0,a[maxn];
int main(){
scanf("%lld",&n);
for(int i=n;i>=1;i--){
//cout<<ans<<endl;
a[i]=(n/i)*(n/i);
for(int j=2;;j++){
if(j*i>n) break;
else a[i]-=a[j*i];
}
ans+=a[i]*i;
}
cout<<ans<<endl;
return 0;
}
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=1e5;
typedef long long ll;
int gcd(int a,int b){
return !b?a:gcd(b,a%b);
}
ll n,ans=0,a[maxn];
int main(){
scanf("%lld",&n);
for(int i=n;i>=1;i--){
//cout<<ans<<endl;
a[i]=(n/i)*(n/i);
for(int j=2;;j++){
if(j*i>n) break;
else a[i]-=a[j*i];
}
ans+=a[i]*i;
}
cout<<ans<<endl;
return 0;
}
阅读全文
0 0
- gcd的和
- GCD和NSOperation的关系
- GCD和NSOperation的比较
- GCD 和 NSOperationQueue 的差别
- GCD的创建和获取
- NSOperationQueue和GCD的区别
- GCD的认识和使用
- GCD和NSOperationQueue的区别
- GCD和NSOperation的区别
- GCD和NSOperation的区别
- NSOperation 和 GCD 的区别
- NSOperation和GCD的原理
- GCD的基本概念和使用
- GCD 和 NSOperation的区别
- GCD and LCM+hdu+利用gcd和lcm的性质
- 有关GCD和LCM的公式
- GCD的串行队列和并行队列
- GCD 的基本概念和Dispatch Queue
- 高额融资「狂欢」背后的旷视科技
- 蚂蚁金服 x 机器之心开发者大赛闭幕,330万元大奖花落「萌宠到家」
- 生成旋律,为作曲家提供最初的灵感,人工智能正在重塑创造音乐的方式
- web提交用户名,密码等数据encodeURIComponent()处理
- spring boot data-jpa 放回null
- gcd的和
- [luogu模拟赛] 11.1
- 金融人士如何建立自己的人脉?
- 输出一个数组第二大的数
- spark 报错ypeError: expected string or Unicode object, NoneType found
- sarpk安装依赖包特别慢的时候
- 11.1 考试 数论+数论+二分
- C++ 数据抽象
- UITabBarController(三)自定义UITabBar方式二