read doubles faster in cpp

Revision en1, by dush1729, 2021-08-09 22:39:29

Just wanted to share this after watching many submissions for Ezzat and Two Subsequences TLEing because they used doubles.


string s;
cin >> s;
double x = stod(s);

instead of

double x;
cin >> x;

Found this trick hidden in algo-lib template after we were wondering why is so fast even after using doubles.


  Rev. Lang. By When Δ Comment
en1 English dush1729 2021-08-09 22:39:29 579 Initial revision (published)