Created
September 12, 2012 13:29
-
-
Save yoshiokatsuneo/3706596 to your computer and use it in GitHub Desktop.
daily-coding-52 for http://daily-coding.herokuapp.com/problems/52
This file contains 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 <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <vector> | |
#include <string> | |
#include <sstream> | |
using namespace std; | |
int main(void) | |
{ | |
long long i = 1; | |
while(true){ | |
bool b_ok = true; | |
int digits[10]; memset(digits, 0, sizeof(digits)); | |
int tmp_i = i; | |
while(tmp_i){ | |
digits[tmp_i%10] = 1; | |
tmp_i /= 10; | |
} | |
vector<int> v{2,3,4,5,6}; | |
for(int multi : v){ | |
long long i_multi = multi * i; | |
int multi_digits[10]; memset(multi_digits, 0, sizeof(multi_digits)); | |
int i_multi_tmp = i_multi; | |
while(i_multi_tmp){ | |
multi_digits[i_multi_tmp%10] = 1; | |
i_multi_tmp /= 10; | |
} | |
int j; | |
for(j=0;j<10;j++){ | |
if(digits[j] != multi_digits[j]){ | |
break; | |
} | |
} | |
if(j!=10){ | |
b_ok = false; | |
break; | |
} | |
} | |
if(b_ok){ | |
printf("%lld\n", i); | |
break; | |
} | |
i++; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment