![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
codeforces
文章平均质量分 86
LzyRapX
Just For Fun .
展开
-
Codeforces Round #364 (Div. 2) C. They Are Everywhere (尺取法)
C. They Are Everywheretime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSergei B., the young coach of Pokemo原创 2016-08-14 00:37:01 · 454 阅读 · 0 评论 -
Codeforces Round #402 (Div. 2) (A-D)
CF #402 div2A题:数学。具体看代码吧。很容易明白的。#includeusing namespace std;int a[6],b[6];int main(){ int n, x, y; cin>>n; if(n==1){ cin>>x>>y; if(x==y) printf("0\n"); el原创 2017-02-27 19:19:03 · 309 阅读 · 0 评论 -
Codeforces Round #396 (Div. 2) E. Mahmoud and a xor trip(树形dp+二进制按位拆分)
CF E题解:给你一棵n个节点的树以及每个节点的权值,点权。dis(u,v)表示节点u到v路径上的异或和,求不大于i的节点与i组成的有序对的距离的和(1题解:树形dp。因为XOR时每一位的操作都是独立的,所以我们可以考虑将这些数的二进制按位拆分考虑。枚举二进制的每一位对,统计对答案的贡献。考虑当前的根节点为cur,那么:dp[cur][0]表示以cur为根节点的异或值为0的路径的数量。原创 2017-02-19 09:49:30 · 651 阅读 · 0 评论 -
Codeforces Round #397 E. Tree Folding (树形dp)
E. Tree Foldingtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputVanya wants to minimize a tree. He can perf原创 2017-02-19 18:17:36 · 941 阅读 · 0 评论 -
Editorial Divide by Zero and Codeforces Round #399 (Div. 1+2, combined) (A~F)
CF #399A题:水题代码:#includeusing namespace std;int a[100010];int main(){ int n; cin>>n; for(int i=0;i<n;i++){ cin>>a[i]; //s.insert(a); } int ans=0; if(n<=2)return 0*printf("%d",0);原创 2017-02-22 22:46:21 · 594 阅读 · 2 评论 -
Codeforces Round #401 (Div. 2) (A~E)
CF #401(链接)A题:枚举一下题意,然后找循环节就可以了。(不找规律会TLE的)代码:#includeusing namespace std;int a[3]={0,1,2};int main(){ int n,x; cin>>n>>x; n=n%6; for(int i=0;i<n;i++){ if(i%2==0){ swap(a[0],a[原创 2017-02-25 14:49:24 · 329 阅读 · 0 评论 -
Abbyy Cup 2.0 - Final (unofficial) A1(贪心)
A1. Beaver's Calculator 1.0time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Smart Beaver from ABBYY has原创 2017-03-05 13:35:51 · 603 阅读 · 0 评论 -
D. Lizards and Basements 2 (DFS+最优性剪枝)
点击打开链接http://codeforces.com/contest/6/problem/DD. Lizards and Basements 2This is simplified version of the problem used on the original contest. The original problem seems原创 2017-04-09 21:31:35 · 846 阅读 · 0 评论 -
#6 Div2 E. Exposition(RMQ+最长连续子序列变形)
点击打开链接http://codeforces.com/contest/6/problem/EE. ExpositionThere are several days left before the fiftieth birthday of a famous Berland's writer Berlbury. In this connection the原创 2017-04-10 08:44:47 · 438 阅读 · 0 评论 -
#7 B. Memory Manager(细节+模拟)
题目链接:点击打开链接http://www.codeforces.com/contest/7/problem/BDescriptionThere is little time left before the release of the first national operating system BerlOS. Some of its components ar原创 2017-04-10 15:08:02 · 1287 阅读 · 0 评论 -
Codeforces Round #396 (Div. 2) D. Mahmoud and a Dictionary (并查集)
D. Mahmoud and a Dictionarytime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMahmoud wants to write a new di原创 2017-02-17 19:35:17 · 421 阅读 · 0 评论 -
Codeforces Round #396 (Div. 2) C. Mahmoud and a Message (新手DP)
C. Mahmoud and a Messagetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMahmoud wrote a message s of lengt原创 2017-02-17 15:12:00 · 510 阅读 · 0 评论 -
Codeforces Round #363 (Div. 1) A. Vacations(dp)
A. Vacationstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya has n days of vacations! So he decided to原创 2016-08-14 03:11:51 · 470 阅读 · 0 评论 -
codeforces AIM Tech Round 3 (Div. 2) (A~D)
A. Juicertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputKolya is going to make fresh orange juice. He has原创 2016-08-25 17:58:18 · 611 阅读 · 0 评论 -
AIM Tech Round 3 (Div. 2) E. Centroids (树形dp)
E. Centroidstime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputTree is a connected acyclic graph. Suppose you原创 2016-08-26 00:27:27 · 1351 阅读 · 0 评论 -
Codeforces Round #344 (Div. 2) E. Product Sum (三分)
E. Product Sumtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBlake is the boss of Kris, however, this does原创 2016-09-06 00:00:53 · 632 阅读 · 0 评论 -
Codeforces Round #344 (Div. 2) A. Interview (位运算)
A. Interviewtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBlake is a CEO of a large company called "Blake原创 2016-09-06 14:15:19 · 409 阅读 · 0 评论 -
Codeforces Round #344 (Div. 2) B. Print Check (模拟)
B. Print Checktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputKris works in a large company "Blake Technolo原创 2016-09-07 13:00:06 · 709 阅读 · 0 评论 -
Codeforces Round #344 (Div. 2) C. Report (脑洞题)
C. Reporttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEach month Blake gets the report containing main原创 2016-09-07 21:14:06 · 527 阅读 · 0 评论 -
Codeforces Round #344 (Div. 2) D. Messenger (KMP)
D. Messengertime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputEach employee of the "Blake Techologies" compa原创 2016-09-07 23:52:36 · 594 阅读 · 0 评论 -
Codeforces Round #397 D. Artsem and Saunders(构造)
D. Artsem and Saunderstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputArtsem has a friend Saunders from Un原创 2017-02-17 10:57:01 · 644 阅读 · 0 评论 -
#7 C. Line (扩展欧几里得)
题目链接:点击打开链接http://codeforces.com/contest/7/problem/CC. LineA line on the plane is described by an equation Ax + By + C = 0. You are to find any point on this line, whose co原创 2017-04-10 20:50:48 · 453 阅读 · 0 评论 -
C. Commentator problem (模拟退火)
点击打开链接http://codeforces.com/contest/2/problem/CDescriptionThe Olympic Games in Bercouver are in full swing now. Here everyone has their own objectives: sportsmen compete for medals, and原创 2017-04-02 00:04:40 · 688 阅读 · 0 评论 -
B. Lorry (贪心)
点击打开链接http://codeforces.com/contest/3/problem/BB. LorryDescriptionA group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot t原创 2017-04-02 17:26:13 · 710 阅读 · 0 评论 -
#8 C. Looking for Order (状压dp + 路径记忆)
题目链接:点击打开链接http://codeforces.com/contest/8/problem/C题意:給定原点 ( sx, sy ),以及 N 個坐标 X, Y。每次至多选两个坐标,依序拜访完后,回到原点。问你最好的路径,使得总路径最小。兩個坐标的路径长为欧几里得距离的平方。题解:看N(N状压dp。dp[ i ] : 已完成 i 的拜访,此时的最小总原创 2017-04-21 14:47:48 · 818 阅读 · 0 评论 -
Codeforces Round #411 (Div. 1)(A~D)题解
题目链接:#411 (Div. 1)差点翻船。题解:A.A. 这个推导一下,找一下规律就可以了。答案是:ans=(n+1)2−1ans=\frac{(n+1)}{2}-1。B.B. 容易发现,无论我们要对字符串操作几遍,我们最后都是要把字符串变成bbbb...aaaabbbb...aaaa这种形式的。发现每个aa能把它后边的bb变成22个bb,而aa要变的次数一定是后面bb的个数,所以从后面开始遍历原创 2017-05-06 02:56:28 · 1058 阅读 · 0 评论 -
Educational Codeforces Round 20 G. Periodic RMQ Problem(线段树动态开点)
题目链接: 点击我打开题目题意: 给你一个nn个数的序列,将它复制粘贴kk次得到新的序列。 在新的序列上有22个操作:区间赋值,区间取最小值。题解:其实就是线段树动态开点。其他和普通的线段树差不多吧。代码:#include<bits/stdc++.h>using namespace std;const int mod=1e9+7;typedef long long ll;#define原创 2017-05-15 20:05:51 · 507 阅读 · 0 评论 -
Educational Codeforces Round 20 F. Coprime Subsequences(莫比乌斯反演)
题目链接: 点击我打开题目链接 题意: 给你一个序列,问你有多少个子序列的gcd(子序列)=1gcd(子序列)=1。题解: 考虑一下容斥,枚举gcdgcd然后容斥,先加上所有子序列的总个数2n−12^n−1,然后减去gcd=2gcd=2的,然后减去gcd=3gcd=3的,然后减去gcd=5gcd=5的,然后加上gcd=6gcd=6的….为什么不减去gcd=4gcd=4呢? 因为这些的贡献统原创 2017-05-15 16:25:37 · 486 阅读 · 0 评论 -
Codeforces Beta Round #8 E. Beads (数位dp)
题目链接:点击打开题目题意:将所有二进制串(只允许前导 00)中,同时满足字典序不小于其逆序串,取反串和逆序取反串(三种都要满足)的串提出来,按字典序排序,求第mm个。 n<=50,k<=1016。n <= 50, k <= 10^16。题解:显然满足题意的二进制串的首位必须是00。考虑一位一位地确定答案串。假设已经确定了答案串的前kk位,我们假设第k+1k + 1位是00,则要设法统计出满足条件的原创 2017-04-25 23:44:22 · 826 阅读 · 0 评论 -
#51 Codeforces-E. Very simple problem (计算几何)(点被多少个三角形包含)
题目链接:点击打开链接http://codeforces.com/contest/55/problem/E题意:给定一个凸多边形,给定一些点,问你这些点被多少个三角形包含?题解:平面内n点任意三点不共线可组成n*(n-1)*(n-2)/6个三角形。求出不包含该点的三角形个数,用总个数减去这些即可。即用n*n(n-1)*(n-2)/6 - 不包含该点的三角形个数?原创 2017-04-16 22:15:32 · 510 阅读 · 0 评论 -
Codeforces Beta Round #1 C. Ancient Berland Circus (计算几何)
C. Ancient Berland Circustime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputNowadays all circuses in Berland h原创 2016-09-10 01:16:48 · 747 阅读 · 0 评论 -
#9 (Div. 2 Only) B. Running Student (枚举)
题目链接:点击打开链接http://codeforces.com/contest/9/problem/B题意:给你车的速度,人跑步的速度,和站点的坐标,以及学校的坐标。问你从哪个站点下车可以最快到达学校?题解:直接枚举下车的站点。AC代码:#include using namespace std;double dis(double x1,double原创 2017-04-27 13:17:07 · 696 阅读 · 0 评论 -
#9 (Div. 2 Only) D. How many trees? (dp)(好题)
题目链接:点击打开链接http://codeforces.com/contest/9/problem/D题意:规定一个二叉树,有n个节点,问你深度大于等于h的一共有多少种?这个二叉树满足左儿子比自己小,右儿子比自己大的特性。题解:dp。假设dp[ i ][ j ]表示当前用了 i 个节点,深度度小于等于 j 的方案数。如果我们直接求深度大于等于h有点难。原创 2017-04-27 14:36:33 · 506 阅读 · 0 评论 -
#51 D. Beautiful numbers (数位dp+离散化)
题目链接:点击打开链接http://codeforces.com/contest/55/problem/D题意:定义:Beautiful Numbers : 这个数能整除它的所有位上非零整数。问你[ l , r ] 之间的Beautiful Numbers的个数。题解:数位dp。如果一个数能整除它的所有的非零数位,那么相当于它能整除个位数的最小公倍数。因此记忆化原创 2017-04-15 19:44:35 · 425 阅读 · 0 评论 -
VK cup Div1 C. Vulnerable Kerbals (扩展gcd+DAG+最长路)
题目链接:点击打开链接http://codeforces.com/contest/800/problem/CC. Vulnerable Kerbals题意:给定n个0~m-1内的数和m,构造一个尽可能长的所有元素都在0~m-1内的数列,并且使所有前缀积模m不相同且不在n个数中出现过。题解:如果前 i 个数的前缀积为x,前i+1个数的前缀积可以为y当且仅当ax-b原创 2017-04-19 14:08:17 · 1217 阅读 · 0 评论 -
D. Least Cost Bracket Sequence (贪心)
点击打开链接http://codeforces.com/contest/3/problem/DD. Least Cost Bracket SequenceDescription:This is yet another problem on regular bracket sequences.A bracket sequence原创 2017-04-02 23:38:39 · 798 阅读 · 0 评论 -
#7 D. Palindrome Degree (manacher + dp)
题目链接:点击打开链接http://codeforces.com/contest/7/problem/DD. Palindrome DegreeString s of length n is called k-palindrome, if it is a palindrome itself, and its prefix and su原创 2017-04-12 23:55:17 · 687 阅读 · 0 评论 -
VK Cup 2017 B. Volatile Kite (Div . 1)(凸多边形退化)(计算几何)
题目链接:点击打开链接http://codeforces.com/contest/801/problem/D题意:给定一个凸n边形,你可以移动每个点在x范围之内,问你x最大为多少时,这个n边形仍为凸边形? 即不能退化为凹多边形。题解:如果想要一个凸多边形不退化为凹多边形,当一个点A和它相连的两个点B、 C退化为成一条直线的时候就不行了,那么在极限的情况下,任意的相邻原创 2017-04-17 21:18:11 · 720 阅读 · 0 评论 -
E. Bindian Signalizing (拆环成链)(好题)
点击打开链接http://codeforces.com/contest/5/problem/EE. Bindian SignalizingEveryone knows that long ago on the territory of present-day Berland there lived Bindian tribes. Their capital wa原创 2017-04-05 13:42:39 · 1199 阅读 · 0 评论 -
#10 C. Digital Root (数论)
题目链接: 点击打开链接 http://codeforces.com/contest/10/problem/C 题意: 定义d(x)d(x)为xx的数字根,找出nn以内的满足d(z)=d(d(x)⋅d(y))d(z)=d(d(x)⋅d(y))但不满足x⋅y=zx⋅y=z这样的x,y,zx,y,z有多少组? d(A)d(A)是数根,其实就是AA%9. 题解: 容斥,首先把所有的d(A)d原创 2017-04-28 16:46:10 · 549 阅读 · 0 评论