BZOJ 1968: [Ahoi2005]COMMON 约数研究 水题
生活随笔
收集整理的這篇文章主要介紹了
BZOJ 1968: [Ahoi2005]COMMON 约数研究 水题
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1968: [Ahoi2005]COMMON 約數(shù)研究
Time Limit: 20 Sec
Memory Limit: 256 MB
題目連接
http://www.lydsy.com/JudgeOnline/problem.php?id=1968
Description
Input
只有一行一個(gè)整數(shù) N(0 < N < 1000000)。
Output
只有一行輸出,為整數(shù)M,即f(1)到f(N)的累加和
Sample Input
3
Sample Output
5
HINT
?
題意
?
題解:
直接ans+=n/i就好了
表示這個(gè)數(shù)對(duì)整體的貢獻(xiàn)值是多少
代碼:
//qscqesze #include <cstdio> #include <cmath> #include <cstring> #include <ctime> #include <iostream> #include <algorithm> #include <set> #include <bitset> #include <vector> #include <sstream> #include <queue> #include <typeinfo> #include <fstream> #include <map> #include <stack> typedef long long ll; using namespace std; //freopen("D.in","r",stdin); //freopen("D.out","w",stdout); #define sspeed ios_base::sync_with_stdio(0);cin.tie(0) #define maxn 200051 #define mod 10007 #define eps 1e-9 int Num; //const int inf=0x7fffffff; //нчоч╢С const int inf=0x3f3f3f3f; inline ll read() {ll x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f; } //**************************************************************************************int main() {int n=read();ll ans=0;for(int i=1;i<=n;i++)ans+=n/i;cout<<ans<<endl; }?
轉(zhuǎn)載于:https://www.cnblogs.com/qscqesze/p/4770827.html
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的BZOJ 1968: [Ahoi2005]COMMON 约数研究 水题的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: POJ - 2018 二分+单调子段和
- 下一篇: 最短路--DijkstraFloyedS