Codeforces 492D Vanya and Computer Game】的更多相关文章

D. Vanya and Computer Game time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vanya and his friend Vova play a computer game where they need to destroy n monsters to pass a level. Vanya's cha…
D. Vanya and Computer Game time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vanya and his friend Vova play a computer game where they need to destroy n monsters to pass a level. Vanya's cha…
D. Vanya and Computer Game Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/492/problem/D Description Vanya and his friend Vova play a computer game where they need to destroy n monsters to pass a level. Vanya's character pe…
D. Vanya and Computer Game time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vanya and his friend Vova play a computer game where they need to destroy n monsters to pass a level. Vanya's cha…
D. Vanya and Computer Game time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vanya and his friend Vova play a computer game where they need to destroy n monsters to pass a level. Vanya's cha…
D. Vanya and Computer Game time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vanya and his friend Vova play a computer game where they need to destroy n monsters to pass a level. Vanya's cha…
题目链接:codeforces 492e vanya and field 留个扩展gcd求逆元的板子. 设i,j为每颗苹果树的位置,因为gcd(n,dx) = 1,gcd(n,dy) = 1,所以当走了n步后,x从0~n-1,y从0~n-1都访问过,但x,y不相同. 所以,x肯定要经过0点,所以我只需要求y点就可以了. i,j为每颗苹果树的位置,设在经过了a步后,i到达了0,j到达了M. 则有 1----------------------(i + b * dx) % n = 0 2------…
链接 Codeforces 677D Vanya and Treasure 题意 n*m中有p个type,经过了任意一个 type=i 的各自才能打开 type=i+1 的钥匙,最初有type=1的钥匙, 问拿到type=p的钥匙最少需要走多少步 思路 第一想法就是按type来递推, 将type相同的存到一起,dp[i][j]=min(dp[i][j], dp[k][l]+distance([i][j], [k][l])),其中 a[i][j] = a[k][l]+1. 但这样type相同的个数…
[Codeforces 555E]Case of Computer Network(Tarjan求边-双连通分量+树上差分) 题面 给出一个无向图,以及q条有向路径.问是否存在一种给边定向的方案,使得这q条路径都能被满足.(如果有一条边是从a->b),而经过它的路径是从b->a,那么久不满足).只需要判断,不用输出方案. 分析 对于一个有向环,显然它可以允许各个方向的路径通过.所以我们只要把无向图里的边-双联通分量建成环,然后就不用考虑了.影响答案的只有桥. 所以我们求出所有桥,然后缩点,把图…
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 第一个人攻击一次需要1/x秒 第二个人攻击一次需要1/y秒 这两个数字显然都是小数. 我们可以二分最后用了多少时间来攻击. 显然这个是有单调性的,攻击时间越多的话,攻击的次数也就越多. 假设二分出来攻击的时间是mid 那么攻击的次数就是 mid/(1/x) + mid/(1/y) 但是这样显然二分出来的也是一个小数. 我们完全没有办法根据二分出来的东西判断它到底是谁的倍数. 因此我们可以这样. 我们把第一个人攻击一次和第二个人攻击一次所需…
http://codeforces.com/contest/492/problem/D 有时候感觉人sb还是sb,为什么题目都看不清楚? x per second, y per second... 于是我们二分second即可. 而且对每个monster都有伤害.... #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostream&g…
Vanya and his friend Vova play a computer game where they need to destroy n monsters to pass a level. Vanya's character performs attack with frequency x hits per second and Vova's character performs attack with frequency y hits per second. Each chara…
Vanya and Scales Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 552C Description Vanya has a scales for weighing loads and weights of masses w0, w1, w2, ..., w100 grams where w is some…
题目链接: http://codeforces.com/gym/100114 Description The computer network of “Plunder & Flee Inc.” consists of n servers and m two-way communication links. Two servers can communicate either through a direct link, or through a chain of links, by relayi…
J. Computer Network Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Description The computer network of “Plunder & Flee Inc.” consists of n servers and m two-way communication links. Two servers can communicate either thr…
C. Vanya and Label time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwi…
Vanya and Brackets Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Description Vanya is doing his maths homework. He has an expression of form , where x1, x2, ..., xn are digits from 1 to 9, and sign represents either a p…
C. Vanya and Scales Vanya has a scales for weighing loads and weights of masses w0, w1, w2, ..., w100 grams where w is some integer not less than 2(exactly one weight of each nominal value). Vanya wonders whether he can weight an item with mass m usi…
题目链接:http://codeforces.com/problemset/problem/492/B #include <cstdio> #include <cstdlib> #include <iostream> #include <algorithm> #include <cstring> using namespace std; + ; double a[maxn]; double l[maxn], r[maxn]; int main()…
题目链接:http://codeforces.com/problemset/problem/492/C 题目意思:给出 3 个整数:n,  r,  avg.然后有 n 行,每行有两个数:第 i 行有 ai 和 bi.表示如果写 bi 篇文章那么可以在 ai 这个分数上增加 1 分.可以增加好多次,但是前提是加完得到的分数不能超过 r.要使得 n 个exam 的分数平均分至少达到avg时需要写的最少文章是多少篇. 解决方法很简单,贪心即可. 我们当然希望写的文章越少越好,所以先对文章从小到大排序.…
Vanya and Balloons 枚举中心去更新答案, 数字过大用log去比较, 斜着的旋转一下坐标, 然后我旋出来好多bug.... #include<bits/stdc++.h> #define LL long long #define LD long double #define ull unsigned long long #define fi first #define se second #define mk make_pair #define PLL pair<LL,…
题目链接:http://codeforces.com/problemset/problem/677/D 题意: 有 $n \times m$ 的网格,每个网格上有一个棋子,棋子种类为 $t[i][j]$,棋子的种类数为 $p$. 现在出发点为 $(1,1)$,必须按照种类 $1 \sim p$ 进行移动,即从种类 $x$ 的棋子出发,下一个目标必须是 $x+1$ 才行,直到走到种类为 $p$ 的棋子就终止.求最短路径. 题解: 我们先把棋子按照种类分组,分成 $p$ 组. $dp[i][j]$…
题目链接:http://codeforces.com/problemset/problem/552/C 题目大意:有101个砝码重量为w^0,w^1,....,w^100和一个重量为m的物体,问能否在天平两边放物品和砝码使其平衡.解题思路:将m化为w进制的数,接下来从低到高遍历没一位:如果第i位是0那OK:如果是1那就要把砝码wi放在天平另一边抵消:如果是w-1那就要把砝码wi放到天平同一边,使其变为0并进位,这时第i+1位的权+1:而如果是其他情况,那么肯定不能平衡了. 代码: #includ…
E. Vanya and Field time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vanya decided to walk in the field of size n × n cells. The field contains m apple trees, the i-th apple tree is at the c…
C. Vanya and Exams time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for al…
A. Vanya and Cubes time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vanya got n cubes. He decided to build a pyramid from them. Vanya wants to build the pyramid as follows: the top level of…
题目链接:https://vjudge.net/contest/224393#problem/E Vanya is doing his maths homework. He has an expression of form , where x1, x2, ..., xn are digits from 1 to 9, and sign  represents either a plus '+' or the multiplication sign '*'. Vanya needs to add…
题目链接 Vanya and Brackets 题目大意是给出一个只由1-9的数.乘号和加号组成的表达式,若要在这个表达式中加上一对括号,求加上括号的表达式的最大值. 我们发现,左括号的位置肯定是最左端或者某个乘号右边,右括号的位置肯定是最右段或者某个乘号左边. 而乘号最多只有15个,那么暴力枚举就可以了. #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i(a); i <= (b);…
677D. Vanya and Treasure 题意: 给定一张n*m的图,图上每个点标有1~p的值,你初始在(1,1)点,你必须按照V:1,2,3...p的顺序走图上的点,问你如何走时间最少. 思路: 我一开始想的思路感觉很巧妙,但是TLE了.就是把不同值的点放在不同的vector中,然后类似dp的从2更新最小距离到p.因为我这是暴力枚举点的,复杂度不对.后来发现这个思路还需要优化一下,就是把同一行的点放在一起,for一遍这一行属于V的点,就可以更新本行的信息了,再向下把列中属于v+1的更新…
E. Vanya and Field time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vanya decided to walk in the field of size n × n cells. The field contains m apple trees, the i-th apple tree is at the c…