Note that there are some explanatory texts on larger screens.

plurals
  1. POSilly square root puzzle
    primarykey
    data
    text
    <p>I've been stuck on this problem for quite some time, it seems to work fine when I enter input in the console, but when submitted my solution always fails test #3 (you can not see what the input or output is). The problem is here <a href="http://acm.timus.ru/problem.aspx?space=1&amp;num=1001" rel="nofollow">Timus</a>. Here is the problem:</p> <p>The problem is so easy, that the authors were lazy to write a statement for it!</p> <p><strong>Input</strong></p> <p>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.</p> <p><strong>Output</strong></p> <p>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.</p> <p><strong>Input:</strong> </p> <pre><code>1427 0 876652098643267843 5276538 </code></pre> <p><strong>Output:</strong></p> <pre><code>2297.0716 936297014.1164 0.0000 37.7757 </code></pre> <p>This is my code:</p> <pre><code>using System; using System.Collections.Generic; using System.IO; namespace ReverseRoot { class Program { static void Main(string[] args) { List&lt;ulong&gt; longs = new List&lt;ulong&gt;(); string current = ""; bool inNumber = false; string input = Console.In.ReadToEnd(); for (int i = 0; i &lt; input.Length; ++i) { char c = input[i]; if (inNumber &amp;&amp; !char.IsDigit(c)) { longs.Add(ulong.Parse(current)); inNumber = false; current = ""; } if (char.IsDigit(c)) { inNumber = true; current += c; } } longs.Reverse(0, longs.Count); foreach (ulong n in longs) { double p = (Math.Truncate(Math.Sqrt(n) * 10000.0)) / 10000.0; Console.WriteLine("{0:F4}", p); } Console.ReadLine(); } } } </code></pre> <p>I've also tried Rounding to four decimal places since the wording of the problem is not entirely clear:</p> <pre><code> foreach (ulong n in longs) { Console.WriteLine("{0:F4}", Math.Sqrt(n)); } </code></pre> <p>I've tried numbers through the range of values in the console, not sure what it could be.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload