Codeforces Round #299 (Div. 1)
Problem A:
实际上对于一段数字假设和为k,每次取较大的m个进行t次减一操作,最多减去的是min(m*t,k).
明白了这个结论就可以直接二分答案了。
#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL A, B, n;
LL l, t, m, ans;
int main() {
ios::sync_with_stdio ();
cin >> A >> B >> n;
for (int i = ; i <= n; i++) {
cin >> l >> t >> m;
LL a = A + (l - ) * B;
int el = l, er = l + t, last = -;
while (el <= er) {
int mid = (el + er) >> ;
LL b = A + (mid - ) * B;
if ( (a + b) * (mid - l + ) / <= t * m && b <= t && t >= a) last = mid, el = mid + ;
else
er = mid - ;
}
cout << last << endl;
}
}
536A
Problem B:
对于匹配串p,的位置xi和xj 只要判断是否有冲突,没有的冲突的话,统计确定的位置的数量k,答案就是26^(n-k).否则答案就是0.
判断冲突利用KMP的next数组就行了.
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int MAXN = ;
const int MOD = int (1e9 + );
int n, m;
int p[MAXN];
char s[MAXN];
int main() {
ios::sync_with_stdio ();
cin >> n >> m >> (s + );
int len = strlen (s + );
for (int i = , j = ; i <= len; i++) {
if (j && s[j + ] != s[i]) j = p[j];
if (s[j + ] == s[i]) j++;
p[i] = j;
}
int k = ;
for (int i = , x, y = ; i <= m; i++) {
cin >> x;
if (y && y + len > x) {
int tem = len;
while (p[tem] > y + len - x)
tem = p[tem];
if (p[tem] != y + len - x) {
cout << << endl;
return ;
}
else k -= y - x;
}
else if (y && y + len <= x) k += len;
y = x;
}
if(m) k += len;
LL ans = , tem = ;
k = n - k;
while (k) {
if (k & ) ans = (ans * tem) % MOD;
tem = (tem * tem) % MOD;
k >>= ;
}
cout << ans << endl;
}
536B
Codeforces Round #299 (Div. 1)的更多相关文章
- 二分搜索 Codeforces Round #299 (Div. 2) C. Tavas and Karafs
题目传送门 /* 题意:给定一个数列,求最大的r使得[l,r]的数字能在t次全变为0,每一次可以在m的长度内减1 二分搜索:搜索r,求出sum <= t * m的最大的r 详细解释:http:/ ...
- 水题 Codeforces Round #299 (Div. 2) A. Tavas and Nafas
题目传送门 /* 很简单的水题,晚上累了,刷刷水题开心一下:) */ #include <bits/stdc++.h> using namespace std; ][] = {" ...
- DFS Codeforces Round #299 (Div. 2) B. Tavas and SaDDas
题目传送门 /* DFS:按照长度来DFS,最后排序 */ #include <cstdio> #include <algorithm> #include <cstrin ...
- Codeforces Round #299 (Div. 2) D. Tavas and Malekas kmp
题目链接: http://codeforces.com/problemset/problem/535/D D. Tavas and Malekas time limit per test2 secon ...
- Codeforces Round #299 (Div. 1) A. Tavas and Karafs 水题
Tavas and Karafs Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/536/prob ...
- Codeforces Round #299 (Div. 2) B. Tavas and SaDDas 水题
B. Tavas and SaDDas Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/535/p ...
- Codeforces Round #299 (Div. 2) A. Tavas and Nafas 水题
A. Tavas and Nafas Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/535/pr ...
- Codeforces Round #299 (Div. 2)【A,B,C】
codeforces 535A-水题: #include <bits/stdc++.h> using namespace std; typedef long long LL; char s ...
- Codeforces Round #299 (Div. 1)C. Tavas and Pashmaks (凸壳)
C. Tavas and Pashmaks Tavas is a cheerleader in the new sports competition named "Pashmaks&qu ...
随机推荐
- HW2.13
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- 143. Sort Colors II
最后更新 一刷 class Solution { public void sortColors2(int[] colors, int k) { // write your code here if ( ...
- NSThread常见方法
// CACurrentMediaTime:获取绝对时间:从新世纪到现在的绝对时间,常用来计算耗时操作的时间差(结束时间 - 开始时间) double start = CACurrentMediaTi ...
- weblogic目录结构
安装WEBLOGIC SERVER weblogic server 的目录结构 weblogic server的classpath变量 weblogic server使用命令行 通过管理控制台执行核心 ...
- 自己写的一个Js小插件
这是效果图.上面一个过滤标签.下面弹出框,选择日,周,月.我的用途主要是报表查询的时候根据这3种类型来查询数据用的. 这里分享下代码. Js代码 (function ($) { $.extend($. ...
- 【转】浅谈HTTP中Get与Post的区别
转自:http://www.cnblogs.com/hyddd Http定义了与服务器交互的不同方法,最基本的方法有4种,分别是GET,POST,PUT,DELETE.URL全称是资源描述符,我们可以 ...
- sharepoint 2013 更改搜索server组态
1.新搜索server在.安装sharepoint server 2013,并连接到一个现有的sharepoint server领域,完成后.您可以配置新的搜索server. 打开sharepoint ...
- android内存优化发展——使用软引用
整个Android开发者一定是遇到了内存溢出这个头疼的问题,一旦这个问题.很难直接决定我们的应用程序是哪里出了问题,为了找到问题的解决方案,必须累积发行通过一些内存分析工具高速定位和强大的体验,现在详 ...
- Android5.0之CardView的使用
CardView也是一个非常炫酷的控件,一般我们将CardView配合RecyclerView来使用,当然,CardView也可以配合ListView来使用,都是可以的.OK,我们先来看一张CardV ...
- ArcGIS中文件共享锁定数据溢出 这个方法不行,建议用gdb,不要用mdb
ArcGIS中文件共享锁定数据溢出 (2011-11-24 15:52:41) 转载▼ 标签: 杂谈 分类: GIS 文件共享锁定数溢出.(Error 3052)1. Access数据库,同时操作大量 ...