#P93. Interactive Problem Test 2: And-Sum Conversion
Interactive Problem Test 2: And-Sum Conversion
Person in charge
Problem Description
There are non-negative integers , where each takes a value between and , inclusive.
Before interaction begins, you can obtain the value of .
You have interaction opportunities. In each interaction, you can specify a non-negative integer (must be between and inclusive), and you will receive the count of elements in that satisfy .
Using these interactions, determine the value of .
Interaction Protocol
This is an interactive problem.
The problem provides an additional header file "conversion.h"
for interaction:
Function | Description | Constraints | Call Limit |
---|---|---|---|
int start(); |
Returns the value of | None | Unlimited |
int interact(int x); |
Returns the count of satisfying | must be satisfied | |
void stop(int s); |
Submit your answer (the sum) | Must terminate interaction after calling |
Use the following template:
#include <bits/stdc++.h>
#include "conversion.h"
using namespace std;
int main()
{
int n = start(); // Get n
int s = 0; // Answer
// Perform interactions here using interact()
stop(s); // Submit answer
return 0;
}
Sample
For this sample, , , with correct answer .
The following interaction sequence would get AC:
Function Call | Return Value | Explanation |
---|---|---|
start(); |
||
interact(0); |
Only satisfies | |
interact(1); |
satisfy | |
interact(2); |
satisfy | |
interact(3); |
All satisfy | |
stop(6); |
Correct answer submitted |
Constraints