-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBai158_SoDep2.cpp
More file actions
46 lines (35 loc) · 803 Bytes
/
Bai158_SoDep2.cpp
File metadata and controls
46 lines (35 loc) · 803 Bytes
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
#include<iostream>
using namespace std;
bool soThuanNghich(long long int n) {
int tong = 0;
long long int kq = n, so = 0;
while (n > 0) {
so = so * 10 + n % 10;
tong += n % 10;
n /= 10;
}
if (so != kq || tong % 10 != 0)
return false;
return true;
}
int main() {
int soBoTest;
int dem;
int batDau, ketThuc;
long long int n;
cin >> soBoTest;
for (int k = 0; k < soBoTest; k++) {
dem = 0;
batDau = 1;
ketThuc = 1;
cin >> n;
for (int i = 0; i < n - 1; i++)
batDau = batDau * 10;
ketThuc = batDau * 10;
for (int i = batDau; i < ketThuc; i++)
if (soThuanNghich(i))
dem++;
cout << dem << endl;
}
return 0;
}