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)的更多相关文章

  1. 二分搜索 Codeforces Round #299 (Div. 2) C. Tavas and Karafs

    题目传送门 /* 题意:给定一个数列,求最大的r使得[l,r]的数字能在t次全变为0,每一次可以在m的长度内减1 二分搜索:搜索r,求出sum <= t * m的最大的r 详细解释:http:/ ...

  2. 水题 Codeforces Round #299 (Div. 2) A. Tavas and Nafas

    题目传送门 /* 很简单的水题,晚上累了,刷刷水题开心一下:) */ #include <bits/stdc++.h> using namespace std; ][] = {" ...

  3. DFS Codeforces Round #299 (Div. 2) B. Tavas and SaDDas

    题目传送门 /* DFS:按照长度来DFS,最后排序 */ #include <cstdio> #include <algorithm> #include <cstrin ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. Codeforces Round #299 (Div. 2)【A,B,C】

    codeforces 535A-水题: #include <bits/stdc++.h> using namespace std; typedef long long LL; char s ...

  9. 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 ...

随机推荐

  1. ZOJ-3720 Magnet Darts 计算几何,概率

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3720 题意:在一个矩形区域投掷飞镖,每个整点有磁性,每个点的磁性 ...

  2. Worker工作者进程

  3. 使用 IntelliJ IDEA 导入 Spark 最新源码及编译 Spark 源代码

    前言   其实啊,无论你是初学者还是具备了有一定spark编程经验,都需要对spark源码足够重视起来. 本人,肺腑之己见,想要成为大数据的大牛和顶尖专家,多结合源码和操练编程. 准备工作 1.sca ...

  4. Yii2 富头像上传

    前台html: <div class="xz_img2 text-center"> <div class="images_flow" id=& ...

  5. JavaScript- 获得TreeView CheckBox里选中项的值

    获得TreeView CheckBox里选中项的值,对JSDOM控制还不是很熟,感觉不太容易.试了很多次终于成功了. 代码如下 <body> <form id="form1 ...

  6. 【课程分享】基于Lucene4.6+Solr4.6+Heritrix1.14+S2SH实战开发从无到有垂直搜索引擎

    对这个课程有兴趣的朋友,能够加我的QQ2059055336和我联系,能够和您分享.  课程介绍:最有前途的软件开发技术--搜索引擎技术  搜索引擎作为互联网发展中至关重要的一种应用,已经成为互联网各个 ...

  7. Linux 汇编语言开发指南

    http://www.ibm.com/developerworks/cn/linux/l-assembly/

  8. careercup-树与图 4.2

    4.2 给定有向图,设计一个算法,找出两个结点之间是否存在一条路径. 解答 根据题意,给定一个有向图和起点终点,判断从起点开始,是否存在一条路径可以到达终点. 考查的就是图的遍历,从起点开始遍历该图, ...

  9. nodejs创建ejs工程

    <Node.js开发指南>创建ejs项目的命令为: express -t ejs microblog.执行后,创建的是jade项目.在express3.x,express4.x中创建ejs ...

  10. angularjs填写表单

    https://scotch.io/tutorials/handling-checkboxes-and-radio-buttons-in-angular-forms <!DOCTYPE html ...