CodeForces 705B Spider Man (水题)

题意:给定 n 个数,表示不同的环,然后把环拆成全是1,每次只能拆成两个,问你有多少次。

析:也不难,反正都要变成1,所以把所有的数都减1,再求和即可。

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
using namespace std ;

typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f3f;
const double eps = 1e-8;
const int maxn = 1e4 + 5;
const int mod = 1e9 + 7;
const int dr[] = {0, 0, -1, 1};
const int dc[] = {-1, 1, 0, 0};
int n, m;
inline bool is_in(int r, int c){
    return r >= 0 && r < n && c >= 0 && c < m;
}

int main(){
    cin >> n;
    LL sum = 0;
    for(int i = 0; i < n; ++i){
        scanf("%d", &m);
        sum += (LL)(m-1);
        if(sum & 1)  printf("1\n");
        else printf("2\n");
    }
    return 0;
}
时间: 2024-07-28 13:50:21

CodeForces 705B Spider Man (水题)的相关文章

CodeForces 22D Segments 排序水题

题目链接:点击打开链接 右端点升序,取右端点 暴力删边 #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include <iostream> #include <map> #include <set> #include <math.h> using namespace std; #define inf 10

codeforces 706A A. Beru-taxi(水题)

题目链接: A. Beru-taxi 题意: 问那个taxi到他的时间最短,水题; AC代码: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <bits/stdc++.h> #include <stack> #include <map> using n

【打CF,学算法——二星级】Codeforces 705B Spider Man (简单博弈)

[CF简介] 题目链接:CF 705B 题面: 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 v

【模拟】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不能拆) 1 // 2

CodeForces Gym 100685C Cinderella (水题)

题意:给定 n 个杯子,里面有不同体积的水,然后问你要把所有的杯子的水的体积都一样,至少要倒少多少个杯子. 析:既然最后都一样,那么先求平均数然后再数一下,哪个杯子的开始的体积就大于平均数,这是一定要倒的. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #inclu

CodeForces 710A King Moves (水题)

题意:给定一个坐标,问你皇后有几个方向可以走. 析:直接格举那八个方向即可. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #include <cstring&g

CodeForces 347A Difference Row (水题)

题意:给定 n 个数,让你找出一个排列满足每个数相邻作差之和最大,并且要求字典序最小. 析:这个表达式很简单,就是把重新组合一下,就成了x1-xn,那么很简单,x1是最大的,xn是最小的,中间排序就好. 代码如下: #include <iostream> #include <cstdio> #include <string> #include <algorithm> #include <cstring> using namespace std;

CodeForces 347B Fixed Points (水题)

题意:给定 n 数,让你交换最多1次,求满足 ai = i的元素个数. 析:很简单么,只要暴力一遍就OK了,先把符合的扫出来,然后再想,最多只能交换一次,也就是说最多也就是加两个,然后一个的判,注意数组越界. 代码如下: #include <iostream> #include <cstdio> #include <string> #include <algorithm> #include <cstring> using namespace st

【Codeforces 707B】Bakery 水题

对每个storages找一下最短的相邻边 #include <cstdio> #define N 100005 #define inf 0x3f3f3f3f using namespace std; struct edge{ int to,next,w; }e[N<<1]; int head[N],cnt; void add(int u,int v,int w){ e[++cnt]=(edge){v,head[u],w}; head[u]=cnt; } int n,m,k; int