水题,注意数据范围 #include <iostream> using namespace std; int main(){ long long n,a; cin >> n; ))>>; ; i < n- ; ++i){ cin >>a; sum -=a; } cout<<sum<<endl; }…
水题,只要遍历一遍,不够平均数的,从后面的借,比平均数多的,把多余的数添加到后面即可,注意数据范围 #include <iostream> #include <vector> #include <cmath> using namespace std; int main(){ int n; cin >> n; vector<long long> a(n); ; ; i < n; ++ i){ cin >>a[i]; sum +=a…
题目链接: http://www.codeforces.com/contest/10/problem/D D. LCIS time limit per test:1 secondmemory limit per test:256 megabytes 问题描述 This problem differs from one which was on the online contest. The sequence a1, a2, ..., an is called increasing, if ai …
D. LCIS 题目连接: http://www.codeforces.com/contest/10/problem/D Description This problem differs from one which was on the online contest. The sequence a1, a2, ..., an is called increasing, if ai < ai + 1 for i < n. The sequence s1, s2, ..., sk is call…
C. Digital Root 题目连接: http://www.codeforces.com/contest/10/problem/C Description Not long ago Billy came across such a problem, where there were given three natural numbers A, B and C from the range [1, N], and it was asked to check whether the equat…
B. Cinema Cashier 题目连接: http://www.codeforces.com/contest/10/problem/B Description All cinema halls in Berland are rectangles with K rows of K seats each, and K is an odd number. Rows and seats are numbered from 1 to K. For safety reasons people, who…
A. Power Consumption Calculation 题目连接: http://www.codeforces.com/contest/10/problem/A Description Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minute…
C. Subsequences Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/problem/C Description For the given sequence with n different elements find the number of increasing subsequences with k + 1 elements. It is guaranteed tha…
A. Divisibility Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/problem/A Description Find the number of k-divisible numbers on the segment [a, b]. In other words you need to find the number of such integer values x tha…
C. Subsequences     For the given sequence with n different elements find the number of increasing subsequences with k + 1 elements. It is guaranteed that the answer is not greater than 8·1018. Input   First line contain two integer values n and k (1…
题目链接:http://codeforces.com/problemset/problem/328/B 水题~ #include <cstdio> #include <cstdlib> #include <cstring> ], a[]; ], c[]; int main(void) { //freopen("in.txt", "r", stdin); scanf("%s%s", n, a); int len1…
B. Restaurant Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/problem/B Description A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order…
A:The Way to Home link:http://codeforces.com/contest/910/problem/A 题面:有每次最大跳跃距离d,只有一部分的点可以落脚,求最少几步达到终点D Solution :预处理+贪心 用f[i]表示离点i最近的可落脚点,贪心即可(dp同理) #include <bits/stdc++.h> using namespace std; ]; string s; int main() { cin >> n >> d &…
题意: 一个人在雪地上滑雪,每次可以向上下左右四个方向移动一个单位,如果这条路径没有被访问过,则需要5秒的时间,如果被访问过,则需要1秒(注意:判断的是两点之间的距离,不是单纯的点).给你他的行动轨迹,求消耗的时间. 题解:我们用两个pair来维护边,用map来对边进行标记,每次更新map记得双向更新即可(e.g:(1,2)和(2,1)两个方向都要标记). 代码: #include <iostream> #include <cstdio> #include <cstring&…
D. LCIS time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output This problem differs from one which was on the online contest. The sequence a1, a2, ..., an is called increasing, if ai < ai + 1 for …
题目大意: n波人去k*k的电影院看电影. 要尽量往中间坐,往前坐. 直接枚举,贪心,能坐就坐,坐在离中心近期的地方. #include <cstdio> #include <iostream> #include <cstring> #include <algorithm> #define maxn 1000005 #define lowbit(x) (x&(-x)) using namespace std; struct BIT { int sum…
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一个queen了,问你有多少种方案,能够得到n点 题解 其实只用考虑三种情况,都考虑一下就好了,实在不行就暴力枚举-- 代码 #include<bits/stdc++.h> using namespace std; int n; int main() { scanf("%d",&…
题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考虑:如果操作的次数最少,那么最终得到的不降的数列,必然是由原始数列中的数组成的,具体的证明可以使用反证法 知道了上面讲述的性质,这题就好搞了 先将原始数列(设为 A,共 n 个数)中所有的数去重并从小到达排序,保存在另一个数列中(设为 B,共 m 个数) 定义状态:f[i][j] 表示将原始数列中的…
Problem   Codeforces Global Round 1 - D. Jongmah Time Limit: 3000 mSec Problem Description Input Output Print one integer: the maximum number of triples you can form. Sample Input 10 62 3 3 3 4 4 4 5 5 6 Sample Output 3 题解:动态规划,对这种状态定义不熟悉,主要还是没有发现最优方…
[Codeforces]Round #491 (Div. 2) 总结 这次尴尬了,D题fst,E没有做出来.... 不过还好,rating只掉了30,总体来说比较不稳,下次加油 A:If at first you don't succeed- SB题,就是注意一下特判就好了,然后我一开始wa了三次... #include<bits/stdc++.h> using namespace std; int read(){ int ans=0,w=1;char c=getchar(); while(!…
[Codeforces]Round #488 (Div. 2) 总结 比较僵硬的一场,还是手速不够,但是作为正式成为竞赛生的第一场比赛还是比较圆满的,起码没有FST,A掉ABCD,总排82,怒涨rating两百 A:Fingerprints A题,就在第一个串中查找第二个串中的数字,最气的是一开始没编译直接交CE了,噗 #include<iostream> #include<cstdio> using namespace std; int read(){ int ans=0,w=1…
layout: post title: Codeforces Beta Round 84 (Div. 2 Only) author: "luowentaoaa" catalog: true tags: mathjax: true - codeforces 传送门 不得不说这远古场太简单了 A - Nearly Lucky Number (签到) 题意 给出一个数字 求其中7和4的数目是否是7和4组成 #include<bits/stdc++.h> using namespa…
题目链接   Codeforces Educational Round 33 Problem A 按照题目模拟,中间发现不对就直接输出NO. #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i(a); i <= (b); ++i) #define dec(i, a, b) for (int i(a); i >= (b); --i) #define MP make_pair #de…
Codeforces Beta Round #17 题目链接:点击我打开题目链接 大概题意: 给你 \(b\),\(n\),\(c\). 让你求:\((b)^{n-1}*(b-1)\%c\). \(2<=b<=10^{10^6},1<=n<=10^{10^6},1<=c<=10^9\) 简明题解: 因为 \(b\) , \(n\)都太大了.关键是求 \((b)^{n-1}\%c\) 所以,我们可以利用欧拉函数 \(phi()\) 的性质. 对于\(a^{b} \% c\…
Codeforces Global Round 3 A. Another One Bites The Dust 有若干个a,有若干个b,有若干个ab.你现在要把这些串拼成一个串,使得任意两个相邻的位置都是不同字符,求可能的最长串长度. 枚举一下\(a\)开头还是\(b\)开头,那么接下来就被唯一确定了. #include<iostream> #include<cstdio> using namespace std; int a,b,c;long long ans; int main…
Codeforces Educational Round 92 赛后解题报告 惨 huayucaiji 惨 A. LCM Problem 赛前:A题嘛,总归简单的咯 赛后:A题这种**题居然想了20min 我说这句话,肯定是有原因的,我们看到 \(\operatorname{lcm}\) 会想到之前一些题:题目,我的题解 自然就往 \(a\times b=\operatorname{gcd}(a,b)\times \operatorname{lcm}(a,b)\) 的方向思考,但是,这太麻烦了,…
Codeforces Beta Round #62 A Irrational problem 题意 f(x) = x mod p1 mod p2 mod p3 mod p4 问你[a,b]中有多少个数满足f(x)=x 题解 显然直接带进去就好了-- 代码 #include<bits/stdc++.h> using namespace std; int main() { int p1,p2,p3,p4,a,b; scanf("%d%d%d%d%d%d",&p1,&am…
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0,那么这个点就是水龙头点. 如果这个点的出度为0,那么这个点就是储存点. 现在让你把所有水龙头到储存点的路径都输出出来,且输出这条路径的边权最小值 题解 显然是个仙人掌图,所以直接XJB暴力就好了 代码 #include<bits/stdc++.h> using namespace std; co…
CodeForces Global Round 1 CF新的比赛呢(虽然没啥区别)!这种报名的人多的比赛涨分是真的快.... 所以就写下题解吧. A. Parity 太简单了,随便模拟一下就完了. B. Tape 显然就是先找一个长的把所有的全部覆盖,然后可以在上面丢掉\(k-1\)段间隙. 那么把两两之间的间隙长度拿出来排序就可以了. C. Meaningless Operations 如果\(a\)不等于\(2^k-1\)的形式,那么令\(S=2^k-1\),其中\(2^{k-1}<a<2…
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++.h> using namespace std; #define lson l,mid,rt<<1 #define rson mid+1,r,rt<<1|1 #define sqr(x) ((x)*(x)) #define pb push_back #define eb empla…