Codeforces Round #534 (Div. 2) D. Game with modulo 交互题
先二分一个区间,再在区间里面二分即可;
可以仔细想想,想明白很有意思的;
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#pragma GCC optimize(2)
using namespace std;
#define maxn 200005
#define inf 0x7fffffff
//#define INF 1e18
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
#define rdult(x) scanf("%lu",&x)
#define rdlf(x) scanf("%lf",&x)
#define rdstr(x) scanf("%s",x)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
//const long long int mod = 1e9 + 7;
#define Mod 1000000000
#define sq(x) (x)*(x)
#define eps 1e-4
typedef pair<int, int> pii;
#define pi acos(-1.0)
//const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;
inline ll rd() {
ll x = 0;
char c = getchar();
bool f = false;
while (!isdigit(c)) {
if (c == '-') f = true;
c = getchar();
}
while (isdigit(c)) {
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
return f ? -x : x;
} ll gcd(ll a, ll b) {
return b == 0 ? a : gcd(b, a%b);
}
int sqr(int x) { return x * x; } /*ll ans;
ll exgcd(ll a, ll b, ll &x, ll &y) {
if (!b) {
x = 1; y = 0; return a;
}
ans = exgcd(b, a%b, x, y);
ll t = x; x = y; y = t - a / b * y;
return ans;
}
*/ string s; int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
while (1) {
cin >> s;
if (s == "end") {
return 0;
}
if (s == "start") {
ll a = 1;
for (; a < (1 << 30); a <<= 1) {
cout << "?" << ' ' << a / 2 << ' ' << a << endl;
fflush(stdout);
cin >> s;
if (s == "x") {
break;
}
}
// 区间 a/2~ a
ll l = a / 2, r = a;
while (l + 1 < r) {
ll mid = (l + r) >> 1;
cout << "?" << ' ' << mid << ' ' << l << endl;
fflush(stdout);
cin >> s;
if (s == "x") {
l = mid;
}
else r = mid;
}
cout << "!" << ' ' << r << endl;
fflush(stdout);
}
}
}
Codeforces Round #534 (Div. 2) D. Game with modulo 交互题的更多相关文章
- Codeforces Round #534 (Div. 2) D. Game with modulo(取余性质+二分)
D. Game with modulo 题目链接:https://codeforces.com/contest/1104/problem/D 题意: 这题是一个交互题,首先一开始会有一个数a,你最终的 ...
- Codeforces Round #551 (Div. 2) E. Serval and Snake (交互题)
人生第一次交互题ac! 其实比较水 容易发现如果查询的矩阵里面包含一个端点,得到的值是奇数:否则是偶数. 所以只要花2*n次查询每一行和每一列,找出其中查询答案为奇数的行和列,就表示这一行有一个端点. ...
- Codeforces Round #812 (Div. 2) D. Tournament Countdown(交互题)
记录一下第一次写交互题 题目大意:一共有1<<n个人参加一场竞标赛,需要你通过比较两人的胜场来判断谁晋级,最终获得第一名 最多1/3*2^(n+1)次询问,每次询问query(a,b),如 ...
- Codeforces Round #297 (Div. 2)A. Vitaliy and Pie 水题
Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec Memory Limit: 256 MBSubmit: xxx ...
- Codeforces Round #298 (Div. 2) A、B、C题
题目链接:Codeforces Round #298 (Div. 2) A. Exam An exam for n students will take place in a long and nar ...
- CF1103D Codeforces Round #534 (Div. 1) Professional layer 状压 DP
题目传送门 https://codeforces.com/contest/1103/problem/D 题解 失去信仰的低水平选手的看题解的心路历程. 一开始看题目以为是选出一些数,每个数可以除掉一个 ...
- CF1103C Johnny Solving (Codeforces Round #534 (Div. 1)) 思维+构造
题目传送门 https://codeforces.com/contest/1103/problem/C 题解 这个题还算一个有难度的不错的题目吧. 题目给出了两种回答方式: 找出一条长度 \(\geq ...
- Codeforces Round #534 (Div. 1)
A 构造题 有一个44的方格 每次放入一个横向12或竖向2*1的方格 满了一行或一列就会消掉 求方案 不放最后一行 这样竖行就不会消 然后竖着的放前两行 横着的放第三行 循环放就可以啦 #includ ...
- Codeforces Round #534 (Div. 2)D. Game with modulo-1104-D(交互+二分+构造)
D. Game with modulo time limit per test 1 second memory limit per test 256 megabytes input standard ...
随机推荐
- cron job error : c queue max run limit reached
在cron job的日志中发现以下报错: ! c queue max run limit reached Wed Aug 28 12:56:00 2013 ! rescheduling a cron ...
- oracle错误-ORA-12519, TNS:no appropriate service handler found
转自:https://blog.csdn.net/u013147600/article/details/48380841
- python中的变量以及字符串的使用
在python中只有一个变量:动态变量 在Python当中令人奇怪的是我们的python没有静态变量,这个特性大大的增加了python的灵活性. 由于python中没有静态变量所以我们千万不要使用静态 ...
- iOS 地图(自定义地位图标)
#import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @pr ...
- 算法Sedgewick第四版-第1章基础-011一用链表实现bag、queue、stack
1. package algorithms.ADT; /************************************************************************ ...
- Blocks UVA - 10559
传送门 题目大意 有n个带有颜色的方块,没消除一段长度为x的连续的相同颜色的方块可以得到x^2的分数,让你用一种最优的顺序消除所有方块使得得分最多. 分析 首先不难看出这是一个区间dp,于是我们考虑如 ...
- git clone Timed out 解决
因为不可抗拒的原因,在乌鲁木齐从 github 上面克隆项目时,会超时克隆不了. 使用 https 方式报错: $ git clone https://github.com/xxx.git Cloni ...
- 面试经常问的一个问题:final、finalize、finally
http://m.blog.csdn.net/u010980446/article/details/51493658
- SDUT 3402 数据结构实验之排序五:归并求逆序数
数据结构实验之排序五:归并求逆序数 Time Limit: 40MS Memory Limit: 65536KB Submit Statistic Problem Description 对于数列a1 ...
- 使用IDEA编译spark 1.5并运行example的代码
操作系统:windows 10 IDEA : IDEA 14.1.4 1:使用IDEA导入spark 1.5的源码,注意maven配置为自动导入 2:在maven窗口下的profiles中勾选hado ...