-
CF#470 Div2 B. Primal SportAlice and Bob begin their day with a quick game. They first choose a starting number X0 ≥ 3 and try to reach one million by the process described below. Alice goes first and then they take alternating turns. In the i-th turn, the player whose turn it is selects a prime number smaller than the curr
-
CF#470 Div2 D. Perfect SecurityAlice has a very important message M consisting of some non-negative integers that she wants to keep secret from Eve. Alice knows that the only theoretically secure cipher is one-time pad. Alice generates a random key K of the length equal to the message's length. Alice co
-
Codeforces 915C Permute Digits题目蓝链 Description You are given two positive integer numbers a and b. Permute (change order) of the digits of a to construct maximal number not exceeding b. No number in input and/or output can start with the digit 0. It is allowed to leave a as it is. Input The first line contains i
-
Codeforces 915D Almost Acyclic Graph题目蓝链 Description You are given a directed graph consisting of n vertices and m edges (each edge is directed, so it can be traversed in only one direction). You are allowed to remove at most one edge from it. Can you make this graph acyclic by removing at most one edge from it? A directed gra
-
Codeforces 911D Inversion Counting题目蓝链 Description A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and ai < aj. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2,
-
CF#259 Div1 A Little Pony and Expected MaximumTwilight Sparkle was playing Ludo with her friends Rainbow Dash, Apple Jack and Flutter Shy. But she kept losing. Having returned to the castle, Twilight Sparkle became interested in the dice that were used in the game. The dice has m faces: the first face of the dice contains a dot, the
-
CF GYM100548 Problem G. The Problem to Slow Down YouDescriptionAfter finishing his homework, our problem setter Federmann decided to kill time by hangingaround online. He found a cool chat room that discusses competitive programming. Federmannhas already joined lot of such chat rooms, but this one is special. Once he entered thechat room, he noticed
-
CF161D Distance in tree题意:一棵无边权(边长均为1)树,求出树上权值=k的路径条数。 题目分析: 乍一看跟POJ1741很像啊,只是<=k变成了=k。 这道题应该还是可以使用根的答案-子树中多统计的答案的思想来做的,不过在做这道题的时候一直没有能够推出很简洁而且正确的式子,WA了许多次之后去网上找题解,发现可以直接暴力统计——也就是每一次搜索出一个路径长度之后找到之前的长度与其互补的路径,更新答案,这样就可以避免重复了。 以后注意如果真的推不出式子,可以采用这道题的方法。 #include<cstdio>#include<cstring>#includCodeforces 点分治 181 0 0
-
Codeforces Round #390 (Div. 2)A. Lesha and array splittingTags:贪心 题意:划分成若干段,使得各自的和不为0。 题解:如果总和为0,找到第一个不为0的数字,分成两段;否则就整个作为一段。 代码: #include <bits/stdc++.h> int a[105]; int n; int main() { scanf("%d", &n); int sum = 0,Codeforces 209 0 0
-
Codeforces Round #389 (Div. 2)A. Santa Claus and a Place in a ClassTags:数学 找k所在的行号和列号。除下,模下就好了。 #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e5 + 5; int main() { int n, m, kCodeforces 292 1 0