zoukankan      html  css  js  c++  java
  • codechef FEB19 Manhattan Rectangle

    Manhattan Rectangle

    链接

    题意:

      交互题,询问小于7次,确定一个矩形的位置,每次询问一个点到矩形的曼哈顿距离。

    分析:

      询问三个顶点,然后解一下方程,求出一个边界,就好办了。

      用scanf和printf会TLE?

    代码:

    #include<cstdio>
    #include<algorithm>
    #include<cstring>
    #include<iostream>
    #include<cmath>
    #include<cctype>
    #include<set>
    #include<queue>
    #include<vector>
    #include<map>
    using namespace std;
    typedef long long LL;
    
    const LL D = 1e9;
    
    LL Ask(LL x,LL y) {
        LL z; 
        cout << "Q " << x << " " << y << "
    ";
        cin >> z;
        fflush(stdout);
        return z;
    }
    void solve() {
        LL a = Ask(0ll, 0ll), b = Ask(D, 0ll), c = Ask(0ll, D);
        LL d = Ask((a - b + D) / 2, 0); // !!! 
        LL y0 = d, x0 = a - d, x1 = D - (b - d), y1 = D - (c - x0);
        cout << "A " << x0 << " " << y0 << " " << x1 << " " << y1 << "
    ";
        int flag; 
        cin >> flag;
        fflush(stdout);
        if (flag < 0) exit(0);
    }
    int main() {
        int T ;
        cin >> T;
        for (; T --; solve()) ;
        return 0;
    }
  • 相关阅读:
    《架构真经》读后感2
    css的引入
    交流会发言
    css学习
    数据结构-哈希表、二叉排序数
    软工人学习日常
    Java包、类、方法、变量、常量命名规范
    数据库命名规范
    学生信息系统jsp界面
    学生信息系统servlet层
  • 原文地址:https://www.cnblogs.com/mjtcn/p/10382821.html
Copyright © 2011-2022 走看看