Codeforces Round 970 (Div. 3) 2008B. Square or Not Solution
Solution in C++:
- /// Author : AH_Tonmoy
- #include <bits/stdc++.h>
- using namespace std;
- int32_t main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- int t;
- cin >> t;
- while (t--) {
- int n ; cin >> n ;
- string s ; cin >> s ;
- int cnt = 0 ;
- for (int i = 0 ; i < n ; i++){
- if(s[i] == '0'){
- break ;
- }
- else{
- cnt++;
- }
- }
- if(n == 4){
- if( cnt == n){
- cout <<"YES\n";
- }
- else{
- cout <<"NO\n";
- }
- }
- else {
- if( (cnt - 1 ) * (cnt - 1 ) == n){
- cout <<"YES\n";
- }
- else{
- cout <<"NO\n";
- }
- }
- }
- return 0 ;
- }
No comments