根据题意,p/q的整数部分一定是a[i],然后小数部分的倒数进行同样的处理判断即可
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#define LL long long
using namespace std;
LL gcd(LL a,LL b)
{
return b==0?a:gcd(b,a%b);
}
LL num[100];
int main()
{
//freopen("in.txt","r",stdin);
LL q,p;
int n;
cin>>p>>q>>n;
for(int i=1; i<=n; i++)
cin>>num[i];
LL temp;
for(int i=1; i<n; i++)
{
temp=floor(p*1.0/q);
if(temp<num[i])
{
cout<<"NO\n";
return 0;
}
p-=num[i]*q;
LL hg=gcd(p,q);
p/=hg;
q/=hg;
hg=p;
p=q;
q=hg;
if(p==0||q==0)
{
cout<<"NO\n";
return 0;
}
// cout<<p<<" "<<q<<endl;
}
if(p%q==0&&num[n]==p/q)
cout<<"YES\n";
else cout<<"NO\n";
return 0;
}