CF114A.Cifera
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
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.
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.
当佩佳去上学时,他对大数字以及它们在古代的叫法产生了兴趣。例如,他了解到俄语单词“тма”(如今意为“多得数不清”)在古代表示一千,而“тма тмыщая”(字面意思是“тма 的 тма”)则表示一百万。
佩佳想对数字的命名方式进行现代化改造,并发明了一个新词 petricium,它代表数字 k。此外,“petricium la petricium” 表示数字 k2,“petricium la petricium la petricium” 表示 k3,依此类推。所有这类形式的数字统称为 petriciumus cifera,而一个数字的“重要性”即为其名称中出现的 la 的个数。
佩佳的这项发明引发了一个亟需快速解决的挑战:某个给定的数字 l 是否属于集合 petriciumus cifera?由于佩佳是一名非常忙碌的中学生,他需要将该过程自动化,因此请你来帮他解决这个问题。
输入格式
The first input line contains integer number k, the second line contains integer number l (2 ≤ k, l ≤ 231 - 1).
第一行输入为整数 k,第二行输入为整数 l(2 ≤ k,l ≤ 231 − 1)。
输出格式
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.
如果该数属于集合 petriciumus cifera,则在输出的第一行打印 “YES”,否则打印 “NO”。如果该数属于该集合,则在第二行打印唯一的数字——即数 l 的重要性。
输入输出样例
输入#1
5 25
输出#1
YES 1
输入#2
3 8
输出#2
NO
输入解题思路,AI测评打分。不知道怎么写?