2019牛客暑期多校训练营(第七场)D Number(思维)
生活随笔
收集整理的這篇文章主要介紹了
2019牛客暑期多校训练营(第七场)D Number(思维)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
鏈接: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-9const 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
總結
以上是生活随笔為你收集整理的2019牛客暑期多校训练营(第七场)D Number(思维)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2019牛客暑期多校训练营(第七场)J
- 下一篇: 异步编程异常和死锁处理