#include<cstdio> #include<algorithm> #include<cmath> #include<vector> #include<string.h> #include<set> #include<string> #include<map> #include<iostream> #include<queue> #include<unordered_set> #include<stdlib.h> #include<sstream> #include<iomanip> typedef long long ll; using namespace std; const int Mod=1e9+7; const int N=2e5+7; int T; int n,q,m; int main() { cin >> T; while(T--){ int k,H,h[55]; cin>>n>>m>>k>>H; int cnt=0; for(int i=0;i<n;i++) { int dif=0; cin>>h[i]; dif=abs(H-h[i]); if(dif%k==0&&dif/k<m&&H!=h[i]) { cnt++; } } cout<<cnt<<endl; } system("pause"); return 0; }
#include<cstdio> #include<algorithm> #include<cmath> #include<vector> #include<string.h> #include<set> #include<string> #include<map> #include<iostream> #include<queue> #include<unordered_set> #include<stdlib.h> #include<sstream> #include<iomanip> typedef long long ll; using namespace std; const int Mod=1e9+7; const int N=2e5+7; int T; int n,q,m; int main() { cin >> T; while(T--){ cin>>n; int a[N],b[N]; map<int,int> mp; for(int i=0;i<n;i++) { cin>>a[i]; b[i] = a[i]; mp[a[i]]=i; } sort(a,a+n); int flag=0; for(int i=0;i<n;i++) { if(b[i]!=a[i]) { int f=mp[a[i]]; if((b[i]%2==0&&b[f]%2==0)||(b[i]%2!=0&&b[f]%2!=0)) { } else { cout<<"NO"<<endl; flag=1; break; } } } if(flag==0) { cout<<"YES"<<endl; } } system("pause"); return 0; }
#include<bits/stdc++.h> typedef long long ll; using namespace std; const int N = 2e5 + 7; int T; int n, q, m; int main() { int x,x1,x2; cin >> T; while (T--) { int k; cin >> n >> k; int c[N]; map<int, int> ha; for (int i = 1; i <= n; i++) { cin >> c[i]; ha[c[i]]++; } if(c[1] == c[n]){ int flag1 = 0; for(int i = 1;i <= ha[c[1]];i++){ if(i >= k){ if(i % k == 0){ flag1 = 1; cout << "YES" << endl; break; } } } if(!flag1)cout << "NO" << endl; } else{ if(ha[c[1]] < k || ha[c[n]] < k){ cout << "NO" << endl; } else{ int sum = 0,i = 1; while(sum < k && i <= n){ if(c[i] == c[1]){ sum++; } i++; } int sum1 = 0,i1 = n; while(sum1 < k && i1 >= i){ if(c[i1] == c[n]){ sum1++; } i1--; } if(sum1 >= k && sum >= k){ cout << "YES" << endl; } else cout << "NO" << endl; } } } system("pause"); return 0; }
标签:const,int,888,Codeforces,long,cin,--,Div,include From: https://www.cnblogs.com/oliverfg/p/17586027.html