zoukankan      html  css  js  c++  java
  • 《codeforces交互式题目》

    https://codeforces.ml/gym/101021/problem/1

    入门题。

    对于交互式题目,就是通过自己询问的结果来判断下一次询问最后得出结果的过程。

    对于打印出来的结果,都必须用fflush(stdout)来强制清空

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long LL;
    typedef pair<string,int> pii;
    const int N = 1e3+5;
    const int M = 2e5+5;
    const LL Mod = 1e9+7;
    #define rg register
    #define pi acos(-1)
    #define INF 1e9
    #define CT0 cin.tie(0),cout.tie(0)
    #define IO ios::sync_with_stdio(false)
    #define dbg(ax) cout << "now this num is " << ax << endl;
    namespace FASTIO{
        inline LL read(){
            LL x = 0,f = 1;char c = getchar();
            while(c < '0' || c > '9'){if(c == '-') f = -1;c = getchar();}
            while(c >= '0' && c <= '9'){x = (x<<1)+(x<<3)+(c^48);c = getchar();}
            return x*f;
        }
        void print(int x){
            if(x < 0){x = -x;putchar('-');}
            if(x > 9) print(x/10);
            putchar(x%10+'0');
        }
    }
    using namespace FASTIO;
    
    int main()
    {
        int L = 1,r = 1000000;
        while(L < r)
        {
            int mid = (L+r+1)>>1;
            printf("%d
    ",mid);
            fflush(stdout);
            string s;cin >> s;
            if(s == ">=") L = mid;
            else r = mid-1;
        }
        printf("! %d
    ",L);
        fflush(stdout);
    }
    View Code
  • 相关阅读:
    AutoResetEvent 2
    AutoResetEvent
    c++ 控制台输入参数
    C# .Net 多进程同步 通信 共享内存 内存映射文件 Memory Mapped
    filezilla管理网站服务器
    matlab
    WCF:无法满足对安全令牌的请求,因为身份验证失败。
    WCF 学习
    dev
    dotnetbar
  • 原文地址:https://www.cnblogs.com/zwjzwj/p/13696198.html
Copyright © 2011-2022 走看看