codeforce843B Interactive LowerBound(随机算法+交互题)
来源:互联网 发布:sql注入绕过单引号 编辑:程序博客网 时间:2024/05/02 00:02
#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <string>#include <cmath>#include <algorithm>#include <vector>#include <set>#include <map>#include <time.h>using namespace std;int num[50015];int main(){ int n, st, x; scanf("%d%d%d", &n, &st, &x); //第一种产生随机数的方法: //for(int i = 0; i < n; ++i) num[i] = i + 1; //random_shuffle(num, num + n); srand((unsigned)time(0)); int cnt = min(999, n); int v = -1, t = 0, ne = 0; for(int i = 0; i < cnt; ++i) { //第二种产生随机数的方法: printf("? %d\n", abs((rand()<<15)+rand()) % n + 1); fflush(stdout); scanf("%d%d", &t, &ne); if(t <= x && t >= v) v = t, st = ne; } while(st != -1 && v < x) { printf("? %d\n", st); fflush(stdout); scanf("%d%d", &v, &st); } if(v < x) printf("! -1\n"); else printf("! %d\n", v); fflush(stdout); return 0;}
阅读全文
0 0
- codeforce843B Interactive LowerBound(随机算法+交互题)
- AIM Tech Round 4 (Div. 1) B. Interactive LowerBound(随机)
- Codeforces 844 D Interactive LowerBound(随机化)
- AIM Tech Round 4 (Div. 2) D. Interactive LowerBound
- AIM Tech Round 4 (Div. 2) D. Interactive LowerBound
- Interactive Cloth 交互布料
- hust 1628 LowerBound 莫队算法
- HSUT 1628 LowerBound(划分树+二分)
- 【C#】30. VS 2015 的 C# 交互窗口(interactive window)
- tcp/ip学习笔记--第19章 TCP interactive data flow (交互数据流)
- 交互系统公司(Interactive Systems Corporation)
- 随机算法(上)
- 随机算法(下)
- 算法竞赛入门经典:第八章 高效算法设计 8.6二分查找之lowerBound
- 【算法题】随机的机器人
- 关于Vs2015中C#交互(C# Interactive)窗口的应用。
- [交互 杂题] Codeforces Gym 100307 NEERC 13 I. Interactive Interception
- 随机算法
- 【Java面试】---面向对象技术
- 数据库——数据库练习题
- BufferedWriter和BufferedReader
- c3p0配置文件出错:实体之间要使用;隔开,而在xml文件中,分号用&代替
- 1045. 快速排序(25)
- codeforce843B Interactive LowerBound(随机算法+交互题)
- python用BeautifulSoup库简单爬虫入门+案例(爬取妹子图)
- 设计模式
- iphone模拟器快捷键使用
- 【第一篇】搞定BootstrapTable(后端使用SpringMVC+Hibernate)
- 【数据结构与算法】topK问题
- 友盟第三方分享步骤
- Java Serializable(序列化)的理解和总结
- eclipse下打包java项目为jar文件