CodeForces 518B. Tanya and Postcard】的更多相关文章

B. Tanya and Postcard time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little Tanya decided to present her dad a postcard on his Birthday. She has already created a message — string s of le…
题目链接:http://codeforces.com/problemset/problem/518/B 题目意思:给出字符串 s 和 t,如果 t 中有跟 s 完全相同的字母,数量等于或者多过 s,就将 s 这个数量加到 YAY! 的答案里,少于的话就加 t 中有的数量:如果 t 中有跟 s 相同的字母但是大小写不对应(例如A-a,z-Z),就加到 WHOOPS 的答案里. 举个例子就很容易明白了.例如 s 和 t 分别为: ncMeXssLHS uwyeMcaFatpInZVdEYpwJQSn…
题意:给定两个字符串,然后从第二个中找和第一个相同的,如果大小写相同,那么就是YAY,如果大小写不同,那就是WHOOPS.YAY要尽量多,其次WHOOPS也要尽量多. 析:这个题并不难,难在读题懂题意.首先把两个字符串的的每个字符存起来,然后,先扫一遍,把所有的能YAY的都选出来,剩下的再尽量先WHOOPS. 代码如下: #include <iostream> #include <cstdio> #include <algorithm> #include <vec…
B. Tanya and Postcard time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little Tanya decided to present her dad a postcard on his Birthday. She has already created a message — string s of le…
Tanya and Postcard time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little Tanya decided to present her dad a postcard on his Birthday. She has already created a message — string s of lengt…
Description While dad was at work, a little girl Tanya decided to play with dad characters. She has written all the possible n three-letter continuous substrings of the password on pieces of paper, one for each piece of paper, and threw the password…
题目链接:http://codeforces.com/problemset/problem/659/C 题意: n是已经有的数字,m是可用的最大数字和 要求选自己没有的数字,且这些数字的数字和不能超过m 且要求可选的数字的数目越多越好 输出一种答案即可 解题思路: 刚开始想开一个bool型的1e9的数组,然后判断即可 可是交上去发现内存超限 后来把1e9的数组改成2*1e6的数组即可 具体原因应该从数学数字和方面考虑 具体代码如下: #include<bits/stdc++.h> using…
题目链接 将给出的已经有了的排序, 在前面加上0, 后面加上1e9+1. 然后对相邻的两项判断. 如果相邻两项之间的数的和小于m, 那么全都选上, m减去相应的值. 如果大于m, 那么二分判断最多能选多少个. #include <iostream> #include <vector> #include <cstdio> #include <cstring> #include <algorithm> #include <complex>…
题目链接 给你n个长度为3的子串, 这些子串是由一个长度为n+2的串分割得来的, 求原串, 如果给出的不合法, 输出-1. 一个欧拉通路的题, 将子串的前两个字符和后两个字符看成一个点, 比如acb, 就是ac->cb. 然后建图. #include <iostream> #include <vector> #include <cstdio> #include <cstring> #include <algorithm> #include…
A. Vitaly and Strings 题意:两个字符串s,t,是否存在满足:s < r < t 的r字符串 字符转处理:字典序排序 很巧妙的方法,因为s < t,只要找比t字典序稍微小一点的和s比较就行了 具体方法和数字减1相类似,从"个位"减1,如果是0,从前面借1 !strcmp (t, s):如果t < s 或者 t > s (不可能)则输出,t == s 则输出NO #include <cstdio> #include <i…
Tanya and Postcard CodeForces - 518B 有个小女孩决定给他的爸爸寄明信片.她已经想好了一句话(即长度为n的字符串s),包括大写和小写英文字母.但是他不会写字,所以她决定将报纸里的字母剪下来贴到明信片上,最好能够把字符串s拼凑出来.报纸里包含字符串t,包括大写和小写英文字母.我们知道,t的长度大于或等于串s的长度.   如果在s串中的某些位置上的字母能够在报纸串t中找到对应一模一样的字符,那么,她会高兴地喊“耶!”,如果在s串中的某些位置的字母只能在报纸串t中找到…
D. Tanya and Password Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/508/problem/D Description While dad was at work, a little girl Tanya decided to play with dad's password to his secret database. Dad's password is a stri…
B. Kolya and Tanya Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/584/problem/B Description Kolya loves putting gnomes at the circle table and giving them coins, and Tanya loves studying triplets of gnomes, sitting in the v…
C. Tanya and Toys 题目链接http://codeforces.com/contest/659/problem/C Description In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collectio…
C. Tanya and Toys 题目连接: http://www.codeforces.com/contest/659/problem/C Description In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new col…
Tanya has nn candies numbered from 11 to nn. The ii-th candy has the weight aiai. She plans to eat exactly n−1n−1 candies and give the remaining candy to her dad. Tanya eats candies in order of increasing their numbers, exactly one candy per day. You…
http://codeforces.com/contest/1118/problem/B 题目大意,给你一个序列,删去一个数值之后,要求剩下序列奇数和偶数的和相同,问有多少种删法. 思路:预处理奇数和偶数和即可 (算法能力康复性训练中......) //看看会不会爆int!数组会不会少了一维! //取物问题一定要小心先手胜利的条件 #include <bits/stdc++.h> #pragma comment(linker,"/STACK:102400000,102400000&q…
B. Our Tanya is Crying Out Loud time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Right now she actually isn't. But she will be, if you don't solve this problem. You are given integers n, k,…
原题链接:http://codeforces.com/contest/584/problem/B 题意: 有3*n个人围成一个圈,每个人可以分配1到3个硬币,但是相邻为n的三个人的和不能是6,问你有多少种方案 题解: 考虑反面,则答案是: $$27^n-(3!+1)^n$$ 代码: #include<iostream> #include<cstring> #include<cstdio> using namespace std; typedef long long LL…
题目链接: C. Tanya and Toys time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered wi…
[题目链接]:http://codeforces.com/problemset/problem/508/D [题意] 给你一个字符的所有连续3个的子串; 让你复原出原串; (包含小写.大写字母以及数字); [题解] 相当于给你n条边; 每条边的两端; 一个点是由s[0]s[1]组成的; 另一端是s[1]s[2]组成的; (用map很容易做hash..) 然后让你求一个欧拉通路; 即经过所有的边仅一次的路径(一笔画); 有向图; 可以先算出每个点的入度和出度; 设入度和出度的差的点数为1的个数为c…
大意:给定n个长为3的子串, 求一个长为n+2的字符串包含所有子串. 相邻两个字符开一个节点, 建图跑欧拉回路, 若存在的话长度一定是$\le n+2$.…
题意:有\(n\)个数,你可以任意去除某个位置的元素然后得到一个新数组,使得新数组奇数位和偶数的元素相等,现在问你有多少种情况合法. 题解:先求个后缀和,然后遍历,记录奇数和偶数位置的前缀和,删去\(i\)位置的元素,意味着原来\(i\)位置之后的奇数和变成了偶数和,偶数和变成了奇数和,将前缀和与差位的后缀和相加判断一下即可. 代码: int n; ll a[N]; ll suf1[N],suf2[N]; ll cnt1,cnt2; int main() { ios::sync_with_std…
---恢复内容开始--- Codeforces Round #324 (Div. 2) Problem A 题目大意:给二个数n.t,求一个n位数能够被t整除,存在多组解时输出任意一组,不存在时输出“-1”. 数据范围: 1 ≤ n ≤ 100, 2 ≤ t ≤ 10 so easy!首先考虑无解的时候,只有当n==1,t==10是无解,其他情况都存在解.很容易想到最简单的n位数能被t整除的数是,t个n组成的数. 参考代码: By Royecode, contest: Codeforces Ro…
所有的题目都可以在CodeForces上查看 中间看起来有很多场比赛我没有写了 其实是因为有题目没改完 因为我不想改,所以就没有写了(大部分题目还是改完了的) 我还是觉得如果是打了的比赛就一场一场写比较好 要不然以后就写有难度的.比较好的题目?? 这场比赛时间真心良心(只是没吃饭) 状态也很好,考场上把\(ABCDE\)切了 \(F\)是自己弃疗了... 不管啦不管啦,进入正题了 题解 A.Points on the line 翻译: 给定一个长度为\(n\)的数组 问最少删去几个数之后使得最大…
A. Water Buying 链接:http://codeforces.com/contest/1118/problem/A 实现代码: #include<bits/stdc++.h> using namespace std; #define ll long long int main() { ll n,a,b,m; cin>>n; ;i <= n;i ++){ cin>>m>>a>>b; <= b) cout<<m*a…
A. Snowball 链接:http://codeforces.com/contest/1099/problem/A 思路:模拟 代码: #include<bits/stdc++.h> using namespace std; #define ll long long #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 #define mid int m = (l + r) >> 1 ; ],y[]; int…
链接:https://codeforces.com/contest/659 A - Round House - [取模] AC代码: #include<bits/stdc++.h> using namespace std; int n,a,b; int main() { cin>>n>>a>>b; a=(a-+b); ) a+=n; a%=n; cout<<a+<<endl; } B - Qualifying Contest - [水…
链接:https://codeforces.com/contest/584 A - Olesya and Rodion - [水] 题解:注意到 $t$ 的范围是 $[2,10]$,对于位数小于 $2 \times 3 \times \cdots \times 10 = 3628800$ 的数,暴力枚举去找:否则就直接在 $3628800$ 后面补零即可. AC代码: #include<bits/stdc++.h> using namespace std; int n,t; ]; int ma…
链接:https://codeforces.com/contest/1099 A - Snowball - [模拟水题] 题意:有一个雪球从山顶滚落,山坡上有两块石头,每秒钟会一次发生三件事:1.雪球增重,数值为当前高度:2.如果当前高度有一块石头,则会撞到石头,损失跟石头同样重的重量:3.往下移动一米.此外,若雪球的重量如果变为负数,则自动变成零.雪球会在高度为零处停止滚动,问停止滚动时雪球重量. 题解:模拟水题. AC代码: #include<bits/stdc++.h> using na…