F. Guards In The Storehouse time limit per test 1.5 seconds memory limit per test 512 megabytes input standard input output standard output Polycarp owns a shop in the capital of Berland. Recently the criminal activity in the capital increased, so Po…
Educational Codeforces Round 40 F. Runner's Problem 题意: 给一个$ 3 * m \(的矩阵,问从\)(2,1)$ 出发 走到 \((2,m)\) 的方案数 \(mod 1e9 + 7\), 走的规则和限制如下: From the cell (i, j) you may advance to: (i - 1, j + 1) - only if i > 1, (i, j + 1), or (i + 1, j + 1) - only if i <…
题目链接:http://codeforces.com/contest/845 A. Chess Tourney 水题,排序之后判断第n个元素和n+1个元素是不是想等就可以了. #include <bits/stdc++.h> using namespace std; int a[210]; int n; int main() { scanf("%d", &n); for(int i=1; i<=2*n; i++) scanf("%d", &…
https://codeforces.com/contest/1132/problem/F 思维 + 区间dp 题意 给一个长度为n的字符串(<=500),每次选择消去字符,连续相同的字符可以同时消去,问最少需要消去多少次 题解 定义dp[l][r]为区间[l,r]剩下一个字符所需要的最小次数 dp[l][r]=min(dp[l][i]+dp[i+1][r]+x) x为消去剩下两个字符所需要的次数,假如两个字符相同需要x=-1 代码 #include<bits/stdc++.h> #de…
https://codeforces.com/contest/1051/problem/F 题意 给一个带权联通无向图,n个点,m条边,q个询问,询问两点之间的最短路 其中 m-n<=20,1<=n,m<=1e5 思路 因为图一定联通,所以n-1<=m<=n+20 因为是求任意两点的最短路,所以直接暴力跑最短路是不行的,考虑选择性的跑最短路 因为是求两点之间的距离,所以可以往lca方面想 先跑一棵生成树出来,然后处理出每个点的lca,这样就可以求出任意两点的距离 然后就可以记…
F. Four Divisors 题目连接: http://www.codeforces.com/contest/665/problem/F Description If an integer a is divisible by another integer b, then b is called the divisor of a. For example: 12 has positive 6 divisors. They are 1, 2, 3, 4, 6 and 12. Let's def…
题目链接:http://codeforces.com/contest/837/problem/F 题意:如题QAQ 解法:参考题解博客:http://www.cnblogs.com/FxxL/p/7282909.html    由于新生成的m+1个数列第一个肯定为0,所以可以忽略掉,当作每次新生成的数列只拥有m个元素    来枚举一个例子,可以发现规律. 当a[] = {1,0,0,0,0}时,手动推出的矩阵如下: 可以发现对于这个矩阵显然是满足杨辉三角的,我们二分出一个值后可以直接利用组合数来…
F. Magic Matrix 题目连接: http://www.codeforces.com/contest/632/problem/F Description You're given a matrix A of size n × n. Let's call the matrix with nonnegative elements magic if it is symmetric (so aij = aji), aii = 0 and aij ≤ max(aik, ajk) for all…
F. Xors on Segments 题目连接: http://www.codeforces.com/contest/620/problem/F Description You are given an array with n integers ai and m queries. Each query is described by two integers (lj, rj). Let's define the function . The function is defined for o…
F. The Sum of the k-th Powers 题目连接: http://www.codeforces.com/contest/622/problem/F Description There are well-known formulas: , , . Also mathematicians found similar formulas for higher degrees. Find the value of the sum modulo 109 + 7 (so you shoul…