Skip to main content
Code Review

Return to Question

Tweeted twitter.com/#!/StackCodeReview/status/558223641721458688
deleted 20 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

The problem statement can be found here.

Description (short):

Input The

The input stream contains a set of integer numbers Ai \$A_i\$(0 ≤ Ai ≤ 1018\0ドル \le A_i \le 10^{18}\$). The numbers are separated by any number of spaces and line breaks. A size of the input stream does not exceed 256 KB.

Output For

For each number Ai\$A_i\$ from the last one tilluntil the first one, you should output its square root. Each square root should be printed in a separate line with at least four digits after the decimal point.

#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main()
{
 double t;
 double v [128 * 1024];
 int idx = 0;
 while (cin >> t) {
 v[idx] = sqrt(t);
 ++idx;
 }
 cout << fixed;
 cout << setprecision(4);
 for (int i = idx - 1; i >= 0; --i)
 cout << v[i] << endl;
 return 0;
}

I am encountering a TLE on test case 9, with an execution time of 2.031s and memory usage of 1 474 KB. (The allowable limits are 2.0s and 64 MB.) How can I improve (or change) my method to complete the problem successfully?

The problem statement can be found here.

Description (short):

Input The input stream contains a set of integer numbers Ai (0 ≤ Ai ≤ 1018). The numbers are separated by any number of spaces and line breaks. A size of the input stream does not exceed 256 KB.

Output For each number Ai from the last one till the first one you should output its square root. Each square root should be printed in a separate line with at least four digits after decimal point.

#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main()
{
 double t;
 double v [128 * 1024];
 int idx = 0;
 while (cin >> t) {
 v[idx] = sqrt(t);
 ++idx;
 }
 cout << fixed;
 cout << setprecision(4);
 for (int i = idx - 1; i >= 0; --i)
 cout << v[i] << endl;
 return 0;
}

I am encountering a TLE on test case 9, with an execution time of 2.031s and memory usage of 1 474 KB. (The allowable limits are 2.0s and 64 MB.) How can I improve (or change) my method to complete the problem successfully?

The problem statement can be found here.

Description (short):

Input

The input stream contains a set of integer numbers \$A_i\$(\0ドル \le A_i \le 10^{18}\$). The numbers are separated by any number of spaces and line breaks. A size of the input stream does not exceed 256 KB.

Output

For each number \$A_i\$ from the last one until the first one, you should output its square root. Each square root should be printed in a separate line with at least four digits after the decimal point.

#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main()
{
 double t;
 double v [128 * 1024];
 int idx = 0;
 while (cin >> t) {
 v[idx] = sqrt(t);
 ++idx;
 }
 cout << fixed;
 cout << setprecision(4);
 for (int i = idx - 1; i >= 0; --i)
 cout << v[i] << endl;
 return 0;
}

I am encountering a TLE on test case 9, with an execution time of 2.031s and memory usage of 1 474 KB. (The allowable limits are 2.0s and 64 MB.) How can I improve (or change) my method to complete the problem successfully?

added 89 characters in body
Source Link
200_success
  • 145.6k
  • 22
  • 190
  • 479

The problem statement can be found here.

Description (short):

Input The input stream contains a set of integer numbers AiAi (0 ≤ AiAi10181018). The numbers are separated by any number of spaces and line breaks. A size of the input stream does not exceed 256 KB.

Output For each number AiAi from the last one till the first one you should output its square root. Each square root should be printed in a separate line with at least four digits after decimal point.

#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main()
{
 double t;
 double v [128 * 1024];
 int idx = 0;
 while (cin >> t) {
 v[idx] = sqrt(t);
 ++idx;
 }
 cout << fixed;
 cout << setprecision(4);
 for (int i = idx - 1; i >= 0; --i)
 cout << v[i] << endl;
 return 0;
}

I am encountering a TLE on test case 9, with an execution time of 2.031s and memory usage of 1 474 474 KB. How (The allowable limits are 2.0s and 64 MB.) How can I improve (or change) my method to complete the problem successfully?

The problem statement can be found here.

Description (short):

