2016 Al-Baath University Training Camp Contest-1 A题:http://codeforces.com/gym/101028/problem/A 题意:比赛初始值是1500,变化了几次,得到的正确结果和bug后的是否相等.(Tourist大佬好 Y(^o^)Y) #include <bits/stdc++.h> using namespace std; int main() { int t; cin>>t; while(t--) { in…
1001,只要枚举区间即可.签到题,要注意的是输入0的话也是“TAT”.不过今天补题的时候却WA了好几次,觉得奇怪.原来出现在判断条件那里,x是一个int64类型的变量,在进行(x<65536*65536)的时候,后面的已经爆int了!因为如果写的是int类型他就默认是int类型的.所以要写成(ll)65536*65536或者直接4294967296,因为如果这个值是ll类型的,就自动用ll类型来保存了(另外要注意的是(ll)(65536*65536)也是错的!因为后面已经爆int了,再转成ll…
第一场多校,出了一题,,没有挂零还算欣慰. 1001,求最小生成树和,确定了最小生成树后任意两点间的距离的最小数学期望.当时就有点矛盾,为什么是求最小的数学期望以及为什么题目给了每条边都不相等的条件.看了题解以后才明白:“首先注意到任意两条边的边权是不一样的,由此得知最小生成树是唯一的,最小生成树既然 是唯一的,那么期望其实也就是唯一的,不存在什么最小期望.”那么第一问最小生成树只要克鲁斯卡尔算法即可,第二问,总的路的条数是n*(n-1)/2,然后确定所有路的权值和的方法是:枚举每一条边,这一条…
1001,官方题解是直接dp,首先dp[i]表示到i位置的种类数,它首先应该等于dp[i-1],(假设m是B串的长度)同时,如果(i-m+1)这个位置开始到i这个位置的这一串是和B串相同的,那么dp[i]还应该加上dp[i-m],因为从i-m+1开始可以被替换成另外一种意思.详细的见代码吧.我们当时使用dfs来做的,实际上换汤不换药,思想是一样的(不过dfs的话是从前往后算的).代码如下: #include <bits/stdc++.h> using namespace std; + ; ;…
1009,直接贪心,只要让后面的尽量小,第一位和第二位尽量大即可. 1011,直接统计奇数的字母的个数,然后用偶数的个数平均分配到它们上面即可.代码如下: #include <stdio.h> #include <algorithm> #include <string.h> using namespace std; int main() { int T; scanf("%d",&T); while(T--) { int n; , even =…
Description ACM-SCPC-2017 is approaching every university is trying to do its best in order to be the Champion, there are n universities, the ith of them has exactly ai contestants. No one knows what is the official number of contestants in each team…
Description Zaid has two words, a of length between 4 and 1000 and b of length 4 exactly. The word a is 'good' if it has a substring which is equal tob. However, a is 'almost good' if by inserting a single letter inside of it, it would become 'good'.…
Description Tourist likes competitive programming and he has his own Codeforces account. He participated in lots of Codeforces Rounds, solved so many problems and became "Legendary Grand Master" (the highest rank on Codeforces). One day, he logg…
题目链接:http://codeforces.com/problemset/gymProblem/101028/I I. March Rain time limit per test 2 seconds memory limit per test 64 megabytes input standard input output standard output It is raining again! Youssef really forgot that there is a chance of…
Problem F. Grab The Tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others) Total Submission(s): 2004    Accepted Submission(s): 911 Problem Description Little Q and Little T are playing a game on a tree. There are …
Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1770    Accepted Submission(s): 1089 Problem Description Alice and Bob are playing a game. The game is played on a set of positive integers…
Maximum Multiple Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3985    Accepted Submission(s): 926 Problem Description Given an integer n, Chiaki would like to find three positive integers x,…
Description X is fighting beasts in the forest, in order to have a better chance to survive he's gonna buy upgrades for his weapon. Weapon upgrade shops are available along the forest, there are n shops, where the ith of them provides an upgrade with…
Description It is raining again! Youssef really forgot that there is a chance of rain in March, so he didn't fix the roof of his house. Youssef's roof is 1-D, and it contains n holes that make the water flow into the house, the position of hole i is…
 Description You've possibly heard about 'The Endless River'. However, if not, we are introducing it to you. The Endless River is a river in Cambridge on which David and Roger used to sail. This river has the shape of a circular ring, so if you kept…
