mohitm's blog

By mohitm, history, 22 months ago, In English

Below is the code for a function returing a double value as string whose precision is 15(i.e. no. of digit after decimal should be 15)

Click here to see the execution on ide

#include <bits/stdc++.h>
using namespace std;

string doit(){

    cout<<setprecision(15)<<fixed;

    double val = 4444/21;

    // want to return it as string
    string ans = to_string(val);

    return ans;
}

int main() {

    string ans = doit();
    cout<<ans;
    return 0;
}

output is

211.000000

I want the output to contain 15 digits after decimal and it should be returned by the function and not use print/cout statement inside the function.

Read more »

 
 
 
 
  • Vote: I like it
  • -9
  • Vote: I do not like it

By mohitm, history, 2 years ago, In English

In Codeforces Round #604 (Div. 2) I was able to solve A,B and C problems and I received 1314 rating.

I have given total 3 contest on codeforces.

  • contest 1 — solved only A, rating — 1370 , rank — 5680
  • contest 2 — unable to solve any problem, rating — 1255 , rank — 4168
  • contest 3 — solved A,B and C, rating — 1314, rank — 2165

Despite solving more problems and getting better rank in contest 3 than in contest 1, why my ratings are less than that of contest 1 ? __

Read more »

 
 
 
 
  • Vote: I like it
  • -3
  • Vote: I do not like it

By mohitm, history, 2 years ago, In English

I am new to codeforces, I tried boost library for big integers but it gave me error boost/multiprecision/cpp_int.hpp: No such file or directory Is it not possible to use boost library ?

Read more »

 
 
 
 
  • Vote: I like it
  • +12
  • Vote: I do not like it