BZOJ 2005 [Noi2010]能量采集
来源:互联网 发布:微单 人像 知乎 编辑:程序博客网 时间:2024/05/16 08:22
以前只会利用容斥原理找gcd(x,y)=k的解法,今天看了这篇博客又涨姿势了...
/************************************************************** Problem: 2005 User: too_weak Language: C++ Result: Accepted Time:48 ms Memory:1588 kb****************************************************************/ #include <cstdio>#include <algorithm>using namespace std;const int maxn =100005;typedef long long LL ;LL f[maxn];///f[i]表示满足gcd(x,y)=i的对数int main(){ int n,m; scanf("%d%d",&n,&m); LL t=min(n,m); LL ans=0; for(int i=t;i;i--){ f[i]=(LL)(m/i)*(n/i); for(int j=i+i;j<maxn;j+=i) f[i]-=f[j]; ans+=f[i]*(2*i-1); } printf("%lld\n",ans); return 0;}
- BZOJ 2005 [Noi2010]能量采集
- BZOJ 2005: [Noi2010]能量采集
- bzoj 2005: [Noi2010] 能量采集
- bzoj 2005: [Noi2010]能量采集
- 能量采集 [Bzoj 2005,Noi2010]
- 【BZOJ】2005 [Noi2010]能量采集
- BZOJ 2005: [Noi2010]能量采集
- 【bzoj 2005】[Noi2010]能量采集
- BZOJ 2005: [Noi2010]能量采集
- BZOJ 2005 [Noi2010]能量采集
- BZOJ[Noi2010]能量采集
- BZOJ系列2005《[Noi2010]能量采集》题解
- bzoj 2005 [Noi2010]能量采集 数学
- BZOJ 2005 [Noi2010]能量采集 (容斥)
- BZOJ 2005([Noi2010]能量采集-数论)
- 2005: [Noi2010]能量采集
- 2005: [Noi2010]能量采集
- BZOJ 2005 NOI2010 能量采集 数论+容斥原理
- 5 Shell Scripts for Linux Newbies to Learn Shell Programming – Part II
- Linux netstat命令详解
- ZOJ - 1119 SPF
- linux中的用户和用户组
- uva 644 Immediate Decodability
- BZOJ 2005 [Noi2010]能量采集
- c语言 外部函数
- 设计模式之——工厂模式(简单工厂模式1)
- Linux GCC常用命令
- 关于银行调度的学习
- Node.js编程时fs.renameSync出错
- undefined reference to `vtable for TEXT1'
- Linux tcpdump命令详解
- 指针转换