1. 程式人生 > >P2393 yyy loves Maths II

P2393 yyy loves Maths II

putchar ++ 誤差 logs open include can space color

P2393 yyy loves Maths II
long double
比如保留5位小數
*1000000都變成整數
最後再/1000000避免精度誤差
scanf("%Lf",&x);
printf("%.Lf",x);

#include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstring>
#define inf 2147483647
#define For(i,a,b) for(register int i=a;i<=b;i++)
#define
p(a) putchar(a) #define g() getchar() //by war //2017.10.21 using namespace std; long double sum,x,t=1000000; void in(int &x) { int y=1; char c=g();x=0; while(c<0||c>9) { if(c==-) y=-1; c=g(); } while(c<=9&&c>=0)x=x*10+c-0,c=g(); x*=y; } void
o(int x) { if(x<0) { p(-); x=-x; } if(x>9)o(x/10); p(x%10+0); } int main() { // freopen("t.in","r",stdin); // freopen("t.out","w",stdout); while(scanf("%LF",&x)!=EOF) sum+=x*t; printf("%.5LF",sum/t); return 0; }

P2393 yyy loves Maths II