zoukankan      html  css  js  c++  java
  • III USP Freshmen ContestH. MaratonIME gets candies

    这题挺有意思的,刚开始不会这交互题,模仿着做了一题就会了,蛮简单 的

    这题我用2分,结果wa了,想了一下发现,1到1e9二分50次完全不够用啊,那就转换一下思维,先求出在10^n~10^(n+1)的n

    然后进行二分,这样居然a了。。。

    #include<map>
    #include<set>
    #include<cmath>
    #include<queue>
    #include<stack>
    #include<vector>
    #include<cstdio>
    #include<cassert>
    #include<iomanip>
    #include<cstdlib>
    #include<cstring>
    #include<iostream>
    #include<algorithm>
    #define pi acos(-1)
    #define ll long long
    #define mod 1000000007
    #define ls l,m,rt<<1
    #define rs m+1,r,rt<<1|1
    #pragma comment(linker, "/STACK:1024000000,1024000000")
    
    using namespace std;
    
    const double g=10.0,eps=1e-9;
    const int N=300000+10,maxn=16,inf=9999999;
    
    int main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        ll l=1,r=1;
        string str;
        for(int i=1;i<=10;i++)
        {
            cout<<"Q "<<l<<endl;
            cout.flush();
            cin>>str;
            if(str=="=")return 0;
            if(str==">")l*=10;
            else if(str=="<")
            {
                r=l;
                l/=10;
                break;
            }
        }
        for(int i=1;i<=50;i++)
        {
            ll m=(l+r)/2;
            cout<<"Q "<<m<<endl;
            cout.flush();
            cin>>str;
            if(str==">")l=m;
            else if(str=="<")r=m;
            else return 0;
        }
        return 0;
    }
    View Code
  • 相关阅读:
    2019春季学期第四周作业
    2019年春季学期第三周作业+预习作业
    2019第一周作业2
    2019第一周作业1
    寒假作业3(抓老鼠啊~亏了还是赚了?)
    nginx负载均衡
    性能优化建议
    数据库主从配置
    php魔术方法
    图片轮播
  • 原文地址:https://www.cnblogs.com/acjiumeng/p/6909850.html
Copyright © 2011-2022 走看看