ZOJ 3625 Geek's Collection (数学公式,注意long double输出格式,附输出格式总结)
2014-08-28 21:21
411 查看
题目:
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3625
题意:
注意:
1、欧拉常数为$euler=0.57721566490153286060651209$
2、用long double
3、输出方法:两种
总结:
C的printf控制符:
C++的cout控制符:
需要
方法:输出公式结果
$({2.0}^{t}-1.0)\times euler$
代码:
C:
ZOJ 3625 C++
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3625
题意:
注意:
1、欧拉常数为$euler=0.57721566490153286060651209$
2、用long double
3、输出方法:两种
cout << setprecision(12) << setiosflags(ios::scientific) << ret << endl;
printf("%.12Le\n", ret);
总结:
C的printf控制符:
输出long double:%Ld 科学计数法输出long double:%Le 科学计数法输出double:%e
C++的cout控制符:
需要
#include <iomanip>
setprecision(n) 设显示小数精度为n位 setw(n) 设域宽为n个字符 setioflags(ios::fixed) 固定的浮点显示 setioflags(ios::scientific) 指数表示 setiosflags(ios::left) 左对齐 setiosflags(ios::right) 右对齐 setiosflags(ios::skipws 忽略前导空白 setiosflags(ios::uppercase) 16进制数大写输出 setiosflags(ios::lowercase) 16进制小写输出 setiosflags(ios::showpoint) 强制显示小数点 setiosflags(ios::showpos) 强制显示符号
方法:输出公式结果
$({2.0}^{t}-1.0)\times euler$
代码:
C:
/******************************************** *ACM Solutions * *@Title: ZOJ 3625 Geek's Collection *@Version: 1.0 *@Time: 2014-xx-xx *@Solution: http://www.cnblogs.com/xysmlx/p/xxxxxxx.html * *@Author: xysmlx(Lingxiao Ma) *@Blog: http://www.cnblogs.com/xysmlx *@EMail: xysmlx@163.com * *Copyright (C) 2011-2015 xysmlx(Lingxiao Ma) ********************************************/ // #pragma comment(linker, "/STACK:102400000,102400000") #include <cstdio> #include <iostream> #include <cstring> #include <string> #include <cmath> #include <set> #include <list> #include <map> #include <iomanip> #include <iterator> #include <cstdlib> #include <vector> #include <queue> #include <stack> #include <algorithm> #include <functional> using namespace std; typedef long long LL; typedef long double LD; #define pb push_back #define ROUND(x) round(x) #define FLOOR(x) floor(x) #define CEIL(x) ceil(x) const int maxn = 0; const int maxm = 0; const int inf = 0x3f3f3f3f; const LL inf64 = 0x3f3f3f3f3f3f3f3fLL; const double INF = 1e30; const double eps = 1e-6; const int P[4] = {0, 0, -1, 1}; const int Q[4] = {1, -1, 0, 0}; const int PP[8] = { -1, -1, -1, 0, 0, 1, 1, 1}; const int QQ[8] = { -1, 0, 1, -1, 1, -1, 0, 1}; const double euler = 0.57721566490153286060651209; int kase; double x; void init() { kase++; } void input() { // } void debug() { // } void solve() { LD ret = (LD)pow(2.0, x) - (LD)1.0; ret *= (LD)euler; cout << setprecision(12) << setiosflags(ios::scientific) << ret << endl; } void output() { // } int main() { // int size = 256 << 20; // 256MB // char *p = (char *)malloc(size) + size; // __asm__("movl %0, %%esp\n" :: "r"(p)); // std::ios_base::sync_with_stdio(false); #ifdef xysmlx freopen("in.cpp", "r", stdin); #endif kase = 0; while (~scanf("%lf", &x)) { init(); input(); solve(); output(); } return 0; }
ZOJ 3625 C++
相关文章推荐
- ZOJ 2099题解 只要分别把横坐标的的最大小值和纵坐标的最大最小值找到输出就行,注意一下输出格式
- JIURL PE 格式学习总结(二)-- PE文件中的输出函数
- Lucene学习总结之六:Lucene打分公式的数学推导
- hdu 1405 The Last Practice 输出格式需注意
- C语言输出格式总结
- zoj 2106 Tick and Tick(比较好的数学题目,代码特麻烦,注意精度)
- Asp 输出编码为UTF-8格式的XML内容的注意事项
- Lucene学习总结之六:Lucene打分公式的数学推导
- 数学-向量公式总结和一些公式证明
- XeLatex输出数学公式
- printf输出格式总结
- C语言输出格式总结
- C语言输出格式总结
- PHP输出非HTML格式文件总结
- cout 输出格式控制 还是要注意点
- Lucene学习总结之六:Lucene打分公式的数学推导
- Lucene学习总结之六:Lucene打分公式的数学推导
- VC++ 数学公式及格式转欢 math.h、stdlib.h、string.h、float.h
- C语言输出格式总结
- Lucene学习总结之六:Lucene打分公式的数学推导 2014-06-25 14:20 384人阅读 评论(0) 收藏