一的个数

 1 #include <iostream>
 2 #include <algorithm>
 3 #include <cmath>
 4 using namespace std;
 5 
 6 typedef long long LL;
 7 
 8 int main(){
 9 
10     LL a, b;
11     while (cin >> a >> b){
12         int t;
13         int ans = 0;
14         while (a){
15             int t = a%b;
16             if (t == 1){
17                 ans++;
18             }
19             a = a/b;
20         }
21         cout << ans << endl;
22     }
23 
24     return 0;
25 }

 

posted @ 2018-03-05 20:15  ouyang_wsgwz  阅读(146)  评论(0编辑  收藏  举报