#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
inline void read(int &T) {
int x=0;bool f=0;char c=getchar();
while(c<‘0‘||c>‘9‘){if(c==‘-‘)f=!f;c=getchar();}
while(c>=‘0‘&&c<=‘9‘){x=x*10+c-‘0‘;c=getchar();}
T=f?-x:x;
}
int main() {
for(int i=1,x;i<=5;++i) {
read(x);
if(x==0) {
std::cout<<i<<‘\n‘;
return 0;
}
}
return 0;
}
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
inline void read(int &T) {
int x=0;bool f=0;char c=getchar();
while(c<‘0‘||c>‘9‘){if(c==‘-‘)f=!f;c=getchar();}
while(c>=‘0‘&&c<=‘9‘){x=x*10+c-‘0‘;c=getchar();}
T=f?-x:x;
}
int x,y;
int main() {
read(x),read(y);
for(int i=0;i<=x;++i) {
int j=x-i;
if(i*2+j*4==y) {
puts("Yes");
return 0;
}
}
puts("No");
return 0;
}
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#define MAXN 101
inline void read(int &T) {
int x=0;bool f=0;char c=getchar();
while(c<‘0‘||c>‘9‘){if(c==‘-‘)f=!f;c=getchar();}
while(c>=‘0‘&&c<=‘9‘){x=x*10+c-‘0‘;c=getchar();}
T=f?-x:x;
}
int x,n,a[MAXN];
bool appear[201];
int main() {
read(x),read(n);
for(int i=1;i<=n;++i) {
read(a[i]);
appear[a[i]]=1;
}
std::sort(a+1,a+n+1);
int minn=2147483647,ans;
for(int i=101;i>=0;--i) {
if(!appear[i]) {
if(abs(x-i)<=minn) {
minn=abs(x-i);
ans=i;
}
}
}
std::cout<<ans<<‘\n‘;
return 0;
}
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#define MAXN 200001
inline void read(int &T) {
int x=0;bool f=0;char c=getchar();
while(c<‘0‘||c>‘9‘){if(c==‘-‘)f=!f;c=getchar();}
while(c>=‘0‘&&c<=‘9‘){x=x*10+c-‘0‘;c=getchar();}
T=f?-x:x;
}
int n,a[MAXN],times[MAXN*10];
bool okay[MAXN*10];
int main() {
read(n);int maxx=0;
for(int i=1;i<=n;++i) {
read(a[i]);
if(a[i]>maxx) maxx=a[i];
++times[a[i]];
}
std::sort(a+1,a+n+1);int ans=0;
for(int i=1;i<=n;++i) {
if(okay[a[i]]==1) continue;
++ans;
if(times[a[i]]>=2) {
okay[a[i]]=1;
--ans;
}
int j=a[i]+a[i];
while(j<=maxx) {
okay[j]=1;
j+=a[i];
}
}
std::cout<<ans<<‘\n‘;
return 0;
}
【比赛】 AtCoder Beginner Contest 170
原文:https://www.cnblogs.com/poi-bolg-poi/p/13127316.html