#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#define ep emplace_back
using namespace std;
void solve() {
int ans = 0;
int a1, b1, a2, b2;
cin >> a1 >> a2 >> b1 >> b2;
int cnt1 = 0, cnt2 = 0;
if (a1 > b1)
cnt1++;
else if (a1 < b1)
cnt2++;
if (a2 > b2)
cnt1++;
else if (a2 < b2)
cnt2++;
if (cnt1 > cnt2)
ans += 2;
cnt1 = cnt2 = 0;
if (a1 > b2)
cnt1++;
else if (a1 < b2)
cnt2++;
if (a2 > b1)
cnt1++;
else if (a2 < b1)
cnt2++;
if (cnt1 > cnt2)
ans += 2;
cout << ans << "\n";
}
int main() {
int T = 1;
cin >> T;
while (T--) {
solve();
}
return 0;
}
#include<iostream>
using namespace std;
void solve(){
int n,s,m;
scanf("%d%d%d",&n,&s,&m);
bool ok=0;
int pos=0;
for(int i = 0; i < n; ++i){
int l,r;
scanf("%d%d",&l,&r);
int k = l-pos;
if( k>=s )
ok=1;
pos=r;
}
if(m-pos>=s) ok=1;
if(ok) cout<<"YES";
else cout<<"NO";
cout<<"\n";
}
int main(){
int T;
cin>>T;
while(T--){
solve();
}
}
#include <iostream>
#include <string>
#include <vector>
#include <unordered_set>
using namespace std;
void solve(){
string s,t;
cin>>s>>t;
int j=0;
for(int i = 0; i < s.size(); ++i){
if(s[i] == '?' ){
if(j < t.size()){
s[i] = t[j];
++j;
}
else {
s[i] = 'a';
}
}
else if( s[i] == t[j] and j<t.size()){
++j;
}
}
if(j == t.size()) cout<<"YES"<<"\n"<<s;
else cout<<"NO";
cout<<"\n";
}
int main(){
int _;
cin>>_;
while(_ --){
solve();
}
}
#include <iostream>
#include <cmath>
#include <cstdio>
#define lld long long
using namespace std;
int f(int x){
int ans=0;
while(x!=0){
x/=3;
ans++;
}
return ans;
}
void solve(){
int L,R;
cin>>L>>R;
int K = f(L);
int M = f(R);
lld ans=0;
int a[50],b[50];
for(int i=0;i<=32;++i){
a[i] = pow(3,i);
b[i] = pow(3,i+1)-1;
}
ans+=2*f(L);
int pos=L+1;
for(int i=f(L+1) ; i <= M; ++i){
//printf("ans=%d ",ans);
int pos2 = b[i-1];
if(pos2>R){
pos2=R;
//printf("pos=%d pos2=%d \n",pos,pos2);
ans+=(pos2-pos+1)*i;
break;
}
else {
//printf("pos=%d pos2=%d \n",pos,pos2);
ans+=(pos2-pos+1)*i;
pos = a[i];
}
}
cout<<ans<<"\n";
}
int main(){
int T;
cin>>T;
while(T--){
solve();
}
}
// 2 3 4 5 6 7 8 9 10 11 12
// 1 2 2 2 2 2 2 3 3 3 3
// 14+12 = 22
大意:
思路: