标签:+= putc https div sizeof 分享 main iostream 多少
大水题,一分钟就做完了。。。直接枚举1~n就行了,然后在n中判断出现多少次。
题干:
代码:
#include<iostream> #include<cstdio> #include<cmath> #include<ctime> #include<queue> #include<algorithm> #include<cstring> using namespace std; #define duke(i,a,n) for(ll i = a;i <= n;i++) #define lv(i,a,n) for(int i = a;i >= n;i--) #define clean(a) memset(a,0,sizeof(a)) const int INF = 1 << 30; typedef long long ll; typedef double db; template <class T> void read(T &x) { char c; bool op = 0; while(c = getchar(), c < ‘0‘ || c > ‘9‘) if(c == ‘-‘) op = 1; x = c - ‘0‘; while(c = getchar(), c >= ‘0‘ && c <= ‘9‘) x = x * 10 + c - ‘0‘; if(op) x = -x; } template <class T> void write(T x) { if(x < 0) putchar(‘-‘), x = -x; if(x >= 10) write(x / 10); putchar(‘0‘ + x % 10); } ll n,tot = 0; int main() { read(n); duke(i,1,n) { tot += n / i; } write(tot); return 0; }
B1968 [Ahoi2005]COMMON 约数研究 数论
标签:+= putc https div sizeof 分享 main iostream 多少
原文地址:https://www.cnblogs.com/DukeLv/p/9556316.html