Description The forces of evil are about to disappear since our hero is now on top on the tower of evil, and all what is left is the most evil, most dangerous monster! The tower has h floors (numbered from 1 to h, bottom to top), each floor has w roo…
Description X is well known artist, no one knows the secrete behind the beautiful paintings of X except his friend Y, well the reason that Y knows X's secrete is that he is that secret. Y is a programmer and he helps X with drawing paintings using co…
Description Rami went back from school and he had an easy homework about bitwise operations (and,or,..) The homework was like this : You have an equation : " A | B = C " ( this bar '|' means OR ) you are given the value of A and B , you need to…
Description A group of junior programmers are attending an advanced programming camp, where they learn very difficult algorithms and programming techniques! Near the center in which the camp is held, is a professional bakery which makes tasty pastrie…
比赛链接:http://codeforces.com/gym/101028/ 由于实习,几乎没有时间刷题了.今天下午得空,断断续续做了这一套题,挺简单的. A.读完题就能出结果. /* ━━━━━┒ギリギリ♂ eye! ┓┏┓┏┓┃キリキリ♂ mind! ┛┗┛┗┛┃\○/ ┓┏┓┏┓┃ / ┛┗┛┗┛┃ノ) ┓┏┓┏┓┃ ┛┗┛┗┛┃ ┓┏┓┏┓┃ ┛┗┛┗┛┃ ┓┏┓┏┓┃ ┛┗┛┗┛┃ ┓┏┓┏┓┃ ┃┃┃┃┃┃ ┻┻┻┻┻┻ */ #include <algorithm> #inclu…
Solved A HDU 6298 Maximum Multiple Solved B HDU 6299 Balanced Sequence Solved C HDU 6300 Triangle Partition Solved D HDU 6301 Distinct Values   E HDU 6302 Maximum Weighted Matching   F HDU 6303 Period Sequence Solved G HDU 6304 Chiaki Sequence Revisi…
Blank 定义dp[i][j][k][t]dp[i][j][k][t]dp[i][j][k][t]代表填完前ttt个位置后,{0,1,2,3}\{0,1,2,3\}{0,1,2,3}这4个数字最后一次出现的位置,排序后为i,j,k,t(i<j<k<t)i,j,k,t(i<j<k<t)i,j,k,t(i<j<k<t)的方案数目,则按照第t+1t+1t+1位的数字的四种选择,可以得到四种转移. 对于限制可以按照限制区间的右端点分类,求出dp[i][j][…
目录 Cookies Distinct Sub-palindromes Fibonacci Sum Finding a MEX Leading Robots Math is Simple Minimum Index Mow Cookies 先简单二分出最后查的是哪个标号. 然后发现这个可以快速处理出一段区间的答案,分段打表即可. 注意代码长度限制不要爆了我就白打了 10min Code ll n, k, a[N]; ll S[4001] = { ... }; int m; inline ll c…
8/11 2016 Multi-University Training Contest 1 官方题解 老年选手历险记 最小生成树+线性期望 A Abandoned country(BH) 题意: 1. 求最小生成树 2. 求在某一棵最小生成树任意两点的最小距离的期望值. 思路: 首先题目说了边权值都是不同的,所以最小生成树唯一.那么只要统计出最小生成树的每一条边在“任意两点走经过它“的情况下所贡献的值,发现在一棵树里,一条边所贡献的次数为,sz[v]表示v子树包括节点v的个数.如下图所示,红边所…
8/13 2016 Multi-University Training Contest 2官方题解 数学 A Acperience(CYD)题意: 给定一个向量,求他减去一个  α(>=0)乘以一个值为任意+1或-1的B向量后得到向量,求这个向量膜的最小值思路: 展开式子,当时最小,结果为. 代码: #include <bits/stdc++.h> using namespace std; long long w,a,b,c,a2; long long gcd(long long x,l…
5/11 2016 Multi-University Training Contest 3官方题解 2016年多校训练第三场 老年选手历险记 暴力 A Sqrt Bo(CYD) 题意:问进行多少次开根号向下取整能使给定的值为1,若为5次以上,则输出TAT: 思路: 有5次这个限制,得知值最大为10的11次方左右,存下后运算即可,注意初始值为0时运算的次数是大于5次的,输出TAT: 代码: #include <bits/stdc++.h> using namespace std; char st…
6/12 2016 Multi-University Training Contest 4官方题解 KMP+DP A Another Meaning(CYD) 题意: 给一段字符,同时给定你一个单词,这个单词有双重意思,字符串中可能会有很多这种单词,求这句话的意思总数:hehe. 思路: 可以用kmp算法快速求出串中的单词数量,若单词是分开的,每个单词有两种意思,可以直接相乘,若两个及以上单词在原串中是有交集的,那么数量不是直接相乘,发现这片连在一起的单词数量dp[i]=dp[i-1]+dp[j…
5/12 2016 Multi-University Training Contest 6 官方题解 打表找规律/推公式 A A Boring Question(BH) 题意: ,意思就是在[0,n]里选择m个数字的相邻数字二项式组合的积的总和. 思路: 想了好久,不会,但是这题有300多人过,怀疑人生... 打了个表: n=0, m=2, ans=1n=1, m=2, ans=3n=2, m=2, ans=7n=3, m=2, ans=15n=4, m=2, ans=31n=5, m=2, a…
Differencia Time Limit: 10000/10000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 601    Accepted Submission(s): 173 Problem Description Professor Zhang has two sequences a1,a2,...,an and b1,b2,...,bn. He wants to…
Rigid Frameworks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 337    Accepted Submission(s): 273 Problem Description Erik Demaine is a Professor in Computer Science at the Massachusetts Insti…