题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4029 Time Limit: 1 Second Memory Limit: 131072 KB AC代码: #include<bits/stdc++.h> using namespace std; typedef long long LL; ; ; const LL MOD=1e9; int n,m; LL a[maxn],p[maxm]; ]; void i…
题目链接:Glider Gym-101911B 解题分析:下落的高度一定,是h.在没有气流的地方每秒下落1:所以可以转化为经过无气流地带的时间总长为h. 那么很显然从一个有气流地带的开始,选择下落,那么问题来了,一个一个去试然后一个一个计算他的路径去维护一个最大值吗?未免太过麻烦,所给数据有 那么大. 解题关键:二分+前缀和 二分查找用:lower_bound() int x=lower_bound(a, a+n, val)-a; 其中i返回值为数组元素值大于等于val的第一个下标.相应地,如果…
农夫约翰的农场由 NN 块田地组成,每块地里都有一定数量的牛,其数量不会少于1头,也不会超过2000头. 约翰希望用围栏将一部分连续的田地围起来,并使得围起来的区域内每块地包含的牛的数量的平均值达到最大. 围起区域内至少需要包含 FF 块地,其中 FF 会在输入中给出. 在给定条件下,计算围起区域内每块地包含的牛的数量的平均值可能的最大值是多少. 输入格式 第一行输入整数 NN 和 FF ,数据间用空格隔开. 接下来 NN 行,每行输出一个整数,第i+1i+1行输出的整数代表,第ii片区域内包含…
A /* Huyyt */ #include <bits/stdc++.h> using namespace std; typedef long long ll; ]; ]; map<ll, int> mp; int main() { int n; cin >> n; ; i <= n; i++) { cin >> a[i]; } ; ; i <= n; i++) { memset(num, , sizeof(num)); ; ; j <…
A. 全部空的放狗 B. 先O(NLOGNLOGN)处理出一个合数质因数中最大的质数是多少 因为p1 x1 x2的关系是 x2是p在x1之上的最小倍数 所以x1的范围是[x2-p+1,x2-1]要使最后答案尽可能小 要包含尽可能多的选择 p0 x0  x1关系同上 #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #define TS printf("!!!\…
Modulo Query Time Limit: 2 Seconds      Memory Limit: 65536 KB One day, Peter came across a function which looks like: F(1, X) = X mod A1. F(i, X) = F(i - 1, X) mod Ai, 2 ≤ i ≤ N. Where A is an integer array of length N, X is a non-negative integer n…
题目链接: http://codeforces.com/contest/660/problem/C 题意: 将最多k个0变成1,使得连续的1的个数最大 题解: 二分连续的1的个数x.用前缀和判断区间[i,i+x-1]里面0的个数是否小于等于k. 代码: #include<iostream> #include<cstdio> #include<vector> #include<cstring> using namespace std; ; int n,k; i…
这个题真的难了我一天了,这种方法一开始没想出来,后来看了题解后明白了大致思路开始自己做但是!!!但是自己实现的时候老是一些细节出错!!!,调bug调了得有一个小时,蠢死了,这道题我一定要好好总结,总结为什么会卡壳,这要是比赛的签到题的话我得哭死!!!!! #include<bits/stdc++.h> using namespace std; ; unsigned long long a[maxn]; unsigned long long c[maxn]; unsigned long long…
传送门:点我 A plane is flying at a constant height of hh meters above the ground surface. Let's consider that it is flying from the point (−10^9,h)(−10^9,h) to the point (10^9,h)(10^9,h) parallel with Ox axis. A glider is inside the plane, ready to start…
P1314 聪明的质监员 显然可以二分参数W 统计Y用下前缀和即可. #include<iostream> #include<cstdio> #include<cstring> #include<cctype> #include<algorithm> #include<cmath> #define re register using namespace std; typedef long long ll; void read(int…