链接:https://www.nowcoder.com/acm/contest/147/E 来源:牛客网 题目描述 Niuniu likes to play OSU! We simplify the game OSU to the following problem. Given n and m, there are n clicks. Each click may success or fail. For a continuous success sequence with length X,…
链接:https://www.nowcoder.com/acm/contest/142/A 来源:牛客网 题目描述 A ternary , , or . Chiaki has a ternary in the string, and finally the first character will disappear. For example, ``'' after another second. Chiaki would like to know the number of seconds n…
链接:https://ac.nowcoder.com/acm/contest/297/D 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld 题目描述 旅行到K国的小w发现K国有着很多物美价廉的商品,他想要买一些商品. 结果一掏钱包,包里只剩下n张K国的纸币了,说起来也奇怪,K国纸币并不像其他国家一样都是1元,5元,10元-而是各种奇怪的面值,所以找零就不是很方便. 已知商店里的商品价格…
解题思路:二分图的最大匹配,但这题是所有点都遍历一遍,所以答案/2: 代码: #include<iostream> #include<algorithm> #include<cstdio> #include<cstring> #define maxn 100500 using namespace std; struct Edge { int next; int to; int fa; int w; }edge[maxn]; char s[60][60]; i…
 题目链接:https://ac.nowcoder.com/acm/contest/887/H  题意: 给定A,B,C问在[1,A]和[1,B]中有多少对x,y满足x&y>C或者x^y<C. 数据范围:1<=A,B,C<=1e9,测试用例 T<=100 . 思路: 根据题意本题可以用数位dp来解. /* and 0&0=0; 0&1=0; 1&0=0; 1&1=1; xor 0 ^ 0=0: 0 ^ 1=1: 1^ 0=1: 1^1=…
题目地址:https://www.nowcoder.com/pat/6/problem/4058 题解:用数组下标当学校编号.输入一次数据的时候,直接在相应数组下标位置累加内容,同时更新最大的总分的学校 /** * Copyright(c) * All rights reserved. * Author : YCute * Date : 2019-11-19-21.01.44 * Description : 输入时处理数据 */ #include<iostream> #include<c…
#include<bits/stdc++.h>using namespace std;vector<int>tree[1000010];int sum=0;int dfs(int x, int y){    int first = 0, second = 0;    for (int i = 0; i < tree[y].size(); ++i)    {        if (tree[y][i] == x)            continue;        int…
链接:牛客网暑期ACM多校训练营(第四场):A Ternary String 题意:给出一段数列 s,只包含 0.1.2 三种数.每秒在每个 2 后面会插入一个 1 ,每个 1 后面会插入一个 0,之后第一个数字消失.求最后为空串需要多少秒. 题解: (1)如果在消除一个 0 前经过了 n 秒,那么消掉这个 0 需要 n + 1 秒. (2)如果在消除一个 1 前经过了 n 秒,那么消掉这个 1 与其产生的所有数需要 (n + 1) * 2 秒. (3)如果在消除一个 2 前经过了 n 秒,那么…
链接:牛客网暑期ACM多校训练营(第五场):F - take 题意: Kanade有n个盒子,第i个盒子有p [i]概率有一个d [i]大小的钻石. 起初,Kanade有一颗0号钻石.她将从第1到第n打开盒子.当她打开一个盒子时,如果里面有一颗钻石并且比它的钻石大,那么她将用她的钻石代替它. 现在您需要计算预期的替换次数. 您只需要输出答案模块998244353. 注意:如果x%998244353 = y * d%998244353,那么我们表示x / y%998244353 = d%99824…
牛客网暑期ACM多校训练营(第二场) 水博客. A.run 题意就是一个人一秒可以走1步或者跑K步,不能连续跑2秒,他从0开始移动,移动到[L,R]的某一点就可以结束.问一共有多少种移动的方式. 个人感觉是带约束条件的超级楼梯问题.说是dp其实就是递推吧.只要连续的两秒不是跑的就可以.所以在已经跑了i步的时候,直接考虑最后一步是跑的还是走的就可以了. 所以公式就是dp[i]=dp[i-1]+dp[i-1-k];然后前缀和预处理一下,直接从L的for到R的就可以了. 反正乱七八糟就出来了.现在写题…