Codeforces Round #448 (Div. 2) B
题目描述有点小坑,ij其实是没有先后的 并且y并不一定存在于a中 判断y的个数和所给数组无关 对于2 - 7来说 中间满足%2==0的y一共有3个 2 4 6 这样
可以看出对于每个数字a 都能够二分出来一个范围resl resr 这个范围内的数字到a 之间一共有k个x的倍数
然后就是查找一下a数组中有多少数字在resl和resr中间 也是二分寻找
L n,ds,num;
L a[100050] ;
L fin(L l,L r,L ds) {
L num1=r/ds;
L num2=l/ds;
L nu = num1-num2;
if(l%ds==0)nu++;
return nu;
}
L low(L x) {
L l=1,r=n;L res=-1;
while(l<=r){
L mid=(l+r)/2;
if(a[mid] >= x){
res=mid;r=mid-1;
} else l = mid + 1 ;
}
return res ;
}
L upp(L x){
L l=1,r=n;L res=-1;
while(l<=r){
L mid=(l+r)/2;
if(a[mid] <= x){
res=mid;l=mid+1;
} else r=mid-1 ;
}
return res ;
}
L check(L ql,L qr) {
L l = low(ql);
L r = upp(qr);
if(l==-1||r==-1) return 0 ;
if(l>r) return 0 ;
return r-l+1;
}
int main () {
while(scanf("%lld%lld%lld" , &n,&ds,&num) != EOF) {
rep(i,1,n) a[i] = read() ;
sort(a+1,a+1+n) ;
L ans = 0 ;
rep(i,1,n) {
L x = a[i] ;
L l=x,r=1e18 ;
L resl=-1,resr=-1;
while(l<=r){
L mid=(l+r)/2;
L nu = fin(x,mid,ds) ;
if(nu == num) {
resl=mid;
r=mid-1;
}
else if(nu < num) {
l=mid+1;
}
else {
r=mid-1;
}
}
l=x,r=1e18 ;
while(l<=r){
L mid=(l+r)/2;
L nu = fin(x,mid,ds) ;
if(nu == num) {
resr=mid;
l=mid+1;
}
else if(nu < num) {
l=mid+1;
}
else {
r=mid-1;
}
}
if(resl==-1||resr==-1) continue ;
L z = check(resl,resr) ;
ans += z ;
}
cout << ans << endl ;
}
}
因为室友天天晚上唱歌打牌到一两点。。第二天又要早起去训练赛或者上课。。
然后这两天都很困。。题看不下去。。头晕晕
还记得南宁网络赛之前一夜未眠,很困而又睡不着,到了比赛的时候却一点都感觉不到
就像在网吧连续通宵好几天的人,他们其实应该也是很困的,然而等到游戏开始,就一点也感觉不到了
但是对于身体的消耗是仍然存在的,连续几天的脑力消耗还是很累的
还是要好好调整一下啊。。
Codeforces Round #448 (Div. 2) B的更多相关文章
- Codeforces Round #448(Div.2) Editorial ABC
被B的0的情况从头卡到尾.导致没看C,心情炸裂又掉分了. A. Pizza Separation time limit per test 1 second memory limit per test ...
- Codeforces Round #448 (Div. 2)C. Square Subsets
可以用状压dp,也可以用线型基,但是状压dp没看台懂... 线型基的重要性质 性质一:最高位1的位置互不相同 性质二:任意一个可以用这些向量组合出的向量x,组合方式唯一 性质三:线性基的任意一个子集异 ...
- Codeforces Round #448 (Div. 2) B. XK Segments【二分搜索/排序/查找合法的数在哪些不同区间的区间数目】
B. XK Segments time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- Codeforces Round #448 (Div. 2) A. Pizza Separation【前缀和/枚举/将圆(披萨)分为连续的两块使其差最小】
A. Pizza Separation time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
随机推荐
- Guava教程
http://ifeve.com/google-guava/ github地址:https://github.com/google/guava
- Top15的golang学习资源网站
We decided to ask the Go expert and CTO at QArea’s, Maksim Kuharenko, to share his personal list of ...
- mysql ErrorNo:1449
ErrorMsg:The user specified as a definer ('root'@'%') does not exist解决方法:权限问题,授权 给 root 所有sql 权限 mys ...
- Java基础 - 面向对象 - 类的定义
package mingri.chapter_6; import java.util.Scanner; public class Person { /* * 类变量 * 定义方法: * 数据类型 变量 ...
- SEO优化 给a标签添加rel="nofollow"
为什么要使用nofollow标签? 我们使用nofollow标签的目的是很明确的,就是减少蜘蛛对页面上垃圾链接的爬行和传递权重,或者减少蜘蛛对页面上“无用”链接的爬行和传递链接权重. 这里所说的无用是 ...
- element-UI中el-select下拉框可搜索时候,filter-method自定义搜索方法
使用element-UI框架的使用,我们经常使用el-select下拉框,很多时候还需要使用可搜索的下拉框,然后elementUI官网的实例中只是提了一下filter-method可以自定义搜索方法, ...
- Pycharm选中代码无法Backspace直接删除
现象 如图,选中代码后,按习惯来说,直接Backspace就可以删除被选中代码. 但选中后再按“Backspace”,只会改变(扩选)选中范围. 解决 点击“工具栏”里的“Tool”,去掉勾选的Vim ...
- EasySQLMAIL使用实践系列
原文:http://blog.sina.com.cn/s/articlelist_5713986487_0_1.html 通过sql语句发送微信消息(转) 使用EasySQLMAIL的外部接口功能实现 ...
- oradebug工具使用2(转载)
oradebug的前身是在ORACLE 7时的ORADBX,它可以启动用停止跟踪任何会话,dump SGA和其它内存结构,唤醒ORACLE进程,如SMON.PMON进程,也可以通过进程号使进程挂起和恢 ...
- Hbase 学习笔记2----概念
说在前面,本文部分内容来源于社区官网经过适度翻译,部分根据经验总结,部分是抄袭网络博文,(不一一列举引用,在此致歉)一并列在一起,本文的目的,希望能总结出一些有用的,应该注意到的东西,基本思路是先提出 ...