zoukankan      html  css  js  c++  java
  • zoj 3625 D

    D - Geek's Collection
    Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu
    Submit Status

    Description

    The word geek is a slang term, with different meanings ranging from "a computer expert or enthusiast" to "a carnival performer who performs sensationally morbid or disgusting acts", with a general pejorative meaning of "a peculiar or otherwise dislikable person, especially one who is perceived to be overly intellectual".

    The definition of geek has changed considerably over time, and there is no longer a definitive meaning. The terms nerd, gimp, dweeb, dork, spod and gump have similar meanings as geek, but many choose to identify different connotations among these terms, although the differences are disputed. In a 2007 interview on The Colbert Report, Richard Clarke said the difference between nerds and geeks is "geeks get it done." Julie Smith defined a geek as "a bright young man turned inward, poorly socialized, who felt so little kinship with his own planet that he routinely traveled to the ones invented by his favorite authors, who thought of that secret, dreamy place his computer took him to as cyberspace somewhere exciting, a place more real than his own life, a land he could conquer, not a drab teenager's room in his parents' house."The definition of geek has changed considerably over time, and there is no longer a definitive meaning. The terms nerd, gimp, dweeb, dork, spod and gump have similar meanings as geek, but many choose to identify different connotations among these terms, although the differences are disputed. In a 2007 interview on The Colbert Report, Richard Clarke said the difference between nerds and geeks is "geeks get it done." Julie Smith defined a geek as "a bright young man turned inward, poorly socialized, who felt so little kinship with his own planet that he routinely traveled to the ones invented by his favorite authors, who thought of that secret, dreamy place his computer took him to as cyberspace somewhere exciting, a place more real than his own life, a land he could conquer, not a drab teenager's room in his parents' house."

    The biggest geek in the world named Alice, she is major in many subject. One day she come to a new planet named wonderland and she find a way to entertain herself by copy herself again and again, she give the cloning the name as Alice1, Alice2, Alice3... Every Alice like collect things in wonderland, recently, the true Alice want to calculate how many collections did her cloning have.

    The number of collections that each cloning have is (1+1/2+1/3+1/4+...+1/n-ln n)*her special number (n tends to infinity), the defination of special number is as follow, for Alice1, her special number is a, for Alice2, her special number is a(a-1)/(1*2), for Alice3, her special number is a(a-1)(a-2)/(1*2*3)... and there are endless cloning Alice. Your task is to help true Alice c啊alculate how many collections did her cloning have.

    Input

    This problem contains multiple test cases. Each case contains only one line with a float number a. (-1 < a < 0 or a > 0)

    Output

    Print exactly one line with the number of total collections, you should output it in scientific notation and retained thirteen significant figures. Because the wonderland is an amazing place so that the number of the collection can be negative number.

    Sample Input

    -0.5
    100
    

    Sample Output-1.690625540426e-01

    7.317077840736e+29

    这题。。。
    先是利用正项无穷级数的知识。。。那个数列的和当n趋近于无穷时趋近于欧拉常数r
    再根据(1+x)y 的展开式。。。
    然后这道题的数据加强了。
    网上能找到的那份AC代码以及适牛以前AC的代码现在都没办法通过了2333


    注意的地方一个是要用long double
    而且要记得将得到long double变量的每一步计算结果强制转化成long double !!!

    大概类似如果变量是long long类型。。。int不强制转化的话有可能爆掉一样。
    不会这个是爆精度。。
    不过还有一个地方我不是很明白:

    //printf("%.12e
    ",ans);
    	cout<<setprecision(12)<<setiosflags(ios::scientific)<<ans<<endl;

    这两种写法有什么区别?注释掉的写法会WA 问了很多人也没有结果。如果有人知道麻烦指教以下,不胜感激。

     
     1 /*************************************************************************
     2     > File Name: code/zoj/3625.cpp
     3     > Author: 111qqz
     4     > Email: rkz2013@126.com
     5     > Created Time: 2015年10月21日 星期三 16时53分36秒
     6  ************************************************************************/
     7 
     8 #include<iostream>
     9 #include<iomanip>
    10 #include<cstdio>
    11 #include<algorithm>
    12 #include<cmath>
    13 #include<cstring>
    14 #include<string>
    15 #include<map>
    16 #include<set>
    17 #include<queue>
    18 #include<vector>
    19 #include<stack>
    20 #include<cctype>
    21 
    22 #define yn hez111qqz
    23 #define j1 cute111qqz
    24 #define ms(a,x) memset(a,x,sizeof(a))
    25 using namespace std;
    26 const int dx4[4]={1,0,0,-1};
    27 const int dy4[4]={0,-1,1,0};
    28 typedef long long LL;
    29 typedef double DB;
    30 const int inf = 0x3f3f3f3f;
    31 const  double r=  0.57721566490153286060651209;
    32   double a;
    33 int main()
    34 {
    35   #ifndef  ONLINE_JUDGE
    36 //   freopen("in.txt","r",stdin);
    37   #endif
    38 
    39 
    40     while (scanf("%lf",&a)!=EOF)
    41     {
    42       long double ans = (long double )pow(2.0,a) - (long double)1.0;
    43       ans = ans * r;
    44     //printf("%.12e
    ",ans);
    45     cout<<setprecision(12)<<setiosflags(ios::scientific)<<ans<<endl;
    46     }
    47 
    48 
    49 
    50  #ifndef ONLINE_JUDGE
    51   fclose(stdin);
    52   #endif
    53     return 0;
    54 }
    View Code
     
  • 相关阅读:
    Android研究之游戏开发处理按键的响应
    C语言指针的初始化和赋值
    Cloudera CDH 5集群搭建(yum 方式)
    未将对象引用设置到对象的实例--可能出现的问题总结
    内存泄漏以及常见的解决方法
    都能看懂的嵌入式linux/android alsa_aplay alsa_amixer命令行使用方法
    Life is hard!
    EasyUI基础入门之Resiable(可缩放)
    Android -- Looper.prepare()和Looper.loop() —深入版
    vi 命令 使用方法
  • 原文地址:https://www.cnblogs.com/111qqz/p/4899976.html
Copyright © 2011-2022 走看看