-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSource.cpp
More file actions
58 lines (53 loc) · 978 Bytes
/
Copy pathSource.cpp
File metadata and controls
58 lines (53 loc) · 978 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
47
48
49
50
51
52
53
54
55
56
57
58
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <array>
#include <stdio.h>
#include <vector>
#include <map>
#include <cmath>
using namespace std;
int rvs(int i) {
int reverse = 0, rem;
while (i > 0)
{
rem = i % 10;
reverse = reverse * 10 + rem;
i = i / 10;
}
return reverse;
}
int UCLN(int a, int b) {
if (b == 0) return a;
return UCLN(b, a % b);
}
int main() {
int a,b,cnt,ri;
string line;
ifstream input("bl1.INP");
ofstream output("bl1.OUT");
getline(input, line);
sscanf_s(line.c_str(), "%d %d", &a, &b);
if (input.is_open())
{
cout << a << ' ' << b << endl;
cnt = 0;
for (int i = a; i <= b; i++) {
ri = rvs(i);
cout << ri << endl;
if (UCLN(i,ri) == 1) {
cnt++;
}
}
cout << cnt << endl;
if (output.is_open())
{
output<<cnt;
output.close();
}
input.close();
}
else cout<<"Unable to open file";
return 0;
}