题目链接:http://codeforces.com/problemset/problem/1189/A
思路:统计1 和 0 的个数,不相等拆开字符串,否则不拆。
AC代码:
1 #include<bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 int n; 6 string a; 7 while(cin >> n) 8 { 9 cin >> a; 10 int s1= 0,s0 = 0; 11 for(int i = 0;i < n;i++) 12 { 13 if(a[i] == '1') s1++; 14 else s0++; 15 } 16 if(s0 != s1) cout << 1 << endl << a << endl; 17 else{ 18 cout << 2 << endl; 19 cout << a[0] << " "; 20 for(int i = 1;i < n;i++) 21 { 22 cout << a[i]; 23 } 24 cout << endl; 25 } 26 } 27 return 0; 28 }