CCC '04 J1 - Squares

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 64M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
Canadian Computing Competition: 2004 Stage 1, Junior #1

Gigi likes to play with squares. She has a collection of equal-sized square tiles. Gigi wants to arrange some or all of her tiles on a table to form a solid square. What is the side length of the largest possible square that Gigi can build?

For example, when Gigi has 9 tiles she can use them all to build a square whose side length is 3. But when she has only 8 tiles, the largest square that she can build has side length 2.

Write a program that inputs the number of tiles and then prints out the maximum side length. You may assume that the number of tiles is less than ten thousand.

Sample Input 1


Sample Output 1

The largest square has side length 3.

Sample Input 2


Sample Output 2

The largest square has side length 2.

Sample Input 3


Sample Output 3

The largest square has side length 86.

CCC problem statements in large part from the PEG OJ


  • -3
    the_noah  commented on July 31, 2020, 11:48 a.m.

    stupid period

  • 24
    jace_l1808  commented on Feb. 11, 2019, 4:08 p.m.

    Didn't see the period in the output. There goes 10 mins of my life

    • 3
      hjanday  commented on May 9, 2020, 2:38 p.m.

      same, spent 15 minutes debugging and did not see the period

  • 4
    Arihan10  commented on Dec. 22, 2018, 2:46 p.m.

    How do I do this? A simple nudge towards the right side would be nice.

    Thank you.

    • 10
      magicalsoup  commented on Dec. 22, 2018, 3:07 p.m.

      think about using sqrt

      • 8
        Arihan10  commented on Dec. 23, 2018, 12:49 p.m. edited

        Ohhhhh... Thank you so much! You are so smart! Of course... square roots will be used! I am literally so dumb! Thank you once again!

  • 17
    CoolNoobyBooby  commented on Aug. 23, 2018, 10:56 a.m.

    I didn't know what was wrong with my code for a long time, then I realized I forgot a period.

    • 7
      richardyou777  commented on Jan. 1, 2019, 12:21 a.m.

      That got me too. Don't forget the period after the side length of the square.

  • -17
    gabemok  commented on Nov. 21, 2014, 9:45 a.m.

    This comment is hidden due to too much negative feedback. Click here to view it.

    • 15
      FatalEagle  commented on Nov. 21, 2014, 8:14 p.m.

      You are not receiving TLE but WA, meaning your program produced the wrong answer in 0.1 seconds. The output we show you is not the full output; the (clipped) means we only show a certain prefix of your output. For most problems this is the first 32 bytes.

      • 6
        loltrollkill  commented on Dec. 28, 2017, 5:35 p.m.

        Yay FatalEagle! my fav