Input The input stream contains a set of integer numbers Ai (0 ≤ Ai1018). The numbers are separated by any number of spaces and line breaks. A size of the input stream does not exceed 256 KB.

Output For each number Ai from the last one till the first one you should output its square root. Each square root should be printed in a separate line with at least four digits after decimal point.

#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main()
{
 double t;
 double v [128 * 1024];
 int idx = 0;
 while (cin >> t) {
 v[idx] = sqrt(t);
 ++idx;
 }
 cout << fixed;
 cout << setprecision(4);
 for (int i = idx - 1; i >= 0; --i)
 cout << v[i] << endl;
 return 0;
}

I am encountering a TLE on test case 9, with an execution time of 2.031s and memory usage of 1 474 KB. How can I improve (or change) my method to complete the problem successfully?

The problem statement can be found here.

Description (short):

Input The input stream contains a set of integer numbers Ai (0 ≤ Ai1018). The numbers are separated by any number of spaces and line breaks. A size of the input stream does not exceed 256 KB.

Output For each number Ai from the last one till the first one you should output its square root. Each square root should be printed in a separate line with at least four digits after decimal point.

#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main()
{
 double t;
 double v [128 * 1024];
 int idx = 0;
 while (cin >> t) {
 v[idx] = sqrt(t);
 ++idx;
 }
 cout << fixed;
 cout << setprecision(4);
 for (int i = idx - 1; i >= 0; --i)
 cout << v[i] << endl;
 return 0;
}

I am encountering a TLE on test case 9, with an execution time of 2.031s and memory usage of 1 474 KB. (The allowable limits are 2.0s and 64 MB.) How can I improve (or change) my method to complete the problem successfully?

added problem statement
Source Link
manan
  • 163
  • 6

The problem statement can be found here.

Description (short):

Input The input stream contains a set of integer numbers Ai (0 ≤ Ai ≤ 1018). The numbers are separated by any number of spaces and line breaks. A size of the input stream does not exceed 256 KB.

Output For each number Ai from the last one till the first one you should output its square root. Each square root should be printed in a separate line with at least four digits after decimal point.

#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main()
{
 double t;
 double v [128 * 1024];
 int idx = 0;
 while (cin >> t) {
 v[idx] = sqrt(t);
 ++idx;
 }
 cout << fixed;
 cout << setprecision(4);
 for (int i = idx - 1; i >= 0; --i)
 cout << v[i] << endl;
 return 0;
}

I am encountering a TLE on test case 9, with an execution time of 2.031s and memory usage of 1 474 KB. How can I improve (or change) my method to complete the problem successfully?

The problem statement can be found here.

#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main()
{
 double t;
 double v [128 * 1024];
 int idx = 0;
 while (cin >> t) {
 v[idx] = sqrt(t);
 ++idx;
 }
 cout << fixed;
 cout << setprecision(4);
 for (int i = idx - 1; i >= 0; --i)
 cout << v[i] << endl;
 return 0;
}

I am encountering a TLE on test case 9, with an execution time of 2.031s and memory usage of 1 474 KB. How can I improve (or change) my method to complete the problem successfully?

The problem statement can be found here.

Description (short):

Input The input stream contains a set of integer numbers Ai (0 ≤ Ai ≤ 1018). The numbers are separated by any number of spaces and line breaks. A size of the input stream does not exceed 256 KB.

Output For each number Ai from the last one till the first one you should output its square root. Each square root should be printed in a separate line with at least four digits after decimal point.

#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main()
{
 double t;
 double v [128 * 1024];
 int idx = 0;
 while (cin >> t) {
 v[idx] = sqrt(t);
 ++idx;
 }
 cout << fixed;
 cout << setprecision(4);
 for (int i = idx - 1; i >= 0; --i)
 cout << v[i] << endl;
 return 0;
}

I am encountering a TLE on test case 9, with an execution time of 2.031s and memory usage of 1 474 KB. How can I improve (or change) my method to complete the problem successfully?

deleted 32 characters in body; edited tags; edited title
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238
Loading
Source Link
manan
  • 163
  • 6
Loading
lang-cpp

AltStyle によって変換されたページ (->オリジナル) /