1 #include2 using namespace std; 3 char s[105]; 4 char p[]={ "CODEFORCES"}; 5 int main() 6 { 7 cin>>s; 8 int j=0; 9 int len=strlen(s);10 for(int i=0;i
substr函数写法:
1 #include2 using namespace std; 3 int main() 4 { 5 string s; 6 cin>>s; 7 for(int i=0;i
如果还有其它方法欢迎私信我!QAQ
B. Quasi Binary
A number is called quasibinary if its decimal representation contains only digits 0 or 1. For example, numbers 0, 1, 101, 110011 — are quasibinary and numbers 2, 12, 900 are not.
You are given a positive integer n. Represent it as a sum of minimum number of quasibinary numbers.
The first line contains a single integer n (1 ≤ n ≤ 106).
In the first line print a single integer k — the minimum number of numbers in the representation of number n as a sum of quasibinary numbers.
In the second line print k numbers — the elements of the sum. All these numbers should be quasibinary according to the definition above, their sum should equal n. Do not have to print the leading zeroes in the numbers. The order of numbers doesn't matter. If there are multiple possible representations, you are allowed to print any of them.
9
9 1 1 1 1 1 1 1 1 1
32
3 10 11 11
1 #include2 using namespace std; 3 int main() 4 { 5 int n; 6 int s[11]; 7 int k=1,maxn=0; 8 memset(s,0,sizeof(s)); 9 cin>>n;10 while(n)11 {12 int a=n%10;13 n/=10;14 maxn=max(maxn,a);15 for(int i=1;i<=a;i++)16 s[i]+=k;17 k*=10;18 }19 cout< <