这场昨晚没打,早上补的,错过了一场上分场
a.1,2,3特殊处理,其他奇数和偶数下降次数分别为2,3
#include<bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define debug(x) cout<<#x<<" is "<<x<<endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define DBG 0
const int N = 1e5 + 5;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll LLINF = (1LL<<60);
using namespace std;
const int mod = 998244353;
ll fast_pow(ll a,ll b){
ll ans = 1;
while(b){
if(b&1)ans = (ans * a)%mod;
a = (a * a)%mod;
b>>=1;
}
return (ans%mod);
}
inline int read()
{
int x = 0, flag = 1;
char c = getchar();
while(c < '0' && c > '9') {if(c == '-') flag = -1, c = getchar();}
while(c >= '0' && c <= '9') {x = x * 10 + c - '0', c = getchar();}
return x * flag;
}
typedef pair<int,int> pii;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#if DBG
freopen("input.txt","r",stdin);
#endif
int t ;
cin>>t;
while(t--){
int n;
cin>>n;
if(n == 1){
cout<<0<<endl;
continue;
}
if(n == 2){
cout<<1<<endl;
continue;
}
if(n % 2 == 0 || n == 3){
cout<<2<<endl;
continue;
}
cout<<3<<endl;
}
return 0;
}
b.只需要知道s[l]前面是否存在s[l]或者s[r]后面是否存在s[r]
#include<bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define debug(x) cout<<#x<<" is "<<x<<endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define DBG 0
const int N = 100 + 5;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll LLINF = (1LL<<60);
using namespace std;
const int mod = 998244353;
ll fast_pow(ll a,ll b){
ll ans = 1;
while(b){
if(b&1)ans = (ans * a)%mod;
a = (a * a)%mod;
b>>=1;
}
return (ans%mod);
}
inline int read()
{
int x = 0, flag = 1;
char c = getchar();
while(c < '0' && c > '9') {if(c == '-') flag = -1, c = getchar();}
while(c >= '0' && c <= '9') {x = x * 10 + c - '0', c = getchar();}
return x * flag;
}
typedef pair<int,int> pii;
char s[N];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#if DBG
freopen("input.txt","r",stdin);
#endif
int t;
cin>>t;
while(t--){
int n,q;
cin>>n>>q;
cin>>(s + 1);
for(int i = 1;i <= q;i++){
int l,r;
cin>>l>>r;
bool f = false;
for(int j = l - 1;j >= 1;j--)if(s[j] == s[l])f = true;
for(int j = r + 1;j <= n;j++)if(s[j] == s[r])f = true;
if(f)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}
return 0;
}
c.瞎搞,找规律
#include<bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define debug(x) cout<<#x<<" is "<<x<<endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define DBG 0
const int N = 1e6 + 5;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll LLINF = (1LL<<60);
using namespace std;
const int mod = 998244353;
ll fast_pow(ll a,ll b){
ll ans = 1;
while(b){
if(b&1)ans = (ans * a)%mod;
a = (a * a)%mod;
b>>=1;
}
return (ans%mod);
}
inline int read()
{
int x = 0, flag = 1;
char c = getchar();
while(c < '0' && c > '9') {if(c == '-') flag = -1, c = getchar();}
while(c >= '0' && c <= '9') {x = x * 10 + c - '0', c = getchar();}
return x * flag;
}
typedef pair<int,int> pii;
char a[N],b[N];
int cnta[26],cntb[26];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#if DBG
freopen("input.txt","r",stdin);
#endif
int t;
cin>>t;
while(t--){
int n,k;
for(int i = 0;i<26;i++)cnta[i] = cntb[i] = 0;
cin>>n>>k;
cin>>(a+1);
cin>>(b+1);
for(int i = 1;i <= n;i++){
cnta[a[i] - 'a']++;
cntb[b[i] - 'a']++;
}
bool f = true;
int res = 0;
for(int i = 0;i < 26;i++){
if(abs(cnta[i] - cntb[i])% k != 0){
f = false;break;
}
if(cnta[i] - cntb[i] < 0){
if(res < abs(cnta[i] - cntb[i])){
f = false;
break;
}
res -= abs(cnta[i] - cntb[i]);
}
if(cnta[i] - cntb[i] > 0){
res += abs(cnta[i] - cntb[i]);
}
}
if(f)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
return 0;
}
d.博弈论,显然,画一下决策树就知道,两个玩家必然能强制性的达到(x * k,(x + 1) * k) 或((x+1) * k,x * k的位置,分析一下这种局面对谁有利即可
#include<bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define debug(x) cout<<#x<<" is "<<x<<endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define DBG 0
const int N = 1e5 + 5;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll LLINF = (1LL<<60);
using namespace std;
const int mod = 998244353;
ll fast_pow(ll a,ll b){
ll ans = 1;
while(b){
if(b&1)ans = (ans * a)%mod;
a = (a * a)%mod;
b>>=1;
}
return (ans%mod);
}
inline int read()
{
int x = 0, flag = 1;
char c = getchar();
while(c < '0' && c > '9') {if(c == '-') flag = -1, c = getchar();}
while(c >= '0' && c <= '9') {x = x * 10 + c - '0', c = getchar();}
return x * flag;
}
typedef pair<int,int> pii;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#if DBG
freopen("input.txt","r",stdin);
#endif
int t;
cin>>t;
while(t--){
ll d,k;
cin>>d>>k;
ll L = 1,ans = 0;
while(1){
if(2 * (L * k) *(L * k) <= d * d){
ans = L * k;
}else break;
L++;
}
//debug(ans);
if((ans + k) * (ans + k) + ans * ans <= d * d)
cout<<"Ashish"<<endl;
else cout<<"Utkarsh"<<endl;
}
return 0;
}
e1&e2,可以通过n - 1次询问,问出x[1] ^ x[i],i∈[2,n],那么只需要知道x[1]便可求解,如果存在两值相等,他们的异或x[1]值是相等的,再询问这两个位置的相与的值便可知道这两个的值,便可求得x[1]。如果不存在相等的值,说明他们的值是严格分布在[1,2^n-1]之间,那么必存在一个值异或x[1] == 1,高位相同,询问它们相与的值可以得到除第零位的所有值,x[1]第零位还不得而知,这时只需要再问一下与x[1]异或第零位为零的值和x[1]相与的值便可知道x[1]的第零位。详见代码:
#include<bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define debug(x) cout<<#x<<" is "<<x<<endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define DBG 0
const int N = 1e5 + 5;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll LLINF = (1LL<<60);
using namespace std;
const int mod = 998244353;
ll fast_pow(ll a,ll b){
ll ans = 1;
while(b){
if(b&1)ans = (ans * a)%mod;
a = (a * a)%mod;
b>>=1;
}
return (ans%mod);
}
inline int read()
{
int x = 0, flag = 1;
char c = getchar();
while(c < '0' && c > '9') {if(c == '-') flag = -1, c = getchar();}
while(c >= '0' && c <= '9') {x = x * 10 + c - '0', c = getchar();}
return x * flag;
}
typedef pair<int,int> pii;
int a[N];
map<int,int> st;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#if DBG
freopen("input.txt","r",stdin);
#endif
int n,x = 0,y;
cin>>n;
st[0] = 1;
for(int i = 2;i <= n;i++){
cout<<"XOR "<<1<<" "<<i<<endl;
cin>>a[i];
if(st[a[i]] && !x){
cout<<"AND "<<st[a[i]]<<" "<<i<<endl;
cin>>y;
x = i;
}
st[a[i]] = i;
}
if(x){
a[1] = a[x] ^ y;
}else{
cout<<"AND "<<1<<" "<<st[1]<<endl;
cin>>a[1];
for(auto it:st){
if(it.fi & 1 == 1 || it.se == 1)continue;
cout<<"AND "<<1<<" "<<it.se<<endl;
int c;
cin>>c;
if(c&1)a[1]^=1;
break;
}
}
cout<<"! "<<a[1];
for(int i = 2;i <= n;i++)
cout<<" "<<(a[i] ^ a[1]);
cout<<endl;
return 0;
}