进制位数

来源:互联网 发布:人种与长相 知乎 编辑:程序博客网 时间:2024/06/05 02:36

HDU2097 - Sky数


http://acm.hdu.edu.cn/showproblem.php?pid=2097


#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <string>#include <algorithm>#include <cmath>#include <queue>#include <stack>#include <vector>#include <set>using namespace std;const int inf=0x3f3f3f3f;int a;vector <int>point;int sky(int x,int y){    int sum = 0;    point.clear();    while (x)    {        point.push_back(x % y);        x /= y;    }    int len = point.size();    for (int i = 0;i < len;i ++)        sum += point[i];    return sum;}int main(){    while (cin >> a && a)    {        if (sky(a,10) == sky(a,12) && sky(a,10) == sky(a,16))            printf("%d is a Sky Number.\n",a);        else            printf("%d is not a Sky Number.\n",a);    }    return 0;}
0 0
原创粉丝点击