No.863 Time Complexity
タグ : / 解いたユーザー数 346
作問者 :
e869120
/ テスター :
butsurizuki
Problem Statement
E869120 submitted a source code on yukicoder.
The submission produced the following results.
- The execution time for $N = 5 \ 000$ is $A$ milliseconds, with the fractional part truncated
- The execution time for $N = 200 \ 000$ is $B$ milliseconds, with the fractional part truncated
He submitted either a source code that performs exactly $P * N$ operations ($P$ is a natural number) or a source code that performs exactly $Q * N^2$ operations ($Q$ is a natural number).
Judging from the execution time information, output $1$ if the time complexity is linear ($P * N$ operations), or $2$ if it is proportional to $N^2$.
Since the yukicoder judge system is extremely stable, assume that the execution speed is always the same.
Constraints
All input data satisfy the following constraints.
- $A$ is an integer between $1$ and $25 \ 000 \ 000$, inclusive
- $B$ is an integer between $1$ and $1 \ 000 \ 000 \ 000$, inclusive
- The input satisfies the conditions of the problem statement
Input
$A$ $B$
Output
Output $1$ if the time complexity is linear ($P * N$ operations), or $2$ if it is proportional to $N^2$.
Print a newline at the end.
Sample
Sample 1
Input
2 106
Output
1
It takes $2$ milliseconds for $N = 5 \ 000$ and $106$ milliseconds for $N = 200 \ 000$, so it is reasonable to conclude that the time is linear.
Sample 2
Input
77 124200
Output
2
It takes $77$ milliseconds for $N = 5 \ 000$ and $124 \ 200$ milliseconds ($124.2$ seconds) for $N = 200 \ 000$, so it is reasonable to conclude that the time is proportional to $N^2$.
Sample 3
Input
2160000 86400000
Output
1
This would not normally happen, but this submission appears to be a linear-time solution with a very heavy constant factor. Why could that be?
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。