链接:https://ac.nowcoder.com/acm/contest/887/D来源:牛客网
题目描述
I have a very simple problem for you. Given a positive integeter
n (1≤n≤1000000)n\ (1 \leq n \leq 1000000)n (1≤n≤1000000) and a prime number p (2≤p≤1000000)p\ (2 \leq p \leq 1000000)p (2≤p≤1000000), your job is to output a positive number which is divisible by and has exactly digits. Please output "T_T" if you can not find such number.
输入描述:
The first line of the input file contains two integers
n (1≤n≤1000000)n\ (1 \leq n \leq 1000000)n (1≤n≤1000000) and p (2≤p≤1000000)p\ (2 \leq p \leq 1000000)p (2≤p≤1000000). is a prime number.
输出描述:
Output one number (without leading zeros) or "T_T"
示例1
输入
复制
2 5
输出
复制
10
示例2
输入
复制
1 11
输出
复制
T_T
示例3
输入
复制
5 2
输出
复制
10000
思路:一开始读题,理解成了最小的那个能整除p的n位数,原来忽略了一个positive...心累,算了,菜真是没办法
#include <cstdio>
#include <iostream>
#include <cmath>
#include <
string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
using namespace std;
#define ll long long
#define eps 1e-9
const int inf =
0x3f3f3f3f;
const int mod = 1e9+
7;
int n, p, ans, q, len;
int main()
{
scanf("%d%d", &n, &
p);
q =
p;
len =
0;
while(q)
{
len++
;
q /=
10;
}
if(len >
n)
printf("T_T\n");
else
{
printf("%d", p);
n = n -
len;
while(n)
{
printf("0");
n--
;
}
printf("\n");
}
return 0;
}
转载于:https://www.cnblogs.com/RootVount/p/11346340.html