問題一覧 > 通常問題

No.863 Time Complexity

レベル : / AI推定難易度 : 167 / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 346
作問者 : e869120 / テスター : butsurizuki
お気に入りにしたユーザー ProblemId : 3315 / 自分の提出
問題文最終更新日: 2019-08-16 14:05:42
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 220 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。