https://vjudge.net/problem/UVA-10886
计算标准差
碰到这种题将式子展开
#include<cmath> #include<cstdio> //#include<iostream> using namespace std; unsigned long long seed; long double gen() { static const long double Z = ( long double )1.0 / (1LL<<32); seed >>= 16; seed &= ( 1ULL << 32 ) - 1; seed *= seed; return seed * Z; } int main() { int T,n; double xi,xi2,y,x; scanf("%d",&T); for(int t=1;t<=T;t++) { xi=xi2=0; scanf("%d%llu",&n,&seed); //cin>>n>>seed; for(int i=1;i<=n;i++) { y=gen(); xi+=y; xi2+=y*y; } x=xi/n; printf("Case #%d: %.5lf ",t,sqrt((xi2-2*x*xi+n*x*x)/n)); } }