A
题意
思路
数据范围有迷惑性…
- 当
k>10
时,可直接输出n - 否则,循环存入set数的每一位,用set的size判断是否满足
代码
- 100分
#include<cstdio>
#include<set>
using namespace std;
int main(void){
int n,k;
scanf("%d%d",&n,&k);
int res=0;
for(int i=0;i<n;i++){
long long a;
scanf("%lld",&a);
if(k>10) continue;
else{
set<int> s;
long long tmp=a;
while(tmp>0){
int i=tmp%10;
tmp/=10;
s.insert(i);
}
if(s.size()<k) res++;
}
}
if(k>10) printf("%d\n",n);
else printf("%d\n",res);
return 0;
}
B
题意
思路
数据量不大,直接暴力
- 遍历每个点分别作为圆心,求它与其与各个点的最大距离作为半径
- 若半径小于当前记录的最小半径,则更新圆心和半径信息
- 若相等,按题意先按x最小再按y最小的原则,更新信息
总结
场上爆0了…
注意要求输出的是r^2
代码
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF=1e16;
int n;
struct P{
ll x,y;
} p[1010];
ll pow2(ll x){ return x*x; }
ll dis(ll x1, ll y1, ll x2, ll y2){ return pow2(x1-x2) + pow2(y1-y2); }
int main(void){
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%lld%lld",&p[i].x,&p[i].y);
ll resx=INF,resy=INF, resd=INF;
for(int i=0;i<n;i++){
ll x=p[i].x, y=p[i].y, mxdis=0;
for(int j=0;j<n;j++)
mxdis = max(mxdis,dis(x,y,p[j].x,p[j].y));
if(mxdis < resd)
resx=x, resy=y, resd=mxdis;
else if(mxdis==resd){
if(resx>x)
resx=x, resy=y, resd=mxdis;
else if(resx==x && resy>y)
resx=x, resy=y, resd=mxdis;
}
}
printf("%lld.00 %lld.00\n",resx,resy);
printf("%lld.00\n",resd);
return 0;
}
C
题意
思路
总结
代码