那我们就
while(tmp<l) { tmp*=k; cnt++; }
这样一下~ 然后cnt就能说明一切啦~ 啊需要注意的是,超过范围但是发现不是某次幂要记得判断哦~
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
// http://codeforces.com/contest/114
// Cifera
int main()
{
int cnt=0;
ll k,tmp,l; cin>>k>>l; tmp=k;
while(tmp<l)
{
tmp*=k;
cnt++;
}
if(tmp==l)cout<<"YES"<<endl<<cnt;
else cout<<"NO";
return 0;
}