zoukankan      html  css  js  c++  java
  • [AHOI2005]约数研究

    嘟嘟嘟

    暴力啊,统计当前数 i ,对是 i 的倍数的约数的贡献。

     1 #include<cstdio>
     2 #include<iostream>
     3 #include<cmath>
     4 #include<algorithm>
     5 #include<cstring>
     6 #include<cstdlib>
     7 #include<cctype>
     8 #include<vector>
     9 #include<stack>
    10 #include<queue>
    11 using namespace std;
    12 #define enter puts("")
    13 #define space putchar(' ')
    14 #define Mem(a) memset(a, 0, sizeof(a))
    15 typedef long long ll;
    16 typedef double db;
    17 const int INF = 0x3f3f3f3f;
    18 const int eps = 1e-8;
    19 const int maxn = 1e6 + 5;
    20 inline ll read()
    21 {
    22     ll ans = 0;
    23     char ch = getchar(), last = ' ';
    24     while(!isdigit(ch)) {last = ch; ch = getchar();}
    25     while(isdigit(ch)) {ans = ans * 10 + ch - '0'; ch = getchar();}
    26     if(last == '-') ans = -ans;
    27     return ans;
    28 }
    29 inline void write(ll x)
    30 {
    31     if(x < 0) x = -x, putchar('-');
    32     if(x >= 10) write(x / 10);
    33     putchar(x % 10 + '0');
    34 }
    35 
    36 int n, f[maxn];
    37 ll sum = 0;
    38 
    39 int main()
    40 {
    41     n = read(); 
    42     for(int i = 1; i <= n; ++i)
    43     {
    44         for(int j = i; j <= n; j += i) f[j]++;
    45         sum += f[i];
    46     }
    47     write(sum); enter;
    48     return 0;
    49 }
    View Code
  • 相关阅读:
    List集合
    类加载机制
    代码优化
    JVM字节码
    Tomcat优化之Apache Jmeter压力测试工具
    Tomcat优化
    JVM垃圾收集器
    lambda表达式
    java 内部类
    java多线程3种方式
  • 原文地址:https://www.cnblogs.com/mrclr/p/9553447.html
Copyright © 2011-2022 走看看