/*1001. Reverse Root
Time limit: 2.0 second
Memory limit: 64 MB
The problem is so easy, that the authors were lazy to write a statement for it!
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.
Sample
input:
1427 0 876652098643267843 5276538
output:
2297.0716
936297014.1164
0.0000
37.7757*/
#include <iostream>
#include <string.h>
#include <vector>
#include <math.h>
using namespace std;
int main(int argc, const char * argv[]) {
char str[19];
char a = getchar();
int count = 0;
int countspace = 0;
int numcount = 0;
vector <double> nums;
while (a != '\n'){
if(a != ' '){
countspace = 0;
str[count] = a;
count = count + 1;
if(count > 18){
cout<<"the num is too large"<<endl;
break;
}
}else{
if(countspace == 0){
double tempnum = 0;
for(int i = 0;i<count;i++){
tempnum = tempnum + pow(10,count-i-1)*(str[i]-'0');
}
if(count > 0){
nums.insert(nums.begin(), tempnum);
numcount =numcount + 1;
}
countspace = countspace + 1;
count = 0;
}else{
countspace = countspace + 1;
}
}
a = getchar();
}
double tnum = 0;
for(int i = 0;i<count;i++){
tnum = tnum + pow(10,count-i-1)*(str[i]-'0');
}
if(count > 0){
nums.insert(nums.begin(), tnum);
numcount =numcount + 1;
}
for(int i = 0 ; i < nums.size() ; i++){
double d = sqrt(nums[i]);
printf("%.4f\n", d);
}
return 0;
}
Time limit: 2.0 second
Memory limit: 64 MB
The problem is so easy, that the authors were lazy to write a statement for it!
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.
Sample
input:
1427 0 876652098643267843 5276538
output:
2297.0716
936297014.1164
0.0000
37.7757*/
#include <iostream>
#include <string.h>
#include <vector>
#include <math.h>
using namespace std;
int main(int argc, const char * argv[]) {
char str[19];
char a = getchar();
int count = 0;
int countspace = 0;
int numcount = 0;
vector <double> nums;
while (a != '\n'){
if(a != ' '){
countspace = 0;
str[count] = a;
count = count + 1;
if(count > 18){
cout<<"the num is too large"<<endl;
break;
}
}else{
if(countspace == 0){
double tempnum = 0;
for(int i = 0;i<count;i++){
tempnum = tempnum + pow(10,count-i-1)*(str[i]-'0');
}
if(count > 0){
nums.insert(nums.begin(), tempnum);
numcount =numcount + 1;
}
countspace = countspace + 1;
count = 0;
}else{
countspace = countspace + 1;
}
}
a = getchar();
}
double tnum = 0;
for(int i = 0;i<count;i++){
tnum = tnum + pow(10,count-i-1)*(str[i]-'0');
}
if(count > 0){
nums.insert(nums.begin(), tnum);
numcount =numcount + 1;
}
for(int i = 0 ; i < nums.size() ; i++){
double d = sqrt(nums[i]);
printf("%.4f\n", d);
}
return 0;
}