Question 1:
I have read the question for a long time. Fortunately, I finally understood it. Many of my classmates finally made a mistake.
The problem of whether to output or not when there is only one number.
[Cpp]
# Include <iostream>
# Include <queue>
# Include <algorithm>
# Include <cstdio>
# Include <cstdlib>
# Include <cstring>
# Include <string>
# Include <cmath>
# Include <map>
Using namespace std;
Const int n= 105;
Typedef long LL;
Int xh [N], cnt [N];
Int k = 0;
Int main ()
{
Int I, n;
Int c2 = 0;
Cin> n;
For (I = 0; I <n; I ++)
{
Scanf ("% d", & xh [I]);
If (xh [I]> = 10 & xh [I] <= 99 & xh [I] % 10 = 0)
{
C2 = xh [I];
}
}
Sort (xh, xh + n );
Int vis = 0, vis2 = 0, vis22 = 0;
For (I = 0; I <n; I ++)
{
If (xh [I] = 0 | xh [I] = 100)
Cnt [++ k] = xh [I];
If (xh [I]> = 1 & xh [I] <= 9 & vis = 0)
{
Cnt [++ k] = xh [I];
Vis = 1;
}
If (xh [I]> = 10 & xh [I] <= 99)
{
If (c2! = 0 & vis2 = 0)
{
Cnt [++ k] = c2;
Vis2 = 1;
}
If (c2 = 0)
{
If (vis = 0 & vis2 = 0)
{
Cnt [++ k] = xh [I];
Vis2 = 1;
}
}
}
}
Printf ("% d \ n", k );
For (I = 1; I <k; I ++)
Printf ("% d", cnt [I]);
Printf ("% d \ n", cnt [k]);
Return 0;
}
# Include <iostream>
# Include <queue>
# Include <algorithm>
# Include <cstdio>
# Include <cstdlib>
# Include <cstring>
# Include <string>
# Include <cmath>
# Include <map>
Using namespace std;
Const int n= 105;
Typedef long LL;
Int xh [N], cnt [N];
Int k = 0;
Int main ()
{
Int I, n;
Int c2 = 0;
Cin> n;
For (I = 0; I <n; I ++)
{
Scanf ("% d", & xh [I]);
If (xh [I]> = 10 & xh [I] <= 99 & xh [I] % 10 = 0)
{
C2 = xh [I];
}
}
Sort (xh, xh + n );
Int vis = 0, vis2 = 0, vis22 = 0;
For (I = 0; I <n; I ++)
{
If (xh [I] = 0 | xh [I] = 100)
Cnt [++ k] = xh [I];
If (xh [I]> = 1 & xh [I] <= 9 & vis = 0)
{
Cnt [++ k] = xh [I];
Vis = 1;
}
If (xh [I]> = 10 & xh [I] <= 99)
{
If (c2! = 0 & vis2 = 0)
{
Cnt [++ k] = c2;
Vis2 = 1;
}
If (c2 = 0)
{
If (vis = 0 & vis2 = 0)
{
Cnt [++ k] = xh [I];
Vis2 = 1;
}
}
}
}
Printf ("% d \ n", k );
For (I = 1; I <k; I ++)
Printf ("% d", cnt [I]);
Printf ("% d \ n", cnt [k]);
Return 0;
}
Question 2:
I took a look at the water question and directly simulated it. After that, I finally decided to wa.
Because it is possible that the approximate score does not cross the border during multiplication.
As someone reminds me, follow the instructions to see if each divisor is equal to ai.
[Cpp]
# Include <iostream>
# Include <queue>
# Include <algorithm>
# Include <cstdio>
# Include <cstdlib>
# Include <cstring>
# Include <string>
# Include <cmath>
# Include <map>
Using namespace std;
Const int n= 105;
Typedef _ int64 LL;
LL xh [N], p, q;
Int n, I;
Bool test ()
{
LL t;
For (I = 1; I <= n; I ++)
{
If (q = 0 | (p/q) <xh [I])
Return false;
T = p-xh [I] * q;
P = q;
Q = t;
}
If (q! = 0)
Return false;
Return true;
}
Int main ()
{
Scanf ("% I64d % I64d", & p, & q );
Cin> n;
For (I = 1; I <= n; I ++)
Scanf ("% I64d", & xh [I]);
If (test ())
Printf ("YES \ n ");
Else
Printf ("NO \ n ");
Return 0;
}
# Include <iostream>
# Include <queue>
# Include <algorithm>
# Include <cstdio>
# Include <cstdlib>
# Include <cstring>
# Include <string>
# Include <cmath>
# Include <map>
Using namespace std;
Const int n= 105;
Typedef _ int64 LL;
LL xh [N], p, q;
Int n, I;
Bool test ()
{
LL t;
For (I = 1; I <= n; I ++)
{
If (q = 0 | (p/q) <xh [I])
Return false;
T = p-xh [I] * q;
P = q;
Q = t;
}
If (q! = 0)
Return false;
Return true;
}
Int main ()
{
Scanf ("% I64d % I64d", & p, & q );
Cin> n;
For (I = 1; I <= n; I ++)
Scanf ("% I64d", & xh [I]);
If (test ())
Printf ("YES \ n ");
Else
Printf ("NO \ n ");
Return 0;
}
Question 3:
I came up with the idea of the question, but it cannot be realized.
According to the instructions of the advanced engineer, the binary bit is used to indicate the number of zeros that are output at the end.
[Cpp]
# Include <iostream>
# Include <queue>
# Include <algorithm>
# Include <cstdio>
# Include <cstdlib>
# Include <cstring>
# Include <string>
# Include <cmath>
# Include <map>
Using namespace std;
Const int n= 100005;
Typedef _ int64 LL;
Int save [110000];
Int main ()
{
Int n;
While (scanf ("% d", & n )! = EOF)
{
Map <int, int> mymap;
Map <int, int >:: iterator it;
For (int I = 1; I <= n; I ++)
{
Scanf ("% d", & save [I]);
It = mymap. find (save [I]);
If (it = mymap. end ())
{
Mymap [save [I] = 1;
}
Else
{
Mymap. erase (it );
Int temp = save [I] + 1;
While (mymap. find (temp )! = Mymap. end ())
{
Mymap. erase (temp );
Temp ++;
}
Mymap [temp] = 1;
}
}
It = mymap. begin ();
Int Max =-1, cnt = 0;
For (; it! = Mymap. end (); it ++)
{
Cnt ++;
Max = max (Max, it-> first );
}
Printf ("% d \ n", Max + 1-cnt );
}
Return 0;
}
# Include <iostream>
# Include <queue>
# Include <algorithm>
# Include <cstdio>
# Include <cstdlib>
# Include <cstring>
# Include <string>
# Include <cmath>
# Include <map>
Using namespace std;
Const int n= 100005;
Typedef _ int64 LL;
Int save [110000];
Int main ()
{
Int n;
While (scanf ("% d", & n )! = EOF)
{
Map <int, int> mymap;
Map <int, int >:: iterator it;
For (int I = 1; I <= n; I ++)
{
Scanf ("% d", & save [I]);
It = mymap. find (save [I]);
If (it = mymap. end ())
{
Mymap [save [I] = 1;
}
Else
{
Mymap. erase (it );
Int temp = save [I] + 1;
While (mymap. find (temp )! = Mymap. end ())
{
Mymap. erase (temp );
Temp ++;
}
Mymap [temp] = 1;
}
}
It = mymap. begin ();
Int Max =-1, cnt = 0;
For (; it! = Mymap. end (); it ++)
{
Cnt ++;
Max = max (Max, it-> first );
}
Printf ("% d \ n", Max + 1-cnt );
}
Return 0;
}