【模拟】Codeforces 705B Spider Man】的更多相关文章

题目链接: http://codeforces.com/problemset/problem/705/B 题目大意: 两个人玩游戏,总共N个数,分别求前I(I=1 2 3...n)个数时游戏的获胜者是谁. 游戏规则是可以把一个大于2的数拆成任意大小的两个数,1不能拆,问谁先不能拆谁输.先手输输出2,后手输输出1. 题目思路: [模拟] 很容易想到把一个数拆成两个数,不管怎么拆最后都会被拆成k个1,所以只要判断前I个数的奇偶就行了.(如果是1直接跳过,答案和上一把一样,因为1不能拆) // //b…
题意:给定 n 个数,表示不同的环,然后把环拆成全是1,每次只能拆成两个,问你有多少次. 析:也不难,反正都要变成1,所以把所有的数都减1,再求和即可. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include &…
水题. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #include<map> #include<set> #include<queue> #incl…
题目链接:http://codeforces.com/problemset/problem/216/D 题意: 对于一个梯形区域,假设梯形左边的点数!=梯形右边的点数,那么这个梯形为红色.否则为绿色, 问: 给定的蜘蛛网中有多少个红色. 2个树状数组维护2个线段.然后暴力模拟一下,由于点数非常多但须要用到的线段树仅仅有3条,所以类似滚动数组的思想优化内存. #include<stdio.h> #include<iostream> #include<string.h> #…
题目链接: B. Spider Man time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that…
Description Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that first one is connected with the second, second is connected with third and so on, while the last one is connected wit…
题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, 然后接下来的t秒需要的蜡烛都燃烧着,超过t秒,每减少一秒灭一支蜡烛,好!!! 详细解释:http://blog.csdn.net/kalilili/article/details/43412385 */ #include <cstdio> #include <algorithm> #i…
题目地址:http://codeforces.com/problemset/problem/350/C /* 题意:机器人上下左右走路,把其他的机器人都干掉要几步,好吧我其实没读懂题目, 看着样例猜出来的,这题也蛮水的 模拟+贪心:sort一下,从最近的开始走 注意:坐标有一个为0的比普通的少一半的步骤,每次干掉一个要返回原来的位置 */ #include <cstdio> #include <iostream> #include <algorithm> #includ…
题目地址:http://codeforces.com/contest/435/problem/C /* 题意:给一组公式,一组数据,计算得到一系列的坐标点,画出折线图:) 模拟题:蛮恶心的,不过也简单,依据公式得知折线一定是一上一下的,只要把两个相邻的坐标之间的折线填充就好 注意:坐标有可能为负数,所以移动值y初始化为1000,最后要倒过来输出 详细解释:http://blog.csdn.net/zhb1997/article/details/27877783 */ #include <cstd…
题目传送门 /* 模拟:这就是一道模拟水题,看到标签是贪心,还以为错了呢 题目倒是很长:) */ #include <cstdio> #include <algorithm> #include <iostream> #include <algorithm> #include <cstring> using namespace std; ; const int INF = 0x3f3f3f3f; ]; char s[MAXN]; int main(…
题目传送门 /* 题意:两堆牌,每次拿出上面的牌做比较,大的一方收走两张牌,直到一方没有牌 queue容器:模拟上述过程,当次数达到最大值时判断为-1 */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <string> #include <stack> #include <cmath> #inc…
题目传送门 /* 模拟水题:给定n*m的空白方格,k次涂色,将(x,y)处的涂成黑色,判断第几次能形成2*2的黑色方格,若不能,输出0 很挫的判断四个方向是否OK */ #include <cstdio> #include <iostream> #include <algorithm> #include <cmath> #include <cstring> #include <map> using namespace std; ; c…
题目链接:http://codeforces.com/problemset/problem/705/B 题意略解: 两个人玩游戏,解数字,一个数字可以被分成两个不同或相同的数字 (3可以解成 1 2),最小1不能再解 示例1: 第一把 当前1号玩家开始解数字 1,不能解, 则2号赢 输出2 第二把 当前数字为 1 2, 1号玩家直接对 2 进行解 解成 1 1,数字为 1 1 1,2号玩家无解,1号赢 第三把 当前数字为 1 2 3,一号玩家先对 2 解,解成 1 1,数字为 1 1 1 3,2…
Circle of Students time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are nn students standing in a circle in some order. The index of the ii-th student is pipi. It is guaranteed that a…
Problem's Link:http://codeforces.com/problemset/problem/475/Chttp://codeforces.com/problemset/problem/475/C Mean: 给你一个网格,每个格子中是'X'或'.',你需要用一个刷子去将这些'X'刷掉,而且不能刷到'.',每次只能往下走或者往右走,让你选一把最小的刷子出来. analyse: 爆搜+模拟. 1)我们先遍历两遍,求出最小连续的x和y,那么x和y就是刷子最大能够达到的大小: 2)对…
Tokitsukaze and Discard Items time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Recently, Tokitsukaze found an interesting game. Tokitsukaze had nn items at the beginning of this game. Howeve…
第二弹: 套路&&经验总结: 1. N堆***的游戏,一般可以打表找SG函数的规律.比如CodeForces 603C 2.看起来是单轮的游戏,实际上可能拆分成一些独立的子游戏.比如CodeForces 317D 3.考虑最终如果某方胜利,最后的局面会是怎样. 比如CodeForces 594A 4.大力分类讨论,不要怕麻烦,在纸上写清楚. 比如 CodeForces 455B CodeForces 794C 题目大意: A和B各有一个大小为N的可重复字符集合,然后两个人轮流,每次取出从自…
http://codeforces.com/problemset/problem/747/C 题意:有n台机器,q个操作.每次操作从ti时间开始,需要ki台机器,花费di的时间.每次选择机器从小到大开始,如果可以完成任务,那么输出id总和,否则输出-1. 思路:简单的模拟,注意如果不能完成任务,那么ser数组是不能更新的. #include <cstdio> #include <algorithm> #include <iostream> #include <cs…
A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have decided to watch the best moments of some movie. There are two buttons on your player: Watch the current minute…
A. Alyona and copybooks time limit per test: 1 second memory limit per test: 256 megabytes input: standard input output: standard output Little girl Alyona is in a shop to buy some copybooks for school. She study four subjects so she wants to have eq…
D. Sea Battle time limit per test: 1 second memory limit per test :256 megabytes input: standard input output: standard output Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships…
题目链接:http://codeforces.com/problemset/problem/723/B 题目大意: 输入n,给出n个字符的字符串,字符串由 英文字母(大小写都包括). 下划线'_' .括号'(' ')' 组成.[括号不会嵌套] 求括号外面的连续字符串最大的字符串长度和括号内的连续字符串的个数. 举例: input 37_Hello_Vasya(and_Petya)__bye_(and_OK) output 5 4 括号外面的连续的字符串最长的字符串长度为 5 括号内有 4 个连续…
题目链接: http://codeforces.com/problemset/problem/546/C 题意: 总共有n张牌,1手中有k1张分别为:x1, x2, x3, ..xk1,2手中有k2张,分别为:y1, y2, ...yk2:(n<=10&&k1+k2==n,所有牌的数字都不同): 依次比较x1, y1的大小,若x1>y1,依次将x1, y1加入x牌最底下:反之则将y1,x1依次加入y牌最底下:直至有方的牌输完为止:输出总共游戏的步数和赢方: 如果两方都不能赢,则…
http://codeforces.com/problemset/problem/749/C 题意:有n个人投票,分为 D 和 R 两派,从1~n的顺序投票,轮到某人投票的时候,他可以将对方的一个人KO,被KO的人不能投票了,这样循环,直到某一派的人全部被KO,问哪方赢. 思路:模拟..代码好懂.. #include <cstdio> #include <algorithm> #include <iostream> #include <cstring> #i…
Prison Transfer Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description The prison of your city has n prisoners. As the prison can't accommodate all of them, the city mayor has decided to transfer c of t…
Marathon Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description Valera takes part in the Berland Marathon. The marathon race starts at the stadium that can be represented on the plane as a square whose…
Fox and Cross Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description Fox Ciel has a board with n rows and n columns. So, the board consists of n × n cells. Each cell contains either a symbol '.', or a s…
E. Correct Bracket Sequence Editor time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Recently Polycarp started to develop a text editor that works only with correct bracket sequences (abbrev…
A. Bear and Five Cards time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A little bear Limak plays a game. He has five cards. There is one number written on each card. Each number is a posit…
题目链接: http://codeforces.com/contest/670/problem/E 题解: 用STL的list和stack模拟的,没想到跑的还挺快. 代码: #include<iostream> #include<cstdio> #include<cstring> #include<map> #include<list> #include<stack> using namespace std; + ; const in…