-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathordinaryinumber.cpp
77 lines (76 loc) · 1.74 KB
/
ordinaryinumber.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <iostream>
#include<algorithm>
#include<conio.h>
#include<string>
using namespace std;
int main()
{
int count=0;
int eleven=0;
int t,n;
cin>>t;
for(int i=0;i<t;i++)
{
cin>>n;
for(int j=1;j<=n;j++)
{
if(j>=1&&j<=9)
count++;
else if(j>=10&&j<100){
eleven=11;
if(j%eleven==0)
count++;
}
else if(j>=100&&j<1000)
{
eleven=111;
if(j%eleven==0)
count++;
}
else if(j>=1000&&j<10000)
{
eleven=1111;
if(j%eleven==0)
count++;
}
else if(j>=10000&&j<100000)
{
eleven=11111;
if(j%eleven==0)
count++;
}
else if(j>=100000&&j<1000000)
{
eleven=111111;
if(j%eleven==0)
count++;
}
else if(j>=1000000&&j<10000000)
{
eleven=1111111;
if(j%eleven==0)
count++;
}
else if(j>=10000000&&j<100000000)
{
eleven=11111111;
if(j%eleven==0)
count++;
}
else if(j>=100000000&&j<1000000000)
{
eleven=111111111;
if(j%eleven==0)
count++;
}
else if(j>=100000000&&j<100000000000)
{
eleven=1111111111;
if(j%eleven==0)
count++;
}
}
cout<<count<<endl;
count=0;
}
}