Codeforces Round #512 (Div. 2,) C. Vasya and Golden Ticket【暴力】
程序员文章站
2022-05-09 22:14:57
...
#include<bits/stdc++.h>
using namespace std;
char s[105];
int a[105];
int n;
int main()
{
cin>>n;
int sum=0;
for(int i=0; i<n; i++)
{
cin>>s[i];
a[i]=s[i]-'0';
sum+=a[i];
// printf("%d\n",sum);
}
if(sum==0)
{
cout<<"YES"<<endl;
return 0;
}
for(int i=1; i<sum; i++)
{
if(sum%i!=0) continue;
int cnt=0;
//printf("%d\n",i);
for(int j=0; j<n; j++)
{
cnt+=a[j];
if(cnt==i)
{
cnt=0;
}
else if(cnt>i)
{
break;
}
}
if(cnt==0)
{
cout<<"YES"<<endl;
return 0;
}
}
cout<<"NO"<<endl;
}
推荐阅读
-
Codeforces Round #512 (Div. 2, based on Technocup 2019 Elimination Round 1) D. Vasya and Triangle
-
Codeforces Round #512 (Div. 2 E. Vasya and Good Sequences 异或问题
-
Codeforces Round #512 (Div. 2) D. Vasya and Triangle
-
Codeforces Round #512 (Div. 2,) C. Vasya and Golden Ticket【暴力】
-
Codeforces Round #512 (Div. 2) - D. Vasya and Triangle (皮克公式)
-
Codeforces Round #512 Div. 2 A,B,C Vasya and Golden Ticket
-
Educational Codeforces Round 48 (Rated for Div. 2) C. Vasya And The Mushrooms(思维)