vasya专题

Ural 1353 Milliard Vasya's Function(DP)

题目地址:Ural 1353 定义dp[i][j],表示当前位数为i位时,各位数和为j的个数。 对于第i位数来说,总可以看成在前i-1位后面加上一个0~9,所以状态转移方程就很容易出来了: dp[i][j]=dp[i][j]+dp[i][j-1]+dp[i][j-2]+.......+dp[i][j-9]; 最后统计即可。 代码如下: #include <iostream>#in

Codeforces Contest 1073 problem C Vasya and Robot —— 尺取

Vasya has got a robot which is situated on an infinite Cartesian plane, initially in the cell (0,0). Robot can perform the following four kinds of operations: U — move from (x,y) to (x,y+1); D — move

CODEFORCES --- 581A. Vasya the Hipster

581A. Vasya the Hipster 有一天,时髦精瓦夏决定数一数他有多少袜子。原来,他有 a 双红袜子和 b 双蓝袜子。按照最新的时尚,潮人应该穿不同颜色的袜子:左脚一只红袜子,右脚一只蓝袜子。每天早上,瓦夏都会穿上新袜子,然后在睡觉前扔掉,因为他不想洗袜子。 瓦夏想知道,他最多有多少天可以穿得很时髦,穿不同的袜子,之后,他又有多少天可以穿同样的袜子,直到袜子用完,或者用现有的袜子

cf Educational Codeforces Round 26 E. Vasya's Function

原题: E. Vasya’s Function time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Vasya is studying number theory. He has denoted a function f(a, b

cf Educational Codeforces Round 53 C. Vasya and Robot

原题: C. Vasya and Robot time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Vasya has got a robot which is situated on an infinite Cartesian plane,

Div. 2 ,C. Vasya and Robot

这个题目第一眼看并不是一个二分,仔细思考一下,要枚举长度,然后又要枚举起点,这里已经是O(n^2)的复杂度了,还要判断是否满足条件,如果预处理了,是能在O(1)的复杂度解决的。所以枚举长度这边可以用一个二分,这样复杂度就是O(nlogn)了,可以解决这个题目。 如何在O(n)的复杂度判断这个长度满不满足要求呢? 枚举起点就要O(n)了,接下来就是O(1)判断O不OK;预处理到第i个字母时往右往

Vasya and Petya's Game CodeForces - 577C

http://codeforces.com/problemset/problem/577/C 问序列中最少含几个数 使得1-n的每一个数都能用序列中的几个数相乘得到 把每个数都素因子分解为(2^p1)*(3^p2)*(5^p3)...这种形式 把2^1...2^p1等都扔数组里去个重就好   #include <bits/stdc++.h>using namespace std;con

Educational Codeforces Round 50 (Rated for Div. 2)D. Vasya and Arrays(前缀和)

题目链接:http://codeforces.com/contest/1036/problem/D 题意:给你两个序列,问是否可以转换(相邻相加)成两个相同的字符串,如果不可以输出 -1,如果可以问最大长度是多少。 思路:前缀和标记a数组,b数组统计贡献。 AC代码: #include <bits/stdc++.h>using namespace std;#define ll long

CF1093F Vasya and Array [DP+容斥]

传送门 我们令 f[i][k] 表示到 i , 最后一位为k的答案 , 减去不合法的答案 如果 i-len+1---- i 之间要么是 -1,要么是 j,那么就有可能不合法 j 可以接到 第 i-len的任意一个后面,所以  但是我们前一位可能就已经将不合法的 j 剪掉了,因为每当到不合法的第一个位置就会被剪掉 所以  #include<bits/stdc++.h>#defin

Codeforces Round #354 (Div. 2) - C. Vasya and String

C. Vasya and String 题目链接:http://codeforces.com/problemset/problem/676/C Description High school student Vasya got a string of length n as a birthda

D. Vasya and Chess

这个题略搞笑,蒙的。。。 奇偶判断了下就过了。。。   1 #include <iostream> 2 #include <stdio.h> 3 #include <algorithm> 4 #include <cstring> 5 #include <string.h> 6 #include <math.h> 7 #include <queue> 8 #include <

C. Vasya and Basketball

·真的是发现每题都有坑。。。 这题主要目的是求一个3分的分界线。题意就不多说了,主要说下自己的思路: 思路:     定义结构体,标识每个分数属于哪个队伍,然后将两个队伍的得分放在同一个数组中,从小到大进行排序。   之后从后向前。(即从大分数向小分数)   按照分数计算出Max{num1-num2};(num1为大于等于当前分数的队伍一的投球个数;num2为大于等于当前分数的队伍二的投

【Codeforces】Vasya and String(二分、前缀和)

题目链接 思路: 利用二分搜索和前缀和解决。 AC: #include<iostream>#include<algorithm>using namespace std;int n, k;string s;int sum[100005];int check(int x){for(int i=0 ; i+x<=n ; i++){if (sum[i+x]-sum[i]>=x-k |

Educational Codeforces Round 55 (Rated for Div. 2) A. Vasya and Book

题目链接: http://codeforces.com/contest/1082/problem/A A. Vasya and Book time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya is r

Educational Codeforces Round 48 (Rated for Div. 2) D. Vasya And The Matrix(构造)

描述 Now Vasya is taking an exam in mathematics. In order to get a good mark, Vasya needs to guess the matrix that the teacher has constructed! Vasya knows that the matrix consists of n rows and m col