CodeForces 245C-Game with Coins】的更多相关文章

D. Sorting the Coins time limit per test 1 second memory limit per test 512 megabytes input standard input output standard output Recently, Dima met with Sasha in a philatelic store, and since then they are collecting coins together. Their favorite o…
题意:有n个数的序列,n个数都为0,每次指定某个数变为1,当序列中第i个数为1,第i+1个数为0时,这两个数可交换,将序列从头到尾进行一次交换记为1次,直到某一次从头到尾的交换中没有任何两个数交换.序列的hard值为进行前面叙述过程中共进行的从头到尾交换的次数.每修改某个数为1,都输出对应的hard值. 分析: 1.如果第一次将最后一个数变为1,显然验证交换的次数为1,这一趟验证了没有任何两个数需要交换,因此结束. 2.如果第一次将中间的某个数变为1,显然我们在第一次从头到尾的交换中可以把这个1…
A. Coins 题目链接:http://codeforces.com/gym/101102/problem/A time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Hasan and Bahosain want to buy a new video game, they want to share the expenses. H…
http://codeforces.com/contest/876/problem/D D. Sorting the Coins time limit per test 1 second memory limit per test 512 megabytes input standard input output standard output Recently, Dima met with Sasha in a philatelic store, and since then they are…
传送门 Description Hasan and Bahosain want to buy a new video game, they want to share the expenses. Hasan has a set of N coins and Bahosain has a set of M coins. The video game costs W JDs. Find the number of ways in which they can pay exactly W JDs su…
http://codeforces.com/contest/876/problem/D 题意: 最开始有一串全部由"O"组成的字符串,现在给出n个数字,指的是每次把位置n上的"O"变为"X",之后会进行扫描. 扫描的规则是如果遇到一个字符为"X"并且这个字符后面的字符为"O",那么就交换. 如果哪一次扫描没有发生交换,那么扫描就停止. 现在给出的n个数字,问第一次需要扫描多少次,第二次需要扫描多少次....…
http://codeforces.com/contest/876/problem/D 题意:题意真是难懂,就是给一串序列,第i次操作会在p[x](1<=x<=i)这些位置放上硬币,然后从左到右观察,如果第i个位置有硬币但第i+1个位置没有硬币,那么互换,然后继续从第i+1个硬币开始看.直到不需要交换,需要计算出到终极状态需要多少步. 思路: 模拟. #include<iostream> #include<algorithm> #include<cstring&g…
D - Bags and Coins 思路:我们可以这样构造,最大的那个肯定是作为以一个树根,所以我们只要找到一个序列a1 + a2 + a3 .... + ak 并且ak为 所有点中最大的那个,那么我们a1, a2, a3..., ak-1 作为单独的点,其他没有涉及到的点套在ak的里面. 现在问题变成了找出a1, a2, a3, a4, ... , ak. 可以用bitset优化普通dp,因为要找路径,空间开不下,所以需要分段. #include<bits/stdc++.h> #defin…
A. Coins 题目链接:https://codeforc.es/contest/1061/problem/A 题意: 给出n和s,要在1-n中选数(可重复),问最少选多少数可以使其和为s. 题解: 贪心就行了. 代码如下: #include <cstdio> #include <algorithm> #include <iostream> using namespace std; int main(){ int a,s; cin>>a>>s;…
题目链接:http://codeforces.com/contest/876/problem/D 题解:一道简单的类似模拟的题目.其实就是看右边连出来有多少连续不需要换的假设位置为pos只要找pos-1左边一共有多少x就行(x是什么看一下样例) 第一个是正常解法第二个是用线段树写的,其实正常写就是模拟一下就好 #include<cstdio> #include<cstring> #include<algorithm> #include<cstdlib> #i…