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

Pages: 1 2 Next
уточнение задачи
Posted by JavaClass 17 Feb 2016 00:28
Числа разделяются только по пробелам или по переводам строк тоже? Кто нибудь подскажите?
Re: уточнение задачи
Posted by ToadMonster 17 Feb 2016 14:54
Task description: The numbers are separated by any number of spaces and line breaks.
Can it mean "by spaces only"?
Re: уточнение задачи
Posted by JavaClass 17 Feb 2016 17:02
No, but how can I know end of input? Explain please
Re: уточнение задачи
Posted by Jane Soboleva (SumNU) 17 Feb 2016 17:41
Use hasNext or hasNextLong, if using scanner...
http://www.tutorialspoint.com/java/util/scanner_hasnextlong.htm
Re: уточнение задачи
Posted by ToadMonster 17 Feb 2016 18:59
Didn't you write something in this topic?
http://acm.timus.ru/forum/thread.aspx?id=32443&upd=635912651494294196

There is some code in the starting post.
Of course it doesn't work in general, but it contains read until end.
Re: уточнение задачи
Posted by JavaClass 17 Feb 2016 23:31
Thanks
Re: уточнение задачи
Posted by JavaClass 18 Feb 2016 00:17
ToadMonster, in that post not said about line breaks, and code in start works only for line spaces, send me sample about end of input if it isn't difficult for You?
Re: уточнение задачи
Posted by retired 18 Feb 2016 04:40
I guess since the solution of this task is available anyway, for example, here http://acm.timus.ru/help.aspx?topic=scala , it won't hurt to share it.

import java.util.*;

public class T1001 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in); //initializing scanner to read data
        long a[] = new long[131072]; //an array to keep the numbers we read
        //Since the input is 256kb at most, in worst case it's 1-digit numbers
        //and spaces only, a bit more than 128k numbers,
        //or 131072 (2^17) to be precise.
        int i = 0; //a counter for amount of numbers we've read
        while (in.hasNextLong()) { //while there's a number of long type yet unread
            i++; //we increase the counter
            a[i] = in.nextLong(); //and read it into our array
        }
        //Here, we've just read all the numbers into an array, using nextLong.
        //It works with spaces AND with line breaks, what you said about it
        //working only for spaces is incorrect.
        for (i = i; i > 0; i--) { //for each number, from last one, to the first one
            System.out.println(Math.sqrt(a[i])); //output the square root for it
        }
    }
}

Personally though, i prefer this guy's AC code http://acm.timus.ru/forum/thread.aspx?id=31547&upd=635564450494489323 , but though it's more optimal, it's kinda harder to explain to a novice.

Edited by author 18.02.2016 04:41
Re: уточнение задачи
Posted by JavaClass 18 Feb 2016 09:57
Retired, thanks a lot
Re: уточнение задачи
Posted by ToadMonster 18 Feb 2016 14:46
Code from "post not said about line breaks, and code in start works only for line spaces" is:

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.*;

public class Try2 {

    public static void main(String[] args)
    {
        DecimalFormatSymbols s = new DecimalFormatSymbols();
        s.setDecimalSeparator('.');
        DecimalFormat f = new DecimalFormat("#,####0.0000",s);
        Scanner in = new Scanner(System.in);
        while (in.hasNextLong())
        {
        System.out.println(f.format(Math.sqrt(in.nextLong()) ));
        }
    }
}

Could you:
- run code locally with input like
-----
1 2 3
4
5
6
-----
- show output here
- type "sorry"
- think what do you do here if you don't understand other person code, don't want to run code and see it's behavior, and can't write your own.

P.S. - link to ideonline with code: https://ideone.com/Fddvox



Edited by author 18.02.2016 15:06
Re: уточнение задачи
Posted by JavaClass 18 Feb 2016 18:36
1 2 3
1.0000
1.4142
1.7321
4
2.0000
5
2.2361
6
2.4495

Here for your request, if it would be possibility send screenshots I would be done it for U.
But l think cause of this effect that I use for coding AIDE for android.
And I say "thanks" for your attention on my request.
And last one, be careful on your posts
Re: уточнение задачи
Posted by ToadMonster 18 Feb 2016 18:52
And where is "I see code works with line breaks. I was wrong/I lied."?

Edited by author 18.02.2016 18:54
Re: уточнение задачи
Posted by JavaClass 18 Feb 2016 19:05
I have test it in tablet and in that site U sent link but not in computer,
Maybe really I was wrong but really U were bad mannered, if U guru in java it not means U can tell anything U want
Re: уточнение задачи
Posted by Jane Soboleva (SumNU) 18 Feb 2016 19:31
"But l think cause of this effect that I use for coding AIDE for android."
Using Android IDE for timus might be not the best idea.
Use something like Eclipse (https://eclipse.org/) or IntelliJ Idea (https://jetbrains.com/idea/).

Edited by author 18.02.2016 19:32
Re: уточнение задачи
Posted by JavaClass 18 Feb 2016 19:43
And if U want see my own code here link https://ideone.com/aro6K7
Re: уточнение задачи
Posted by JavaClass 18 Feb 2016 19:46
I used to these IDE s that U advised, but now I haven't got computer, for the time being
Re: уточнение задачи
Posted by Jane Soboleva (SumNU) 18 Feb 2016 19:56
Wow, are you serious~
Must be really tough.
And reminds me of http://goo.gl/Gsuz9H haha.
Anyways respect for trying hard even without computer, and good luck!
Re: уточнение задачи
Posted by ToadMonster 18 Feb 2016 20:07
WA 1.
TLE 7 after some fixes. How is your idea better/equal then  solution by Retired in this topic?
Re: уточнение задачи
Posted by JavaClass 18 Feb 2016 20:33
Jane Soboleva (SumNU), thanks a lot, but I'm ))) not agree with this joke) )
Re: уточнение задачи
Posted by JavaClass 18 Feb 2016 20:34
ToadMonster, iI don't understand U correctly, but I think U r right)
Pages: 1 2 Next