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.

Use

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 https://codeforces.me/contest/1557/submission/125408355 is so fast even after using doubles.

History

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