P11144
将题目进一步形式化:
输出
我们令
相邻两数必然互素,
构造一组
得:
所以
代码:
#include <iostream>
typedef long long LL;
const LL Max = 4e8;
const LL mod = (LL)1e17 + 1;
int main(){
std::cin.tie(0)->sync_with_stdio(0);
int T;
for (std::cin >> T;T--;){
LL res1,res2;
std::cout << "? " << Max << std::endl;
std::cin >> res1;
std::cout << "? " << Max - 1 << std::endl;
std::cin >> res2;
std::cout << "! " << (Max * res2 + (Max - 1) * Max - (Max - 1) * res1) % (Max * (Max - 1)) << '\n';
}
return 0;
}