Mock CCC '18 Contest 1 J5/S3 - A Simulation Problem

View as PDF

Submit solution


Points: 7 (partial)
Time limit: 0.16s
Java 0.6s
Python 0.6s
Memory limit: 1G

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

Consider the following function:

function(N):
    # in some programming languages, 64-bit integers will be required to represent "threshold"
    threshold = N*(N-1)/2
    K = 1
    # in some programming languages, 64-bit integers will be required to represent "count"
    count = 0
    while K < N:
        L = K+1
        print K
        while L <= N:
            count += 1
            L += 1
            if 2 * count >= threshold:
                exit function
        K += 1

Given N, compute the last number this function prints out.

Constraints

2 \le N \le 10^9

Input Specification

The input consists of a single line containing the integer N.

Output Specification

Print, on a single line, the last number this function will print out.

Sample Input

4

Sample Output

1

Sample Input

7

Sample Output

2

Sample Input

10

Sample Output

3

Sample Input

1919

Sample Output

562

Sample Input

290976843

Sample Output

85225144

Comments

There are no comments at the moment.