2021-07-31

原题链接:
https://acm.hdu.edu.cn/showproblem.php?pid=6985

Problem Description
This summer, ZXyang became so tired when doing the
problems of Multi-University contests. So he decided to attend the
Unified National Graduate Entrance Examination. This day, he sees a
problem of series.

Let S(x) be a function with x as the independent variable. S(x) can be
represented by the formula as follow.

f(x)=∑i=1nfi(x)

S(x)=∑j=1xf(j)

fi(x) is a function with x as the independent variable. Furthermore.
fi(x) belongs to the function set F.

F={C,Cx,Csinx,Ccosx,Csinx,Ccosx,Cx,Cx}

C is a constant integer ranging from 0 to 109.

ZXyang wonders if S(x) is convergent. S(x) is convergent if and only
if limx→∞S(x)=c, where c is a constant.

Input
The first line of input contains a single integer t (1≤t≤104)
— the number of test cases.

The first and the only line of each test case contains a single string
s (1≤|s|≤100), indicating the formula of f(x). Fraction is presented
as a/b. Cx is presented as C^x. It’s guaranteed that the constant C
won’t be left out when C=1. f(x) consists of functions from F
connected with +.

Output
For each test case, print YES in one line if S(x) is a
convergent sequence, or print NO in one line if not.

Sample
Input 2 1sinx+0cosx+3x+6/sinx
0

Sample Output
NO
YES

题意为:给出一个序列S,判断它是否收敛。因为对于S里的每一个函数,如sinx,表示sin1+sin2+``````+sinx是否收敛。巧妙的是,在这道题中,所有可用的函数块都是发散的,所以根本不用判断具体的函数式,只需要判断它们的系数是否全部为0,常数项也要为0.

include<bits/stdc++.h>
using namespace std;
char s[MAXN];
void solve()
{
    scanf("%s",s+1);
    int lst=1,n=LEN(s+1);
    Vpii vec;
    for(int i=1;i<=n;i++)if(s[i]=='+')
        vec.pb({lst,i-1}),lst=i+1;
    vec.pb({lst,n});
    for(auto j:vec)
    {
        bool f=0;
        for(int i=j.fi;i<=j.se;i++)
            if(s[i]=='0'&&!isdigit(s[i-1]))f=1;
        if(!f)return W("NO");
    }
    W("YES");
}

int main()
{
    srand(time(0));
    //freopen("input.txt","r",stdin);
    //freopen("test_output.txt","w",stdout);
    int T=1;
    scanf("%d",&T);
    for(int kase=1;kase<=T;kase++)
    {
        //printf("Case #%d: ",kase);
        solve();
    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值