Skip to content

Instantly share code, notes, and snippets.

@kazoo04
Created July 25, 2014 09:12
Show Gist options
  • Save kazoo04/47a8f6b5d9c39759a032 to your computer and use it in GitHub Desktop.
Save kazoo04/47a8f6b5d9c39759a032 to your computer and use it in GitHub Desktop.
#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;
}
@kazoo04
Copy link
Author

kazoo04 commented Jul 25, 2014

オーバーフローとかは知らない

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment