链接
比赛地址
A
#include <iostream>
using namespace std;
const int N = 1e2+10;
int a[N];
bool vis[N];
int main()
{
int t;
cin >> t;
while(t--){
int n;
cin >> n;
for(int i=1;i<=n;++i){
cin >> a[i];
vis[i]=0;
}
int c = 0;
for(int i=1;i<=n;++i){
int pre = a[i];
if(!vis[i]){
vis[i]=1;
c++;
}else continue;
for(int j=i+1;j<=n;++j){
if(vis[j]) continue;
if(a[j]>pre){
pre = a[j];
vis[j]=1;
}
}
}
cout << c << '\n';
}
return 0;
}
B
#include <iostream>
using namespace std;
typedef long long ll;
const int N = 1e4+10;
ll a[N],n,p;
bool get(ll x){
ll d;
while(x){
d=x%10;
x/=10;
if(d==p){
return true;
}
}
return false;
}
void solve(){
for(int i=1;i<=n;i++){
bool flag = get(a[i]);
ll tmp,tot;
tmp=tot=0;
while(tmp<=a[i]&&!flag){
tmp=p*(++tot);
if(tmp > a[i]) break;
if(tmp%10==a[i]%10||get(a[i]-tmp)){
flag = true;
break;
}
}
if(flag){
cout << "YES\n";
}else{
cout << "NO\n";
}
}
}
int main()
{
std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int t;
cin >> t;
while(t--){
cin >> n >> p;
for(int i=1;i<=n;i++) cin >> a[i];
solve();
}
return 0;
}
C
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
const int N = 1e5+10;
ll d[N<<1];
ll t[N];
int n;
map<ll,ll> m;
bool solve(){
ll tot = 0;
for(auto i : m){
if(i.second!=2||i.first&1) return false;
d[++tot]=i.first/2;
}
tot = 1,t[1]=0;
for(int i=2;i<=n;++i,++tot){
if((d[i]-d[i-1])%tot!=0||d[i]==d[i-1]){
return false;
}
t[i]=t[i-1]+(d[i]-d[i-1])/tot;
}
for(int i=2;i<=n;++i){
d[1]-=t[i];
}
if(d[1]<=0||d[1]%n!=0){
return false;
}
return true;
}
int main()
{
std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int t;
cin >> t;
while(t--){
cin >> n;
m.clear();
for(int i=1;i<=2*n;++i){
cin >> d[i];
m[d[i]]++;
}
if(solve()){
cout << "YES\n";
}else{
cout << "NO\n";
}
}
return 0;
}