-
Notifications
You must be signed in to change notification settings - Fork 0
/
ecnuoj3187.cpp
76 lines (76 loc) · 1.3 KB
/
ecnuoj3187.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
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<int> getdigit(int n)
{
vector<int> v;
while(n>0)
{
v.push_back(n%10);
n=n/10;
}
return v;
}
bool iscon(int n)
{
vector<int> mv;
vector<int> v= getdigit(n);
for (size_t i = 0; i < v.size()-1; i++)
{
int j = i+1;
mv.push_back(v[j]-v[i]);
}
int i=0;
int con=0;
while (i<mv.size())
{
if(v[i]<0&&con==0)
{
i++;
}
if(v[i]>0&&con==0)
{
i++;
con=1;
}
if(v[i]<0&&con==1)
{
return false;
}
if(v[i]>0&&con==1)
{
i++;
}
}
if(i==mv.size()&&con==1)
{
return true;
}
return false;
}
int main()
{
int N=0;
scanf("%d",&N);
int countN=0;
while (N>0)
{
int a=0;
int b=0;
int countT=0;
scanf("%d %d",&a,&b);
for (size_t i = a; i < b+1; i++)
{
if(iscon(i))
{
countT++;
}
}
cout<<"case #"<<countN<<":"<<endl;
cout<<countT<<endl;
N--;
countN++;
}
return 0;
}