ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1001. Обратный корень

Страницы: 1 2 Следующая
уточнение задачи
Послано JavaClass 17 фев 2016 00:28
Числа разделяются только по пробелам или по переводам строк тоже? Кто нибудь подскажите?
Re: уточнение задачи
Послано ToadMonster 17 фев 2016 14:54
Task description: The numbers are separated by any number of spaces and line breaks.
Can it mean "by spaces only"?
Re: уточнение задачи
Послано JavaClass 17 фев 2016 17:02
No, but how can I know end of input? Explain please
Re: уточнение задачи
Послано Jane Soboleva (SumNU) 17 фев 2016 17:41
Use hasNext or hasNextLong, if using scanner...
http://www.tutorialspoint.com/java/util/scanner_hasnextlong.htm
Re: уточнение задачи
Послано ToadMonster 17 фев 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: уточнение задачи
Послано JavaClass 17 фев 2016 23:31
Thanks
Re: уточнение задачи
Послано JavaClass 18 фев 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: уточнение задачи
Послано retired 18 фев 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: уточнение задачи
Послано JavaClass 18 фев 2016 09:57
Retired, thanks a lot
Re: уточнение задачи
Послано ToadMonster 18 фев 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: уточнение задачи
Послано JavaClass 18 фев 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: уточнение задачи
Послано ToadMonster 18 фев 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: уточнение задачи
Послано JavaClass 18 фев 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: уточнение задачи
Послано Jane Soboleva (SumNU) 18 фев 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: уточнение задачи
Послано JavaClass 18 фев 2016 19:43
And if U want see my own code here link https://ideone.com/aro6K7
Re: уточнение задачи
Послано JavaClass 18 фев 2016 19:46
I used to these IDE s that U advised, but now I haven't got computer, for the time being
Re: уточнение задачи
Послано Jane Soboleva (SumNU) 18 фев 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: уточнение задачи
Послано ToadMonster 18 фев 2016 20:07
WA 1.
TLE 7 after some fixes. How is your idea better/equal then  solution by Retired in this topic?
Re: уточнение задачи
Послано JavaClass 18 фев 2016 20:33
Jane Soboleva (SumNU), thanks a lot, but I'm ))) not agree with this joke) )
Re: уточнение задачи
Послано JavaClass 18 фев 2016 20:34
ToadMonster, iI don't understand U correctly, but I think U r right)
Страницы: 1 2 Следующая