Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 29th, 2012  |  syntax: C++  |  size: 0.22 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <stdio.h>
  2. int main()
  3. {
  4.     int i,t,n;
  5.     double a,b;
  6.     scanf("%d",&t);
  7.     while(t--){scanf("%d",&n);for(b=1.0,i=2;i<=n;i++,b=a) a=b+n/(double)(n-i+1);printf("%.2lf\n",n==1 ? b : a);}
  8.     return 0;
  9. }