Skip to content

Instantly share code, notes, and snippets.

@knowlet
Created April 30, 2014 13:10
Show Gist options
  • Save knowlet/fed8f1ba8150fd22262c to your computer and use it in GitHub Desktop.
Save knowlet/fed8f1ba8150fd22262c to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
const char *wtfPerfectNum[] = {"6", "28", "496", "8128", "33550336", "8589869056", "13743869132"};
int isPerfect(char* num)
{
int i = 7;
while (i--) if (!strcmp(num, wtfPerfectNum[i])) return 1;
return 0;
}
int main(int argc, char *argv[]) {
int n;
char p[17];
scanf("%d", &n);
while (n--) {
scanf("%s", p);
puts(isPerfect(p) ? "perfect" : "nonperfect");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment