码迷,mamicode.com
首页 > 其他好文 > 详细

P1403 [AHOI2005]约数研究

时间:2019-06-05 00:12:11      阅读:94      评论:0      收藏:0      [点我收藏+]

标签:namespace   har   char   代码   mes   数学题   约数   its   names   

技术图片

技术图片

很简单的数学题啦 推一下就知道f(i) = n / i啦

AC代码:

 1 #include<bits/stdc++.h>
 2 #define pi acos(-1)
 3 typedef long long ll;
 4 typedef unsigned long long ull;
 5 using namespace std;
 6 
 7 namespace io {
 8     const int SIZE = 1e7 + 10;
 9     char inbuff[SIZE];
10     char *l, *r;
11     inline void init() {
12         l = inbuff;
13         r = inbuff + fread(inbuff, 1, SIZE, stdin);
14     }
15     inline char gc() {
16         if (l == r) init();
17         return (l != r) ? *(l++) : EOF;
18     }
19     void read(int &x) {
20         x = 0; char ch = gc();
21         while(!isdigit(ch)) ch = gc();
22         while(isdigit(ch)) x = x * 10 + ch - 0, ch = gc();
23     }
24 } using io::read;
25 
26 bool cmp(const int &a, const int &b){
27     return a > b;
28 }
29 
30 int main(){
31     ios::sync_with_stdio(false);
32     int n;
33     cin>>n;
34     int ans = 0;
35     for (int i = 1; i <= n; i++) ans += n / i;
36     cout<<ans<<endl;
37     return 0;
38 }

 

P1403 [AHOI2005]约数研究

标签:namespace   har   char   代码   mes   数学题   约数   its   names   

原文地址:https://www.cnblogs.com/Misuchii/p/10976941.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!