Click
Here to go back to the homepage.
Heir's Dilemma Solution:
#include <bits/stdc++.h>
using namespace std;
int main(){
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
// Number of digits in N =floor(log10(N)) + 1;
int start, end, count = 0;
cin >> start >> end;
while(start <= end){
int arr[10] = {};
int a, b, c, d, e, f;
a = start / 100000;
b = start / 10000 % 10;
c = start / 1000 % 10;
d = start / 100 % 10;
e = start / 10 % 10;
f = start % 10;
arr[a] += 1;
arr[b] += 1;
arr[c] += 1;
arr[d] += 1;
arr[e] += 1;
arr[f] += 1;
bool ok = arr[0] > 0 ? false : true;
for(size_t i = 0; i < 10; i++)
{
if (arr[i] > 1) {
ok = false;
}
}
if(ok && start % a == 0 && start % b == 0 && start % c == 0 && start % d == 0 && start % e == 0 && start % f == 0){
count++;
}
start++;
}
cout << count;
return 0;
}