fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long int
  4. int main() {
  5. ll t;
  6. cin >> t;
  7. while (t--) {
  8. ll n;
  9. cin >> n;
  10. float ans = 0;
  11. for (ll i = 1; i <= n; i++) {
  12. ans += (1/(i * 1.0));
  13. }
  14. ans *= n;
  15. cout << fixed << setprecision(2) << ans << "\n";
  16. }
  17. }
  18.  
Success #stdin #stdout 0s 4260KB
stdin
2
1
12
stdout
1.00
37.24