L. Controllers
思路:
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define fep(i, a, b) for(int i = (a); i >= (b); --i)
#define _for(i, a, b) for(int i=(a); i<(b); ++i)
#define pii pair<int, int>
#define pdd pair<double,double>
#define ll long long
#define db double
#define endl '\n'
#define x first
#define y second
#define pb push_back
#define vi vector<int>
using namespace std;
const int maxn = 2e5 + 10;
int n,q,k1,k2;
string s;
void solve() {
cin>>n>>s>>q;
for(auto c:s){
if(c=='+') k1++;
else k2++;
}
// cout<<k1<<' '<<k2<<endl;
while(q--){
int x,y;
cin>>x>>y;
int tmp1=(k1-k2)*x;
int tmp2=(k2-k1)*y;
int p=x-y;
if(p==0){
if(tmp1==0||tmp2==0){
cout<<"YES"<<endl;
}else{
cout<<"NO"<<endl;
}
}else{
if(tmp1%p==0){
int d=(k1-k2)*x/(x-y);
if(d>=-k2&&d<=k1){
cout<<"YES"<<endl;
}else{
cout<<"NO"<<endl;
}
}else{
cout<<"NO"<<endl;
}
}
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// freopen("C:\\Users\\24283\\CLionProjects\\untitled2\\1.in", "r", stdin);
int _;
// cin >> _;
// while (_--)
solve();
return 0;
}
标签:k2,19,long,Controllers,int,k1,瞎搞,Mirror,define
From: https://www.cnblogs.com/cxy8/p/18052087