19 SWERC 2022-2023 - Online Mirror (Unrated, ICPC Rules, Teams Preferred)L. Controllers(数学公式+瞎搞)

L. Controllers

思路:
ad6c59561bbebeb38f6e7bc997f62c3.jpg

#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;
}
  • 7
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值