Codeforces Round #363 (Div. 2) A、B、C】的更多相关文章

Codeforces Round 363 Div. 1 题目链接:## 点击打开链接 A. Vacations (1s, 256MB) 题目大意:给定连续 \(n\) 天,每天为如下四种状态之一: 不能进行运动或比赛 可以进行运动但不能比赛 可以进行比赛但不能运动 可以进行比赛或运动 对于每天,可以根据当天的状态选择运动,比赛或休息.但不能连续两天的选择均为运动或均为比赛.求在这 \(n\) 天中最少需要休息多少天. 数据范围:\(n \leq 100\) 简要题解:令 \(f_{i,0},f_…
题目链接:Codeforces Round #433 (Div. 2) codeforces 854 A. Fraction[水] 题意:已知分子与分母的和,求分子小于分母的 最大的最简分数. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int gcd(int a,int b){return b?gcd(b…
B题题意: 给你n个物品的价格,你需要找出来一个值b,使得每一个物品与这个b的差值的绝对值小于k.找到最大的b输出,如果找不到,那就输出-1 题解: 很简单嘛,找到上下限直接二分.下限就是所有物品中最小的价格.上限就是所有物品中最大价格加上k 代码: 1 #include<stdio.h> 2 #include<string.h> 3 #include<iostream> 4 #include<algorithm> 5 #include<map>…
A. Launch of Collider time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n parti…
题目链接:http://codeforces.com/contest/699/problem/C 题解: 1.可知每天有三个状态:1.contest ,2.gym,3.rest. 2.所以设dp[i][j](i:1~n,j:1~3)为第i天进行j活动的最小休息天数. 3.状态转移: contest:如果当天可以进行,从上一天的gym和rest中转移过来,取最小值.否者置为无限大INF. gym:如果当天可以进行,从上一天的contest和rest中转移过来, 取最小值.否则置为无限大INF. r…
A题 http://codeforces.com/problemset/problem/699/A 非常的水,两个相向而行,且间距最小的点,搜一遍就是答案了. #include <cstdio> #include <algorithm> using namespace std; struct node { int x;char ch; }s[+]; bool cmp(node& a,node& b) { return a.x<b.x; } int main()…
题目链接:http://codeforces.com/problemset/problem/698/B题意:告诉你n个节点当前的父节点,修改最少的点的父节点使之变成一棵有根树.思路:拆环.题解:http://codeforces.com/blog/entry/46148代码: #include <cstdio> ; int f[maxn], vis[maxn], n, s, cnt, idx; int Find(int x) { vis[x] = ++ idx; while (!vis[ f[…
题目链接:http://codeforces.com/contest/699/problem/D D. Fix a Tree time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A tree is an undirected connected graph without cycles. Let's consider a root…
题目链接:http://codeforces.com/contest/699/problem/B 题解: 首先统计每行每列出现'*'的次数,以及'*'出现的总次数,得到r[n]和c[m]数组,以及sum,.然后再枚举每一个格子(O(n^2)枚举,反正输入都是枚举的). 对于每一个格子s[i][j]: 1.如果它是'*', 那么当 r[i] + c[j] - 1 = sum 时, 表明炸弹放在这个位置可以炸掉所有的墙. 2.如果它是'.', 那么当 r[i] + c[j] = sum 时, 表明炸…
A. Maximum GCD 题意: t组输入,然后输入一个n,让你在区间[1,n]之间找出来两个不相等的数a,b.求出来gcd(a,b)(也就是a,b最大公约数).让你求出来最大的gcd(a,b)是多少. 题解: 最大gcd(a,b),那就是n/2向下取整的结果.因为如果gcd(a,b)越大,那么a/gcd(a,b)或者b/gcd(a,b)的值肯定越小,最小也就是2了,所以输出n/2就行 代码: 1 #include<stdio.h> 2 #include<algorithm>…
699A 题意:在一根数轴上有n个东西以相同的速率1m/s在运动,给出他们的坐标以及运动方向,问最快发生的碰撞在什么时候 思路:遍历一遍坐标,看那两个相邻的可能相撞,更新ans #include<cstdio> int n,num[200100]; char s[200100]; int main() { scanf("%d",&n); scanf("%s",s+1); for(int i=1;i<=n;i++) scanf("%…
好久没做手生了,不然前四道都是能A的,当然,正常发挥也是菜. A:Launch of Collider 题意:20万个点排在一条直线上,其坐标均为偶数.从某一时刻开始向左或向右运动,速度为每秒1个单位长度.输入给出每个点的坐标及其移动的方向,求发生第一次碰撞的时间,若不会碰撞,则输出-1 最先发生碰撞的是一定是初始时相邻的两个点,因此只需对每个点循环一边,判断其是否会与下一个点碰撞,并求出其时间即可. #include<stdio.h> #include<stdlib.h> int…
One Bomb 题意: 只有一个炸弹,并且一个只能炸一行和一列的'*',问最后能否炸完所以'*',如果可以输出炸弹坐标 题解: 这题做的时候真的没什么好想法,明知道b题应该不难,但只会瞎写,最后越写越乱,我就放弃了.看了题解,果然还是我不行... 首先枚举一遍,记录总'*'数,和每行,每列的'*'数,之后再枚举一遍,看是否一行一列的'*'数和总'*'数相等,如果是,那就是答案,如果没有,就是NO. 代码: #include <bits/stdc++.h> using namespace st…
C. Vacations time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about…
B. One Bomb time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a description of a depot. It is a rectangular checkered field of n × m size. Each cell in a field can be empty (".&…
A. Launch of Collider time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n parti…
题意: n个数,长度为k的缓存,每次询问,每个数以pi的概率被选,如果不在缓存区则加入,如果缓存区满了,则第一个进缓存的出来,问10^100次询问以后每个数在缓存的概率 思路: 状压DP,看了hzwer的代码 f[x]表示当前状态为x的概率 枚举不在缓存区的数:f[t]+=f[x]*(p[i]/tot);  t=x|(1<<(i-1)); tot是当前状态情况下,不在缓存区的所有概率 如果缓存区数大于k,则当前状态概率为0 // #pragma comment(linker, "/S…
D. Fix a Tree time limit per test 2 seconds memory limit per test 256 megabytes     A tree is an undirected connected graph without cycles. Let's consider a rooted undirected tree with n vertices, numbered 1 through n. There are many ways to represen…
要么去体育馆,要么去比赛,要么闲在家里 给出每一天体育馆和比赛的有无情况,要求连续两天不能去同一个地方 问最少闲几天 DP方程很容易看出 dp(第i天能去的地方) = min(dp(第i-1天的三种情况)) : dp(第i天呆在家里) = min(dp(第i-1天的三种情况))+1: #include <cstdio> #include <iostream> using namespace std; #define inf 0x3f3f3f3f ],ans[][],n; void…
D. Fix a Tree time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A tree is an undirected connected graph without cycles. Let's consider a rooted undirected tree with n vertices, numbered 1 th…
B. One Bomb time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a description of a depot. It is a rectangular checkered field of n × m size. Each cell in a field can be empty (".&…
C. Vacations time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about…
Description Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this ndays: whether that gym opened and whether a contest was carried out in the Internet on that day.…
Description You are given a description of a depot. It is a rectangular checkered field of n × m size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*"). You have one bomb. If you lay the bomb at the cell (x…
 Description There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles…
Description Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day…
Description You are given a description of a depot. It is a rectangular checkered field of n × m size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*"). You have one bomb. If you lay the bomb at the cell (x…
Description There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles l…
E. LRU time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output While creating high loaded systems one should pay a special attention to caching. This problem will be about one of the most popular…
题目链接:Distance and Axis 题意:在ox轴上,给出点A的横坐标x,你可以向左或右移动点A(x+1/x-1),问你最小移动A的次数,以使得可以在ox轴上找到B点位置,B点满足从O到B的距离与从A到B的距离之间的绝对差等于k. 题解: 先特判下: if(k==0) { if(n%2) printf("1\n"); else printf("0\n"); } else if(k>=n) { printf("%d\n",k-n);…