PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000399. Khôi phục cấp số cộng bí mật (Recover the Hidden Arithmetic Progression)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Khôi phục cấp số cộng bí mật (Recover the Hidden Arithmetic Progression)
Recover the Hidden Arithmetic Progression
Source: Codeforces
Version: Phuoc Hung OJ Extended
Mode: interactive.
Problem Statement
A hidden array is a permutation of a strictly increasing integer arithmetic progression with . All elements are integers between 0 and .
Determine the minimum element and the common difference using at most 60 queries:
? i, : receive the value .> x, : receive1if some hidden value exceeds , otherwise0.
Output ! b_1 d and terminate. This final answer is not a query. Flush after each question. Stop immediately upon receiving -1.
PHOJ hidden test format
Each .in holds followed by its hidden values. The judge sends only initially; the rest can only be obtained through legal queries. One interaction per file.
Subtasks
- Subtask 1 (20 points): , , positive integer difference; 60-query limit.
- Subtask 2 (30 points): , , positive integer difference; 60-query limit.
- Subtask 3 (50 points): , , positive integer difference; 60-query limit.
Example interaction
Judge: 4
Player: ? 1
Judge: 14
Player: ? 2
Judge: 24
Player: ? 3
Judge: 9
Player: ? 4
Judge: 19
Player: ! 9 5
Explanation: Sorted values are , whose smallest value is 9 and constant difference is 5.