题目链接: C. Vasya and String time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and '…
E - Vasya and Binary String 思路:区间dp + 记忆化搜索 转移方程看上一篇博客. 代码: #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize(4) #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define y1 y11 #define pi acos(-1.0)…
E - Vasya and a Tree 思路: dfs动态维护关于深度树状数组 返回时将当前节点的所有操作删除就能保证每次访问这个节点时只进行过根节点到当前节点这条路径上的操作 代码: #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize(4) #include<bits/stdc++.h> using namespace std; #define fi first #define se second #de…
E. Vasya and Good Sequences time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya has a sequence $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$. Vasya may pefrom the fol…
A. Vasya and Book time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya is reading a e-book. The file of the book consists of nn pages, numbered from 11 to nn. The screen is currently disp…
Discription Vasya is studying number theory. He has denoted a function f(a, b) such that: f(a, 0) = 0; f(a, b) = 1 + f(a, b - gcd(a, b)), where gcd(a, b) is the greatest common divisor of a and b. Vasya has two numbers x and y, and he wants to calcul…
D. Vasya and Triangle time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Vasya has got three integers n, m and k. He'd like to find three integer points (x1,y1), (x2,y2), (x3,y3), such that 0≤x1,x…
C. Vasya and Golden Ticket time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Recently Vasya found a golden ticket - a sequence which consists of n digits a1a2-an. Vasya considers a ticket to be l…
C. Vasya and Robot time limit per test: 1 secondmemory limit per test: 256 megabytesinput: standard inputoutput: standard output Vasya has got a robot which is situated on an infinite Cartesian plane, initially in the cell (0,0)(0,0)(0,0). Robot can…
链接 某个数x属于[1,n],至少询问哪些数“x是否是它的倍数”才能判断x.找出所有质因数和质因数的幂即可. #include<cstdio> #include<algorithm> #define N 1005 using namespace std; int n,pr[N],ans[N],cnt; int main(){ scanf("%d",&n); for(int i=2;i<=n;i++) if(!pr[i]) for(int j=i*2…
文章目录 A题 B题 C题 D题 E题 F题 G题 传送门 GGG题略难,膜了一波zhouyuyang{\color{red} zhouyuyang}zhouyuyang巨佬的代码. 其余都挺清真的. A题 传送门 题意:你有sss元钱,现在每颗糖ccc元,每买aaa颗会送你bbb颗,问最多买几颗糖. 思路:按照题意模拟. 代码: #include<bits/stdc++.h> #define ri register int #define int long long #define fi f…
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 枚举三分线(离散后)的位置 然后根据预处理的前缀和,快速算出两个队伍的分数. [代码] #include <bits/stdc++.h> using namespace std; const int N = 2e5; int n,m; int a[N+10],b[N+10],aa[2*N+100],bb[2*N+100]; map<int,int> dic; map<int,int> dic2; int main…
幸好我没有打这场,我VP的时候在C题就卡死了,我果然还是太菜了. A Vasya and Chocolate 题意:一个巧克力\(c\)元,买\(a\)赠\(b\),一共有\(n\)元,问能买几个巧克力. 小学数学题. B Vasya and Isolated Vertices 题意:\(n\)个点\(m\)条边的无向简单图最多和最少有几个不和任意点联通的点. 最少很好算,让每条边连接两个独立的点,答案就是\(n-2m\). 最多的话,就是让联通的点尽量组成完全图,这样消耗的边数最多,枚举有几个…
A. Vasya and Chocolate 模拟题.数据会爆\(int\),要开\(long\) \(long\) #include <iostream> #include <cstdio> using namespace std; typedef long long LL; int main(){ int T; scanf("%d", &T); while(T--){ LL s, a, b, c; scanf("%lld%lld%lld%l…
E - Domino Principle Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 56E Description Vasya is interested in arranging dominoes. He is fed up with common dominoes and he uses the dominoes…
A - Vasya and Socks Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 460A Description Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he…