4947. Large Integer
Given two integers n,k.
Please output an n-digit number, requiring all digits to be k.
input format
A total of one line, containing two integers n,k.
output format
An integer representing the n-bit number that satisfies the requirement.
data range
The first three test points satisfy 1≤n≤3.
All test points satisfy 1≤n≤100, 1≤k≤9.
Input sample:
3 2
Sample output:
222
#include <iostream>
using namespace std;
int main()
{
int n, k;
cin >> n >> k;
while(n --) cout << k ;
return 0;
}
4948. Large Product
We stipulate that if a non-negative integer a satisfies one of the following two conditions, then a is called a beautiful number:
- a=0
- a=10x, where x is any non-negative integer.
Given n non-negative integers a1,a2,…,an, at least n−1 of them are beautiful numbers.
Please calculate and output the result of a1×a2×…×an.
input format
The first line contains the integer n.
The second row contains a1,a2,…,an.
output format
A total of one line, output an integer without leading 00, indicating the result of a1×a2×…×an.
data range
The first 33 test points satisfy 1≤n≤5.
All test points satisfy 1≤n≤105, a1∼an are non-negative integers without leading 0, and the total length of these n numbers does not exceed 105.
Input sample 1:
3
5 10 1
Output sample 1:
50
Input sample 2:
4
1 1 10 11
Output sample 2:
110
Input sample 3:
5
0 3 1 100 1
Output sample 3:
0
#include <iostream>
using namespace std;
int n;
int main () {
string ans = "1";
int cnt = 0;
cin >> n;
while (n--) {
string x;
cin >> x;
if (x == "0") {
puts ("0");
return 0;
}
bool flag = true;
for (int i = 1;i < x.size ();i++) {
if (x[i] != '0') flag = false;
}
int c = x.size () - 1;
if (x[0] != '1') flag = false;
if (flag) cnt += c;
else ans = x;
}
cout << ans;
while (cnt--) cout << 0;
return 0;
}
4949. Consecutive zeros at the end
Given a positive integer m, please count how many positive integers n are satisfied, and the number of consecutive 00s at the end of the factorial of n is exactly m.
Output the number of ns that satisfy the condition and all ns that satisfy the condition.
For example, when m=1, there are 5 positive integers n satisfying the condition, which are 5, 6, 7, 8, 9, among which 5!=120,6!=720,7!=5040,8!=40320 ,9!=3628805!=120,6!=720,7!=5040,8!=40320,9!=362880.
input format
A total of one line, a positive integer m�.
output format
If there is n� that meets the condition, the first line outputs the number of n� that meets the condition, and the second line outputs all n� that meet the condition in ascending order.
If there is no n� that satisfies the condition, 0
just output one line.
data range
The first 55 test points satisfy 1≤m≤101≤�≤10.
All test points satisfy 1≤m≤1051≤�≤105.
Input sample 1:
1
Output sample 1:
5
5 6 7 8 9
Input sample 2:
5
Output sample 2:
0
#include <iostream>
#include <vector>
using namespace std;
int n,m;
int cnt[10];
int main () {
cin >> m;
vector <int> v;
for (int i = 1;i <= 1e7;i++) {
int t = i;
while (t % 2 == 0) cnt[2]++,t /= 2;
while (t % 5 == 0) cnt[5]++,t /= 5;
if (min (cnt[2],cnt[5]) == m) v.push_back (i);
}
cout << v.size () << endl;
for (int x : v) cout << x << ' ';
return 0;
}