Luogu number P1062 columns
Topic said:
All \ (K \) of a power of a finite number and all equal to each other in the \ (K \) of the square of powers constituting an ascending sequence.
This means that every \ (k \) a power of only or not.
Promising \ (0 \) , not to \ (1 \) .
So these numbers in binary like this:
\ (1,10,11,100,101,110,111,1000 \ cdots \)
So, the first \ (n \) items in decimal is \ (n \) .
#include<bits/stdc++.h>
using namespace std;
int k,n,len;
int num[1010];
long long ans;
int main()
{
scanf("%d%d",&k,&n);
while(n) {
num[++len]=n%2;
n/=2;
}
for(int i=len;i>=1;i--) {
ans+=pow(k,i-1)*num[i];
}
printf("%lld",ans);
return 0;
}