[HDU] [2097] Sky Number

Problem Description

Loading...

Problem Analysis

At the time it felt like a problem that deserved its own separate solution.
I remember agonizing for ages over how hexadecimal numbers should be represented…
Only later did I realize I was overthinking it -.-.

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#include<stdio.h>
int main() {
	int n,i,a,b,c;
	while(scanf("%d",&n),n!=0) {
		a=n%10+n/10%10+n/100%10+n/1000;
		for(i=n,b=0; i!=0; i=i/12)
			b=b+i%12;
		for(i=n,c=0; i!=0; i=i/16)
			c=c+i%16;
		if(a==b&&a==c)
			printf("%d is a Sky Number.\n",n);
		else
			printf("%d is not a Sky Number.\n",n);
	}
	return 0;
}
This post is licensed under CC BY-NC-SA 4.0. If it helped, or if you have anything to say, the comment box below is open.
Page views —
Unique visitors —

Loading...