III USP Freshmen ContestH. MaratonIME gets candies
生活随笔
收集整理的這篇文章主要介紹了
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?
轉載于:https://www.cnblogs.com/acjiumeng/p/6909850.html
總結
以上是生活随笔為你收集整理的III USP Freshmen ContestH. MaratonIME gets candies的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android攻城狮SurfaceVie
- 下一篇: MFC 选择目录