Problem Statement You are given two ints: n and m. Let D be the number of permutations of the set {1,2,-,n+m} such that the first m values are not fixed points of the permutation. Formally, we are interested in permutations p such that for each j bet…
Problem Statement Alice has a string s of lowercase letters. The string is written on a wall. Alice also has a set of cards. Each card contains a single letter. Alice can take any card and glue it on top of one of the letters of s. She may use any su…
Problem Statement You are given a vector t that describes a rectangular table of zeroes and ones. Each character in t is either '0' or '1'. We say that a table is nice if there are two sequences x, y of zeroes and ones such that for each valid pair o…
# [Codeforces #312 div2 A]Lala Land and Apple Trees 首先,此题的大意是在一条坐标轴上,有\(n\)个点,每个点的权值为\(a_{i}\),第一次从原点开始走,方向自选(<- or ->),在过程中,若遇到一个权值>0的点,则将此权值计入答案,并归零.当次.此方向上的所有点均为0后,输出此时的答案. 然后,进行分析: 我们很容易想到这是一个贪心,我们将正的和负的分别存入两个数组,最初的方向为: \(zhengsum > fusum…
Problem Statement A string of zeros and ones is called an alternating string if no two adjacent characters are the same. Examples of alternating strings: "1", "10101", "0101010101". You are given a string s. Each character of…
Problem Statement You are given four ints: n, k, x, and y. The ints n and k describe a simple undirected graph. The graph has n nodes, numbered 1 through n. Two distinct vertices i and j are connected by an edge if and only if gcd(i, j) > k. Here, gc…
链接:http://codeforces.com/contest/984/problem/C 题意 三个数p, q, b, 求p/q在b进制下小数点后是否是有限位. 思路 题意转化为是否q|p*b^x,即看b和q有没有相同的质因子.如果用筛选质因子的话1e18的数会超时,所以每次求出b和q的gcd,再让q/gcd,如果q最后是1那么b和q拥有相同质因子,输出Finite,反之Infinite. 附代码: #include <bits/stdc++.h> typedef long long LL…