• 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
  • 相关阅读:
    时刻记住 不要陷入碌碌无为中
    作战の计划
    SpringMVC确定目标方法POJO类型入参的过程
    springmvc框架第一帖HelloWorld
    Hibernate的主键生成策略的介绍
    Hibernate入门基本部署
    对于Hibernate框架的认识
    hibernate的第一个程序
    struts2框架的第一个程序
    java上传组件FileUpload
  • 原文地址:https://www.cnblogs.com/acjiumeng/p/6909850.html
Copyright © 2020-2023  润新知