Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
- #define ff first
- #define ss second
- #define int long long
- #define pb push_back
- #define pii pair<int,int>
- #define print(x) for(auto it : x) cout<<it<<' '; cout<<'\n';
- #define debug(x) cout<< #x << " ---> " << x << "\n"
- #define p(x,y) fixed<<setprecision(y)<<x
- #define yes cout << "YES" << endl;
- #define no cout << "NO" << endl;
- #define mod 1000000007
- #define inf 2000000009
- #define PI (acos(-1))
- #define eps (1e-8)
- #define clear(x) memset(x,0,sizeof(x));
- main()
- {
- fastio;
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- int n;
- string s;
- cin >> n >> s;
- int totalsum = 0;
- for(int i = 0; i < n; i++) totalsum += s[i] - '0';
- // debug(totalsum);
- string ans = "NO";
- for(int i = 2; i <= n; i++)
- {
- if(totalsum % i == 0)
- {
- int testsum = 0, cnt = 0;
- for(int j = 0; j < n; j++)
- {
- testsum += s[j] - '0';
- if(testsum == (totalsum / i))
- {
- testsum = 0;
- cnt++;
- }
- }
- if(cnt == i)
- {
- ans = "YES";
- break;
- }
- }
- }
- cout << ans << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement