Find a Mine

这篇文章讲述了在Codeforces平台上的一道题目,涉及使用C++编程语言,利用栈和质数的概念解决一个数学问题,包括输入处理、条件判断和求解过程。
摘要由CSDN通过智能技术生成

Problem - C - Codeforces

题意

思路

code

#include<iostream>
#include<cstdio>
#include<stack>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<vector>
#define int long long
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define  long long
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int INF = 1e18 + 10;
const int N = 1e5 + 10;
const int M = 1e7 + 10;
const int mod = 1e9 + 7;
int n, m, k, x, now, ans;
int qcal(int a, int b) { int res = 1; while (b) { if (b & 1) res = res * a % mod; b >>= 1; a = a * a % mod; } return res; }
int a[N], b[N];
bool is_prime(int n) { if (n < 2) return false; for (int i = 2; i <= n / i; i++) { if (n % i == 0) { return false; } }return true; }

int ask(int a, int b)
{
    cout << '?' << ' ' << a << ' ' << b << endl;
    int x; cin >> x;
    return x;
}

void gzy()
{
    cin >> n >> m;
    int k = ask(1, 1);
    int x1 = 0, y1 = 0, x2 = 0, y2 = 0;

    if (k + 1 <= n) x1 = 1 + k, y1 = 1;
    else x1 = n, y1 = 2 + k - n;

    if (k + 1 <= m) x2 = 1, y2 = 1 + k;
    else x2 = 2 + k - m, y2 = m;

    int k1 = ask(x1, y1), k2 = ask(x2, y2);
    //cout << x1 << ' ' << y2 << endl;
    int x3 = x1 - k1 / 2, y3 = y1 + k1 / 2;
    //cout << x3 << ' ' << y3 << endl;
    int x4 = x2 + k2 / 2, y4 = y2 - k2 / 2;
    if (ask(x3, y3) == 0) cout << '!' << ' ' << x3 << ' ' << y3 << endl;
    else cout << '!' << ' ' << x4 << ' ' << y4 << endl;
}

signed main()
{
    int _ = 1; cin >> _;
    // int _ = 1;
    while (_--) gzy();
    return 0;
}
// /**
//  *  ┏┓   ┏┓+ +
//  * ┏┛┻━━━┛┻┓ + +
//  * ┃       ┃
//  * ┃   ━   ┃ ++ + + +
//  *  ████━████+
//  *  ◥██◤ ◥██◤ +
//  * ┃   ┻   ┃
//  * ┃       ┃ + +
//  * ┗━┓   ┏━┛
//  *   ┃   ┃ + + + +Code is far away from  
//  *   ┃   ┃ + bug with the animal protecting
//  *   ┃    ┗━━━┓ 神兽保佑,代码无bug 
//  *   ┃  	    ┣┓
//  *    ┃        ┏┛
//  *     ┗┓┓┏━┳┓┏┛ + + + +
//  *    ┃┫┫ ┃┫┫
//  *    ┗┻┛ ┗┻┛+ + + +
//  */
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值