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

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

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

Looks like you are learning programming from very beginning. You are unfamiliar with input/output, data structures. You are trying to create huge string in your solution by link.

I don't think tasks here are easy enough for you. You should practice on much easier tasks. You can try, for example, https://www.hackerrank.com - easy tasks in "algoriths", "data structures", "java" topics.
JavaClass Re: уточнение задачи [3] // Задача 1001. Обратный корень 19 фев 2016 15:34
Yeah, U r right, I haven't learn data struckture and output input operations fairly yet
JavaClass Re: уточнение задачи [2] // Задача 1001. Обратный корень 19 фев 2016 15:37
Can U help me lern ?
Jane Soboleva (SumNU) Re: уточнение задачи [1] // Задача 1001. Обратный корень 19 фев 2016 18:58
This is no place to learn some programming language from zero, however. You should spend some time reading a book and practice on your own for a while. Try the site ToadMonster advised, too.
JavaClass Re: уточнение задачи // Задача 1001. Обратный корень 19 фев 2016 19:48
Yes, my knowledge is poor but I'm not learning from zero, I need help on choose ways to learn