Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- int main()
- {
- int n;
- string s, t;
- cin>>n>>s;
- vector<int> cnt(10);
- vector<int> cnt2(10);
- for(auto e: s) cnt[e-'0']++;
- int ans = 0;
- for(ll int i=0, x; i<=1e7; i++)
- {
- x = i*i;
- fill(cnt2.begin(), cnt2.end(), 0);
- t = to_string(x);
- for(auto e: t) cnt2[e-'0']++;
- cnt2[0] = max(cnt2[0], cnt[0]);
- if(cnt == cnt2) ans++;
- }
- cout<<ans<<"\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment