HDU 1012 u Calculate e
题解:直接模拟
#include <cstdio> int main(){ puts("n e");puts("- -----------");puts("0 1"); double ans=1.0,f=1.0; for(int i=1;i<=9;i++){ if(i==1)printf("%d %.0lf\n",i,(ans+=(f/=(double)i))); else if(i==2)printf("%d %.1lf\n",i,(ans+=(f/=(double)i))); else printf("%d %.9lf\n",i,(ans+=(f/=(double)i))); }return 0; }
愿你出走半生,归来仍是少年