A. Stock Arbitraging 直接上代码: #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<queue> #include<stack> #include<set> #include<map> #include<vector> #include<cmath>…
Problem  Codeforces Round #556 (Div. 2) - D. Three Religions Time Limit: 1000 mSec Problem Description Input Output Sample Input 51 2 1 2 1 Sample Output 1 1 1 2 2 题解:这个题有做慢了,这种题做慢了和没做出来区别不大... 读题的时候脑子里还意识到素数除了2都是奇数,读完之后就脑子里就只剩欧拉筛了,贪心地构造使得前缀和是连续的素数,那…
Problem  Codeforces Round #556 (Div. 2) - D. Three Religions Time Limit: 3000 mSec Problem Description Input Output Sample Input 6 8abdabc+ 1 a+ 1 d+ 2 b+ 2 c+ 3 a+ 3 b+ 1 c- 2 Sample Output YESYESYESYESYESYESNOYES 题解:动态规划,意识到这个题是动态规划之后难点在于要优化什么东西,本题…
Codeforces Round #556 (Div. 1) A. Prefix Sum Primes 给你一堆1,2,你可以任意排序,要求你输出的数列的前缀和中质数个数最大. 发现只有\(2\)是偶质数,那么我们先放一个\(2\),再放一个\(1\),接下来把\(2\)全部放掉再把\(1\)全部放掉就行了. #include<iostream> #include<cstdio> using namespace std; inline int read() { int x=0;bo…
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate it n = int(raw_input()) s = "" a = ["I hate that ","I love that ", "I hate it","I love it"] for i in ran…
Codeforces Round #247 (Div. 2) http://codeforces.com/contest/431  代码均已投放:https://github.com/illuz/WayToACM/tree/master/CodeForces/431 A - Black Square 题目地址 题意:  Jury玩别踩白块,游戏中有四个区域,Jury点每一个区域要消耗ai的卡路里,给出踩白块的序列,问要消耗多少卡路里. 分析:  模拟水题.. 代码: /* * Author: i…
Brain's Photos 题目链接: http://codeforces.com/contest/707/problem/A Description Small, but very brave, mouse Brain was not accepted to summer school of young villains. He was upset and decided to postpone his plans of taking over the world, but to becom…
比赛链接 A 贪心 #include <cstdlib> #include <cstdio> #include <algorithm> #include <cmath> #include <cstring> #include <queue> #include <vector> #include <set> using namespace std; const int N = 1005; int a[N], b[…
A http://codeforces.com/contest/560/problem/A 推断给出的数能否组成全部自然数. 水题 int a[1010]; bool b[1000010]; int main() { int n; while (scanf("%d", &n) != EOF) { memset(b,false,sizeof(b)); for (int i = 1; i <= n; i++) { scanf("%d", &a[i]…
题目链接:http://codeforces.com/contest/1150/problem/D 题目大意: 你有一个参考串 s 和三个装载字符串的容器 vec[0..2] ,然后还有 q 次操作,每次操作你可以选择3个容器中的任意一个容器,往这个容器的末尾添加一个字符,或者从这个容器的末尾取出一个字符. 每一次操作之后,你都需要判断:三个容器的字符串能够表示成 s 的三个不重叠的子序列. 比如,如果你的参考串 s 是: abdabc 而三个容器对应的字符串是: vec[0]:ad vec[1…