↓ 跳过正文
  1. Posts/

zoj 3625 D - Geek's Collection(正项无穷级数,麦克劳林展开式,2015年10月AC)

·977 字·2 分钟

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)/(12), for Alice3, her special number is a(a-1)(a-2)/(123)… 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

相关说明图片在 WordPress 迁移后已丢失,待恢复。

ZOJ 3625 D · 公式推导示意

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

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

//printf("%.12en",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))
25using namespace std;
26const int dx4[4]={1,0,0,-1};
27const int dy4[4]={0,-1,1,0};
28typedef long long LL;
29typedef double DB;
30const int inf = 0x3f3f3f3f;
31const  double r=  0.57721566490153286060651209;
32double a;
33int main()
34{
35#ifndef  ONLINE_JUDGE
36//   freopen("in.txt","r",stdin);
37#endif
38
39while (scanf("%lf",&a)!=EOF)
40{
41long double ans = (long double )pow(2.0,a) - (long double)1.0;
42ans = ans * r;
43//printf("%.12en",ans);
44cout<<setprecision(12)<<setiosflags(ios::scientific)<<ans<<endl;
45}
46
47#ifndef ONLINE_JUDGE
48fclose(stdin);
49#endif
50return 0;
51}

相关文章

codeforces 569 D. Symmetric and Transitive (组合数学 第二类斯特林数 贝尔数)

D. Symmetric and Transitive time limit per test 1.5 seconds memory limit per test 256 megabytes input standard input output standard output Little Johnny has recently learned about set theory. Now he is studying binary relations. You’ve probably heard the term “equivalence relation”. These relations are very important in many areas of mathematics. For example, the equality of the two numbers is an equivalence relation.

斯特林数

·1 字·1 分钟
http://baike.baidu.com/link?url=nsN1-rcs3Gs0jNurWLSDk6AJ9jmhl_3pfkQmYK7vZoe7BsoTij48Si3It9XeNM4uA7gST-1ITQsAx0bv5si9_q

贝尔数(集合的划分数目)

·790 字·2 分钟
http://baike.baidu.com/link?url=kw5Kxe3nSvRJR0TpJUpMrORcQL8fyZFpJlT9_o0RlGYOy0bKFobabPPSj3LxGfy7o1qGVycrYK4Iags3hMFq0a 在组合数合里,贝尔数给出了集合划分的数目,以数学家埃里克·坦普尔·贝尔(Eric Temple Bell)命名,是组合数学中的一组整数数列。[1] 以B0= B1=1为始, 首几项的贝尔数为:1, 1, 2, 5, 15, 52, 203, 877, 4140, 21147, 115975, …(OEIS的A000110数列)