114A.md (1584B)
1 Source: https://codeforces.com/problemset/problem/114/A 2 3 A. Cifera 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 stdin 16 17 output 18 19 stdout 20 21 When Petya went to school, he got interested in large numbers and what they were called in ancient times. For instance, he learned that the Russian word "tma" (which now means "too much to be counted") used to stand for a thousand and "tma tmyschaya" (which literally means "the tma of tmas") used to stand for a million. 22 23 Petya wanted to modernize the words we use for numbers and invented a word petricium that represents number *k*. Moreover, petricium la petricium stands for number *k*2, petricium la petricium la petricium stands for *k*3 and so on. All numbers of this form are called petriciumus cifera, and the number's importance is the number of articles la in its title. 24 25 Petya's invention brought on a challenge that needed to be solved quickly: does some number *l* belong to the set petriciumus cifera? As Petya is a very busy schoolboy he needs to automate the process, he asked you to solve it. 26 27 Input 28 29 The first input line contains integer number *k*, the second line contains integer number *l* (2 ≤ *k*, *l* ≤ 231 - 1). 30 31 Output 32 33 You should print in the first line of the output "YES", if the number belongs to the set petriciumus cifera and otherwise print "NO". If the number belongs to the set, then print on the seconds line the only number — the importance of number *l*. 34 35 Examples 36 37 Input 38 39 ``` 40 5 41 25 42 ``` 43 44 Output 45 46 ``` 47 YES 48 1 49 ``` 50 51 Input 52 53 ``` 54 3 55 8 56 ``` 57 58 Output 59 60 ``` 61 NO 62 ```