zoukankan      html  css  js  c++  java
  • HDU 5879 Cure

    打表,预处理。

    因为只要保留$5$位小数,所以$n$大于某个数字的时候,答案都是一样的,通过寻找可以发现$n$大约为$2000000$。读入的时候需要用字符串。

    #pragma comment(linker, "/STACK:1024000000,1024000000")
    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<algorithm>
    #include<vector>
    #include<map>
    #include<set>
    #include<queue>
    #include<stack>
    #include<iostream>
    using namespace std;
    typedef long long LL;
    const double pi=acos(-1.0),eps=1e-6;
    void File()
    {
        freopen("D:\in.txt","r",stdin);
        freopen("D:\out.txt","w",stdout);
    }
    template <class T>
    inline void read(T &x)
    {
        char c=getchar(); x=0;
        while(!isdigit(c)) c=getchar();
        while(isdigit(c)) {x=x*10+c-'0'; c=getchar();}
    }
    
    const int maxn=2000010;
    double a[maxn];
    char s[10000010];
    
    int get()
    {
        int res=0;
        for(int i=0;s[i];i++)
            res=res*10+s[i]-'0';
        return res;
    }
    
    int main()
    {
        for(int i=1;i<=2000000;i++)
            a[i]=a[i-1]+1.0/((double)i*(double)i);
        while(~scanf("%s",s))
        {
            int len=strlen(s);
            if(len>7) printf("%.5lf
    ",a[2000000]);
            else
            {
                int n=get();
                if(n>=2000000) n=2000000;
                printf("%.5lf
    ",a[n]);
            }
        }
        return 0;
    }
  • 相关阅读:
    H.264编码之DCT变换原理
    颜色空间转换
    jdbc 大数据存储 图片读取
    spring 事务配置
    Cglib代理
    jdk代理
    spring装配bean
    map 常用方法
    list map set常用方法之list
    calendar 类 用法
  • 原文地址:https://www.cnblogs.com/zufezzt/p/5887008.html
Copyright © 2011-2022 走看看