题目描述有点小坑,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的更多相关文章

  1. Codeforces Round #448(Div.2) Editorial ABC

    被B的0的情况从头卡到尾.导致没看C,心情炸裂又掉分了. A. Pizza Separation time limit per test 1 second memory limit per test ...

  2. Codeforces Round #448 (Div. 2)C. Square Subsets

    可以用状压dp,也可以用线型基,但是状压dp没看台懂... 线型基的重要性质 性质一:最高位1的位置互不相同 性质二:任意一个可以用这些向量组合出的向量x,组合方式唯一 性质三:线性基的任意一个子集异 ...

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

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

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

  6. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  7. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  8. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  9. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

随机推荐

  1. struts2使用jsp和<s:property>标签获取json格式的返回数据

    struts2使用jsp和<s:property>标签获取json格式的返回数据 1.struts2的action中 return "success"; 2.指向的返回 ...

  2. table width 决定 td width

    w td width 有无在chrome edge ff 均未影响td实际宽度,td接近等比分配table width. <!doctype html> <html lang=&qu ...

  3. Python SQLAlchemy基本操作和常用技巧(包含大量实例,非常好)

    https://www.jb51.net/article/49789.htm 首先说下,由于最新的 0.8 版还是开发版本,因此我使用的是 0.79 版,API 也许会有些不同.因为我是搭配 MySQ ...

  4. caffe杂

    一.finetune命令: mpirun /home/zhangsuosheng/caffe_mpi/build/tools/caffe train -solver solver.prototxt - ...

  5. django 配置 多数据库

    django多数据库 阅读spider platform时发现前端项目中使用了多数据库,那么django实现多数据库需要哪些配置呢,又如何使用呢? 定义及路由机制 定义 在settings里面的DAT ...

  6. 让Windows Server 2008+IIS 7+ASP.NET支持10万个同时请求

    具体设置如下: 1. 调整IIS 7应用程序池队列长度 由原来的默认1000改为65535. IIS Manager > ApplicationPools >Advanced Settin ...

  7. Spring-Hello World实例

    Spring Hello World实例 创建Java项目 添加Jar包 创建源文件 现在在Spring项目下创建实际的源文件.首先,要创建一个名为com.tuorialsponit的包,然后在该co ...

  8. LINQ不包含列表

    var query=lista.Where(p=>!listb.Any(g=>p.id==g.id && p.no==g.no))

  9. sizeof 是编译时运算符

    typedef char RT1;typedef struct{ char a[2]; } RT2;template<typename T> RT1 test(typename T::X ...

  10. jmeter+ant+jenkins接口自动环境搭建

    ant 下载地址:http://archive.apache.org/dist/ant/binaries/ 下载:apache-ant-1.9.7-bin.zip 解压到系统盘下:D:\apache- ...