Created
July 25, 2014 09:12
-
-
Save kazoo04/47a8f6b5d9c39759a032 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <math.h> | |
int main(int argc, char **argv) { | |
int n = 1111111; | |
printf("%d", n); | |
int b = 10; | |
int buffer = n % 10; n /= 10; | |
int i = 1; | |
int is_repdigit = 1; | |
int x; | |
while(x = n % b) { | |
n /= b; | |
while(buffer > x) buffer /= 10; | |
if(x - buffer) { | |
is_repdigit = 0; | |
break; | |
} | |
buffer += x * b; | |
i *= 2; | |
b = pow(10, i); | |
} | |
printf(" is%s repdigit", is_repdigit ? "" : " not"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
オーバーフローとかは知らない