ciuemvoiQuan-sensei
user_1746670
c_cpp
2 years ago
1.4 kB
18
Indexable
#include <bits/stdc++.h>
#define ll long long
#define LIM 105
#define X first
#define Y second
#define EL cout<<"\n"
using namespace std;
int Ticket(int n) {
int n1, n2;
if (n >= 1000) {
n1 = n % 100;
n2 = n / 100;
}
else if (n >= 100) {
n1 = n % 10;
n2 = n / 10;
}
else if (n >= 10) {
n1 = n % 10;
n2 = n / 10;
}
else {
return 0;
}
int res = 0;
// if (n < 1000 && n >= 100) {
// if (n1 % 10 == 0) {
// int _n = n / 100;
// int __n = n % 100;
// for (int i = 1; i <= 9; i++) {
// if (_n - i < 10 && _n - i > 0) {
// res += i; res *= 10;
// res += (_n - i); res *= 10;
// for (int j = 0; j <= 9; j++) {
// if (__n - j < 10 && __n - j > 0) {
// res += j; res *= 10;
// res += (__n - j);
// break;
// }
// }
// break;
// }
// }
// return res;
// }
// }
if (n1 >= 19 || n2 >= 19) {
return 0;
}
for (int i = 1; i <= 9; i++) {
if (n1 - i < 10 && n1 - i > 0) {
res += i; res *= 10;
res += (n1 - i); res *= 10;
for (int j = 0; j <= 9; j++) {
if (n2 - j < 10 && n2 - j > 0) {
res += j; res *= 10;
res += (n2 - j);
break;
}
}
break;
}
}
return res;
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n; cin >> n;
cout << Ticket(n) << endl;
return 0;
}Editor is loading...
Leave a Comment