A题 链接
我用了一个类似二分吧,就是不断缩减x,y的范围,与k相乘是否在l,r的区间中,然后再判断一下,不过这里要用longlong,因为int会爆,过了之后突然发现,这题数据直接暴力就能过。。。哎
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
ll l,r,x,y,k;
bool solve(){
ll mid = (y+x)/2;
if(l <= mid*k && mid*k <= r)
return true;
if(l <= y*k && y*k <= r)
return true;
if(l <= x*k && x*k <= r)
return true;
return false;
}
int main(void){
scanf("%lld %lld %lld %lld %lld",&l,&r,&x,&y,&k);
while(y - x > 1){
ll mid = (y+x)/2;
if(mid*k > r) y = mid;
else if(mid*k < l) x = mid;
else
break;
}
if(solve())
printf("YES\n");
else
printf("NO\n");
return 0;
}
B题链接
直接看图就能明白题意了,比A还简单。直接判断就行了,不过我好像判断麻烦了。算了。
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
const double eps = 1e-5;
int R,D,S,N;
int main(void){
scanf("%d %d",&R,&D);
scanf("%d",&N);
S = R-D;
int res = 0;
int x,y,r;
for(int i=1;i<=N;i++){
scanf("%d %d %d",&x,&y,&r);
double dis = pow(x,2) + pow(y,2);
dis = sqrt(dis);
if(dis + r < R || abs(dis+r-R) < eps){
if((dis - S > r || abs(dis-S-r) < eps) && (dis-S < D || abs(dis-S-D) < eps)){
res++;
}
}
}
printf("%d\n",res);
return 0;
}
C题 链接
神他么,最开始没看懂,后来看UOJ大神在讨论好像有点明白了,但还是没过。。至于D题好像是个线段树,,。。我好菜啊啊啊啊啊。烦的一匹。C题补过了,在这里:http://blog.csdn.net/zhao5502169/article/details/77727226