日常训练题解 D.Triangle Formation You are given N wooden sticks. Your task is to determine how many triangles can be made from the given sticks without breaking them. Each stick can be used in at most one triangle. Input The first line of each test case co…
G.LCS Revised   The longest common subsequence is a well known DP problem: given two strings A and B, one has to compute the maximum length of a subsequence that's common to both A and B. In this particular problem we work with strings A and B formed…
I.Yet another A + B You are given three numbers. Is there a way to replace variables A, B and C with these numbers so the equality A + B = C is correct? Input There are three numbers X1, X2 and X3 (1 ≤ Xi ≤ 10100), each on a separate line of input. O…
E - Restore Given a matrix A of size N * N. The rows are numbered from 0 to N-1, the columns are numbered from 0 to N-1. In this matrix, the sums of each row, the sums of each column, and the sum of the two diagonals are equal. For example, a matrix…
http://codeforces.com/gym/100739/problem/A 按位考虑,每一位建一个线段树. 求出前缀xor和,对前缀xor和建线段树. 线段树上维护区间内的0的个数和1的个数. 修改就修改p到最后的区间,进行区间取反. 回答询问时把总区间内0的个数和1的个数相乘即可. 时间复杂度\(O(n\log^2n)\). #include<cstdio> #include<cstring> #include<algorithm> using namesp…
A.B.C(By musashiheart) 0216个人赛前三道题解 E(By ggg) Gym - 100735E Restore H(by pipixia) Gym - 100735H…
Triangle Formation Time Limit: Unknown ms Memory Limit: 65536KB This problem will be judged on CodeForcesGym. Original ID: 100735D64-bit integer IO format: %I64d      Java class name: (Any)   You are given N wooden sticks. Your task is to determine h…
A. Summer Camp 题目连接: http://www.codeforces.com/contest/672/problem/A Description Every year, hundreds of people come to summer camps, they learn new algorithms and solve hard problems. This is your first year at summer camp, and you are asked to solv…
Every year, hundreds of people come to summer camps, they learn new algorithms and solve hard problems. This is your first year at summer camp, and you are asked to solve the following problem. All integers starting with 1 are written in one line. Th…
题目链接:http://codeforces.com/contest/1138/problem/D 题目大意:给你两个字符串s1和s2(只包含0和1),对于s1中,你可以调换任意两个字符的位置.问你最多能在s1中构造出几个s2(可重叠). 具体思路:首先找到字符串s2的最小循环节,比如说1101,我们找到的最小循环节就是101,这样的话,我们每次在后面加上101就能构造出一个新的1101了,最小循环节是最小的代价. AC代码: #include<bits/stdc++.h> using nam…