BestCoder Round #86 解题报告】的更多相关文章

A.Price List Sol 求和查询 Code #include<cstdio> #include<algorithm> #include<iostream> using namespace std; typedef long long LL; const int N = 100005; //LL v[N]; inline LL in(LL x=0,char ch=getchar()){ while(ch>'9'||ch<'0') ch=getchar…
King's Cake [思路] 递推 公式:f(n,m)=f(max(m,n-m),min(m,n-m))+1,n>m [代码] #include<cstdio> #include<iostream> using namespace std; int max(int a,int b) { return a>b? a:b; } int min(int a,int b) { return a>b? b:a; } int f(int n,int m) { ; ; }…
DZY Loves Partition [思路] 贪心 [代码] #include <iostream> using namespace std; typedef long long ll; ; ll n,k,a[]; int main() { int T; cin>>T; while(T--) { cin>>n>>k; ll x=n/k; )/>n) cout<<-<<endl; else { ) { ;i>;i--)…
这场是第一场没有米的BC... 大概也是想震一震那些一听说没米了就不打BC的人吧 这次的题目质量比以往高了许多 (然而我并没有打这一场BC 但是今天下午到现在做的过程中真的学到了不少知识呢 A题略水... #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> int T,n; int main(){ scanf("%d",&T); while (T…
现场只做出前三题w 不过不管怎样这既是第一次认真打BC 又是第一次体验用在线编译器调代码 订正最后一题花了今天一整个下午(呜呜 收获还是比较大的^_^ Delete wld有n个数(a1,a2,...,an),他希望进行k次删除一个数的操作,使得最后剩下的n−k个数中有最多的不同的数,保证1≤n≤100,0≤k<n,1≤ai≤n(对于任意1≤i≤n) 比较简单的贪心... 把出现一次以上的多于一次的部分都删除掉 如果k依然>0就要删去k种不同的数 Multiple wld有一个序列a[1..n…
[HDU5807] [BestCoder Round #86 1004] Keep In Touch (DP) 题面 有三个人从一张N个点无重边的有向无环图上的三个点出发,每单位时间,他们分别选择当前点的一条出边走下去.有向无环图点有点权,任意时刻他们所在的三个点两两点权相差不超过K.他们可以在任意三个点同时结束.求合法的路径总数.N≤50. 分析 暴力的做法,设\(dp[i][j][k]\)表示第一个人在i,第二个人在j,第三个人在k的方案数,然后枚举三个人接着到的地方x,y,z,倒推\(dp…
最近莫名其妙地喜欢上了用这种格式写各省省选的全套题解= = 今年浙江省选的出题人是算法竞赛界传说级人物陈立杰,看样子他的出题风格很有特点……ABC三题难度是严格递减的,感觉如果在做第一题的时候被卡住的话恐怕连想死的心都有了…… 那么我们先从最难的一题开始……= = BZOJ 3924 A.幻想乡战略游戏 给定一棵N个结点的有正的边权.初始点权为0的无根树,进行M次操作,每次将一个点u的权值增加e($0 \leq |e| \leq 1000$),保证任意时刻点权非负.你的任务是在每次操作后找到一个…
呜呜周日的时候手感一直很好 代码一般都是一遍过编译一遍过样例 做CF的时候前三题也都是一遍过Pretest没想着去检查... 期间姐姐提醒说有Announcement也自信不去看 呜呜然后就FST了 呜呜然后rating-55(果然呜呜 TAT A. Cutting Banner   A large banner with word CODEFORCES was ordered for the 1000-th onsite round of Codeforcesω that takes plac…
A题 Price List 巨水..........水的不敢相信. #include <cstdio> typedef long long LL; int main() { int T; scanf("%d",&T); while(T--) { int n,m,x; scanf("%d%d",&n,&m); LL sum = ; ; i < n; i++) { int x; scanf("%d",&…
比赛链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=41856#overview A.多种解法.可以dfs倒序染色,如mathlover神的代码: #include<stdio.h> #include<algorithm> using namespace std; struct node { int x1,y1,x2,y2; bool color; } a[]; int n,m; int ans; void dfs(…
A. Codeforces 92A Chips 签到题.. #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespace std; #define N 10007 ]; int main() { int n,m,i; while(scanf("%d%d",&n,…
题目:传送门. 题意:题目说的是求期望,其实翻译过来意思就是:一个长度为 n 的数列(n>=3),按顺序删除其中每一个数,每次删除都是建立在最原始数列的基础上进行的,算出每次操作后得到的新数列的相邻两数的差的绝对值的最大值,求这些n个最大值的总和. 题解:把n=3的情况单独拿出来直接算出来,就是abs(data[3]-data[2])+abs(data[2]-data[1])+abs(data[3]-data[1]),然后讨论n>=4的情况.首先遍历求出原始数列的相邻两数的差的绝对值的最大值m…
Price List 题意: 有n件商品,每天只能买一件,并且会记录账本,问有多少次一定记多了? 题解: 就是求和,最后如果大于和就输出1,否则0. 代码: #include <bits/stdc++.h> using namespace std; typedef long long ll; #define SI(N) cin>>(N) #define SII(N,M) cin>>(N)>>(M) #define rep(i,b) for(int i=0;i…
严格按题解写,看能不能形成sum,只需要分割当前sum怎么由两边组成就好 #include <cstdio> #include <cstring> #include <cmath> #include <vector> #include <algorithm> using namespace std; const int INF = 0x3f3f3f3f; ; ],g[N][]; ],v[N],d[N],T,n,m; struct Que { in…
#include <cstdio> #include <cstring> #include <cmath> #include <vector> #include <algorithm> using namespace std; typedef long long LL; +; ; ],head[N]; struct Edge{ int v,next; }edge[N*N/]; void add(int u,int v){ edge[tot].v=…
分析:大于等于m的变成1,否则变成0,预处理前缀和,枚举起点,找到第一个点前缀和大于m即可 找第一个点可以二分可以尺取 #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespace std; typedef long long LL; ; int T,n,m,k,a[N],sum[N]; int main(){ scanf("%d…
分析:维护空隙的差,然后预处理前缀最大,后缀最大,扫一遍 #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespace std; typedef long long LL; ; int a[N],T,n,b[N],l[N],r[N]; int main(){ scanf("%d",&T); while(T--){…
分析:大于总和输出1 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; typedef long long LL; ; int ret[N],T,n,m; int main(){ scanf("%d",&T); while(T--){ scanf("%d%d",&n,&m); LL sum=; ;i&…
1001 [题意] 给定一个长度为n(n<=100000)的正整数序列,给出m(m<=100000)个子集合和的记录,问哪些一定比正确的记录多了 [题解] 对正整数序列求和,记录比和大的一定记录多了 HackPoint:sum要开long long ]; int main(){ int T=gi; while(T--){ ; FOR1(i,n)v[i]=gi,sum+=v[i]; FOR1(i,m){ ll p;scanf("%I64d",&p); ");…
若 [i, j] 满足, 则 [i, j+1], [i, j+2]...[i,n]均满足 故设当前区间里个数为size, 对于每个 i ,找到刚满足 size == k 的 [i, j], ans += n - j + 1 . i++ 的时候看看需不需要size-- 就可以更新了. #include <iostream> #include <cstdio> #include <cstring> using namespace std; #define LL long l…
先找相邻差值的最大,第二大,第三大 删去端点会减少一个值, 删去其余点会减少两个值,新增一个值,所以新增和现存的最大的值比较一下取最大即可 #include <iostream> #include <cstdio> #include <cmath> using namespace std; #define LL long long ; int t, n, p1, p2, p3; LL a[N]; LL s1[N], s2[N]; LL sum; int main() {…
这次BC终于不像上次一样惨烈 终于A了三题…… 终测ing…… 发一波题解…… A.Price List A题十分无脑 只要把所有数加起来存到sum里 询问的时候大于sum输出1 否则输出0就行了…… 犹豫了好久 怎么会这么简单…… 看群里好多人卡在了%I64d…… #include<stdio.h> #include<iostream> #include<algorithm> #include<math.h> #include<string.h>…
A 我的方法是: #include<bits/stdc++.h> using namespace std; #define int long long typedef long long ll; const int N=2e5+100; const int INF = 1e9; int32_t main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int b, k; cin >> b >> k; i…
感觉今天早上虽然没有睡醒但是效率还是挺高的... Pas和C++换着写... 544A. Set of Strings   You are given a string q. A sequence of k strings s1, s2, ..., sk is called beautiful, if the concatenation of these strings is string q(formally, s1 + s2 + ... + sk = q) and the first cha…
第一题太水,跳过了. NanoApe Loves Sequence题目描述:退役狗 NanoApe 滚回去学文化课啦! 在数学课上,NanoApe 心痒痒又玩起了数列.他在纸上随便写了一个长度为 nnn 的数列,他又根据心情随便删了一个数,这样他得到了一个新的数列,然后他计算出了所有相邻两数的差的绝对值的最大值. 他当然知道这个最大值会随着他删了的数改变而改变,所以他想知道假如全部数被删除的概率是相等的话,差的绝对值的最大值的期望是多少. 输入描述 第一行为一个正整数 T,表示数据组数. 每组数…
感觉这次的题目顺序很不合理啊... A. Combination Lock   Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock. The combination l…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=5806 题意:有多少个区间里的第 k 大的数不小于 m 解法:尺取法,首先我们用dp[i]保存到i的位置有多少大于m的数 l=1,r=1,r开始遍历,只要符合dp[l]-dp[r]==k就是sum+=(n-r+1) 然后根据情况移动l,r #include<stdio.h> //#include<bits/stdc++.h> #include<string.h> #include…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=5805 题意:删除数列中一个数,找出相邻之差绝对值最大,求依次删除最大值的和 解法:删除边缘位置的数字需要注意 它们的差就是 a[i-1]-a[i-2] ,a[i+2]-a[i+1],a[i-1]-a[i+1]的绝对值,当然,把最大的加起来就行 #include<stdio.h> //#include<bits/stdc++.h> #include<string.h> #incl…
链接http://acm.hdu.edu.cn/showproblem.php?pid=5804 题意:给你一些商店和他的商品价格,然后给你一个记账本,问你记大了就是1,否则是0 解法:模拟,注意测试数据大小 #include<stdio.h> //#include<bits/stdc++.h> #include<string.h> #include<iostream> #include<math.h> #include<sstream&g…
我是比赛地址 A:Phone Numbers $Description$:给你一串数字,问你能组成多少开头为8的11位电话号码. $Sol$:统计8的数量,与$n$%11作比较. #include<cstdio> #include<algorithm> #include<cstring> using namespace std; int n,len,cnt,ans; ]; int main() { scanf("%d",&n); scanf(…