ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1001. Reverse Root

Accepted on C++
Posted by Izobara 2 Oct 2013 14:52
#include <stdio.h>
#include <math.h>
double stack[131073];
int main()
{
    int index = -1;
    while(scanf("%lf", &stack[++index]) != EOF);
    for(; index > 0;printf("%.4lf\n", sqrt(stack[--index])));
    return 0;
}
Re: Accepted on C++
Posted by Cui Xiangfei 29 Oct 2013 09:47
If the digit is negative?
Re: Accepted on C++
Posted by Ouch 29 Oct 2013 19:48
Cui Xiangfei wrote 29 October 2013 09:47
If the digit is negative?
Just use the same method, and append "i" to denote the imaginary number.
Re: Accepted on C++
Posted by WENXIANG LU 4 Nov 2013 10:59
Hi, can this code be accepted?
The input value can be much larger than double value, even long type.
Re: Accepted on C++
Posted by Yuri Pechatnov [Barnaul] 9 Nov 2013 23:15
A strange fact:

[...]
double  b[100000000]; int i = 0;

int main(){
    while (scanf("%lf", &b[i++]) == 1); i--;
    while (i > 0)
        printf("%.4lf\n", sqrt((double)b[--i]));
    return 0;
}

Get AC
BUT:

[...]
long long  b[100000000]; int i = 0;

int main(){
    long long a;
    while (scanf("%lld", &b[i++]) == 1); i--;
    while (i > 0)
        printf("%.4lf\n", sqrt((double)b[--i]));
    return 0;
}

Gets WA 1.
I understand nothing in this life..=) I wonder where may be mistake?

Compiler G++ 4.7.2
Re: Accepted on C++
Posted by Sauron 21 Nov 2013 00:34
Cui Xiangfei wrote 29 October 2013 09:47
If the digit is negative?
lol 0<=A<=10^18 read description :P

Edited by author 21.11.2013 00:35

Edited by author 21.11.2013 00:35
Re: Accepted on C++
Posted by cures 18 May 2014 09:51
Mingw gcc does not recognize %lld, use %I64u.
And now it does not work with %.4lf in printf, only with %.4f (in C++11 mode).
Re: Accepted on C++
Posted by Ping_23 24 May 2014 22:00
Well, it should be double not long long since the output is in real number
Yuri Pechatnov [Barnaul] wrote 9 November 2013 23:15
A strange fact:

[...]
double  b[100000000]; int i = 0;

int main(){
    while (scanf("%lf", &b[i++]) == 1); i--;
    while (i > 0)
        printf("%.4lf\n", sqrt((double)b[--i]));
    return 0;
}

Get AC
BUT:

[...]
long long  b[100000000]; int i = 0;

int main(){
    long long a;
    while (scanf("%lld", &b[i++]) == 1); i--;
    while (i > 0)
        printf("%.4lf\n", sqrt((double)b[--i]));
    return 0;
}

Gets WA 1.
I understand nothing in this life..=) I wonder where may be mistake?

Compiler G++ 4.7.2