F. Cooperative Game

链接

题意:

有10个玩家,开始所有玩家在home处,每次可以让一些玩家沿着边前进一步,要求在3(t+c)步以内,到达终点。

分析:

  很有意思的一道题。我们构造一种走的方式,设玩家有A,B和剩下的。

  1、首先A走一步,然后A,B同时走一步,直到AB相遇。(A,B一定会相遇,A先进入环上,然后B进入环上后,没此操作AB之间的距离减少1)

  2、然后A,B,和剩下的所有玩家同时走,直到相遇。相遇的点就是要找到的点。

  为什么这样是对的?

  设B进入环上后又走了x步,那么B=x+t,A=x+kc+t,即A进入环后转了k圈。A=2B,那么有x+kc+t=2x+2t;在模c的意义下:-x≡t (mod c),即c-x≡t (mod c)。c-x就是AB还要走的步数,t就是剩下的玩家需要走的步数。  

代码:

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
#include<cctype>
#include<set>
#include<queue>
#include<vector>
#include<map>
using namespace std;
typedef long long LL; inline int read() {
int x=,f=;char ch=getchar();for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-;
for(;isdigit(ch);ch=getchar())x=x*+ch-'';return x*f;
} char s[];
int IN() {
int x = read();
for (int i = ; i <= x; ++i) scanf("%s", s);
return x;
}
int main() {
while () {
puts("next 0"); fflush(stdout); IN();
puts("next 0 1"); fflush(stdout);
if (IN() == ) break;
}
while () {
puts("next 0 1 2 3 4 5 6 7 8 9"); fflush(stdout);
if (IN()==) break;
}
puts("done"); fflush(stdout);
return ;
}

CF 1138 F. Cooperative Game的更多相关文章

  1. CF 633 F. The Chocolate Spree 树形dp

    题目链接 CF 633 F. The Chocolate Spree 题解 维护子数答案 子数直径 子数最远点 单子数最长直径 (最长的 最远点+一条链) 讨论转移 代码 #include<ve ...

  2. CF #271 F Ant colony 树

    题目链接:http://codeforces.com/contest/474/problem/F 一个数组,每一次询问一个区间中有多少个数字可以整除其他所有区间内的数字. 能够整除其他所有数字的数一定 ...

  3. CF 494 F. Abbreviation(动态规划)

    题目链接:[http://codeforces.com/contest/1003/problem/F] 题意:给出一个n字符串,这些字符串按顺序组成一个文本,字符串之间用空格隔开,文本的大小是字母+空 ...

  4. CF 1138 E. Museums Tour

    E. Museums Tour 链接 分析: 按时间建出分层图,每个点形如(u,t),表示u在在t个时刻的点,tarjan缩点.每个强连通分量中的点都能经过,然后DAG上dp. 代码: #includ ...

  5. CF 1041 F. Ray in the tube

    F. Ray in the tube 链接 题意: 有两条平行于x轴的直线A,B,每条直线上的某些位置有传感器.你需要确定A,B轴上任意两个整点位置$x_a$,$x_b$,使得一条光线沿$x_a→x_ ...

  6. 【Cf #502 F】The Neutral Zone

    本题把$log$化简之后求得就是每个质数$f$前的系数,求系数并不难,难点在于求出所有的质数. 由于空间限制相当苛刻,$3e8$的$bitset$的内存超限,我们考虑所有的除了$2$和$3$以外的质数 ...

  7. CF 868 F. Yet Another Minimization Problem

    F. Yet Another Minimization Problem http://codeforces.com/contest/868/problem/F 题意: 给定一个长度为n的序列.你需要将 ...

  8. CF 1051 F. The Shortest Statement

    F. The Shortest Statement http://codeforces.com/contest/1051/problem/F 题意: n个点,m条边的无向图,每次询问两点之间的最短路. ...

  9. CF 1042 F. Leaf Sets

    F. Leaf Sets http://codeforces.com/contest/1042/problem/F 题意: 将所有的叶子节点分配到尽量少的集合,一个可行的集合中两两叶子节点的距离< ...

随机推荐

  1. webkit、cef、nwjs、electron、 miniblink浏览器内核优缺点

    市面上作为嵌入的组件的可用的浏览器内核,不外乎这几个:webkit.cef.nwjs.electron. 1.cef:优点是由于集成的chromium内核,所以对H5支持的很全,同时因为使用的人也多, ...

  2. [翻译] LLSimpleCamera

    LLSimpleCamera https://github.com/omergul123/LLSimpleCamera LLSimpleCamera is a library for creating ...

  3. openoffice centos7.4 安装

    其他是配置好java环境后操作 1.下载软件 http://www.openoffice.org/download/other.html 2.安装 tar xf Apache_OpenOffice_4 ...

  4. Win10下安装sulley

    sulley是一款针对网络协议的fuzz框架,记录下安装过程备忘 1.安装MinGW 下载:https://github.com/develersrl/gccwinbinaries/releases/ ...

  5. 内置数据结构(list)

    列表.元组.字符串.字典和集合是python内置的数据结构,也可以叫内置容器.前3个是线性结构,线性结构可以切片操作.解包和封包操作. dir()方法可以查看对象拥有哪些属性和方法. help()方法 ...

  6. HTTP 错误 404.3 - Not Found的问题(WCF)

    模块 StaticFileModule 通知 ExecuteRequestHandler 处理程序 StaticFile 错误代码 0x80070032 请求的 URL http://10.101.3 ...

  7. September 12th 2017 Week 37th Tuesday

    Failure is the fog through which we glimpse triumph. 失败是迷雾,穿过它,我们就可以瞥见光明. Sometimes the fog may be t ...

  8. codeforces 348D Turtles

    codeforces 348D Turtles 题意 题解 代码 #include<bits/stdc++.h> using namespace std; #define fi first ...

  9. SDN2017 第一次实验作业

    1. 安装mininet 从github上获取Mininet源码并运行安装脚本 $ git clone git://github.com/mininet/mininet $ ./mininet/uti ...

  10. Hibernate事务、缓存和连接池

    一.事务 1.数据库事务的概念 数据库事务是指由一个或多个SQL语句组成的工作单元,这个工作单元中的SQL语句相互依赖,如果有一个SQL语句执行失败,就必须撤销整个工作单元.在并发环境中,多个事务同时 ...