Tình hình là mùa ôn luyện Olympic Tin Học lại khởi động rùi! Anh em cũng thảo luận và giải bài luyện thi nào :haha:
Đầu tiên sẽ là bài này nhé!
http://acm.timus.ru/problem.aspx?space=1&num=1001
Bài đó không khó nhưng hãy cẩn thận đấy! Mình đã bị Memory limit exceeded với code sau :amazed: Anh em ai bik giải thích mình tại sao cái nhé?? Hix memory used > 20MB lun mới ghê
(
Đầu tiên sẽ là bài này nhé!

http://acm.timus.ru/problem.aspx?space=1&num=1001
Bài đó không khó nhưng hãy cẩn thận đấy! Mình đã bị Memory limit exceeded với code sau :amazed: Anh em ai bik giải thích mình tại sao cái nhé?? Hix memory used > 20MB lun mới ghê

Code:
#include <iostream> #include <math.h> #include <iomanip> #include <string> #include <sstream> using namespace std; string d2s(double x) { stringstream ii; ii << fixed << setprecision(4) << x; return ii.str(); } int main( ) { double n; string s = ""; while ((cin >> n)) { s = d2s(sqrt(n)) + "\n" + s; } cout << s; //system("pause"); return 0; }
Comment