-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdifferentDigits.cpp
53 lines (48 loc) · 1.04 KB
/
differentDigits.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
ifstream fin("differentDigits.in");
ofstream fout("differentDigits.out");
int main()
{
vector<int> store(5001);
store[0] = 0;
for (int i = 1; i <= 5000; ++i)
{
vector<bool> dp(10, false);
string now = to_string(i);
int size = now.size();
bool is = true;
for (int j = 0; j <= size - 1; ++j)
{
if (dp[now[j] - '0'] == true)
{
is = false;
break;
}
else
{
dp[now[j] - '0'] = true;
}
}
store[i] = store[i - 1] + is;
}
while (true)
{
int n = 0, m;
fin >> n >> m;
if (n == 0)
{
break;
}
fout << store[m] - store[n - 1] << '\n';
}
}