parent
6f93d34893
commit
577697bec5
@ -1,10 +1,30 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
bool check(int x) {
|
||||
int len = to_string(x).size();
|
||||
|
||||
int sum = 0, t = x;
|
||||
while (t) {
|
||||
int a = t % 10;
|
||||
sum += pow(a, len);
|
||||
t /= 10;
|
||||
}
|
||||
|
||||
return x == sum;
|
||||
}
|
||||
|
||||
int main() {
|
||||
string a = "abcdefg";
|
||||
int T;
|
||||
cin >> T;//times
|
||||
while (T--) {
|
||||
int a;
|
||||
cin >> a;
|
||||
|
||||
cout << a.substr(1, 1) << endl; // a[1]
|
||||
cout << a.substr(1, 3) << endl; // a[1] a[2] a[3]
|
||||
cout << a.substr(0, 4) << endl;
|
||||
if (check(a))
|
||||
cout << 'T' << endl;
|
||||
else
|
||||
cout << 'F' << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
int cnt;
|
||||
bool check(int x) {
|
||||
string s = to_string(x);
|
||||
string t = s;
|
||||
reverse(t.begin(), t.end());
|
||||
|
||||
if (s != t) return false;
|
||||
bool flag = false;
|
||||
for (int i = 0; i < s.size(); i++)
|
||||
if (s[i] == '7') flag = true;
|
||||
if (!flag) return false;
|
||||
return true;
|
||||
}
|
||||
int main() {
|
||||
int a, b;
|
||||
cin >> a >> b;
|
||||
for (int i = a; i <= b; i++)
|
||||
if (check(i)) cnt++;
|
||||
cout << cnt << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in new issue