n!在k進制下的後綴0
阿新 • • 發佈:2018-04-11
brush str tput min factorial out ble 分享 actor
問n! 轉化成k進制後的位數和尾數的0的個數。【UVA 10061 How many zeros and how many digits?】
Given a decimal integer number you will have to find out how many trailing zeros will be there in its factorial in a given number system and also you will have to find how many digits will its factorial have in a given number system? You can assume that forView Codea b based number system there are b different symbols to denote values ranging from 0 . . . b − 1. Input There will be several lines of input. Each line makes a block. Each line will contain a decimal number N (a 20bit unsigned number) and a decimal number B (1 < B ≤ 800), which is the baseof the number system you have to consider. As for example 5! = 120 (in decimal) but it is 78 in hexadecimal number system. So in Hexadecimal 5! has no trailing zeros. Output For each line of input output in a single line how many trailing zeros will the factorial of that number have in the given number system and also how many digits will the factorial of that number have inthat given number system. Separate these two numbers with a single space. You can be sure that the number of trailing zeros or the number of digits will not be greater than 231 − 1. Sample Input 2 10 5 16 5 10 Sample Output 0 1 0 2 1 3
n! 在k進制下後綴0的個數。【洛谷 一道中檔題】
輸入輸出格式 輸入格式: 每組輸入僅包含一行:兩個整數n,k。 輸出格式: 輸出一個整數:n!在k進制下後綴0的個數。 輸入輸出樣例 輸入樣例#1: 10 40 輸出樣例#1: 2 說明 對於20%的數據,n <= 1000000, k = 10 對於另外20%的數據,n <= 20, k <= 36 對於100%的數據,n <= 10^12,k <= 10^12
給出一個k進制的數n,求n!裏一共有多少個0。【ZOJ Factorial Problem in Base K】
How many zeros are there in the end of s! if both s and s! are written in base k which is not necessarily to be 10? For general base, the digit order is 0-9,A-Z,a-z(increasingly), for example F4 in base 46 is actually 694 in base 10,and f4 in base 46 is 1890 in base 10. Input There are multiple cases(less than 10000). Each case is a line containing two integers s and k(0 ≤ s < 2^63, 2 ≤ k ≤ 62). Output For each case, output a single line containing exactly one integer in base 10 indicating the number of zeros in the end of s!. Sample Input 101 2 12 7 Sample Output 3 1
n!在k進制下的後綴0