2041 超级楼梯
#include <cstdio>
int method(int m) {
if (m == 2) return 1;
if (m == 3) return 2;
return method(m - 1) + method(m - 2);
}
int main() {
int n, m;
scanf("%d", &n);
while (n--) {
scanf("%d", &m);
printf("%d\n", method(m));
}
return 0;
}
2043 密码
#include <cstdio>
#include <string>
#include <iostream>
#include <cctype>
using namespace std;
int main() {
int n;
scanf("%d", &n);
string s;
while (cin >> s) {
if (s.size() > 16 || s.size() < 8) {
printf("NO\n"); continue;
}
bool judge[4] = {0};
for (int i = 0; i < s.size(); i++) {
if (isupper(s[i])) judge[0] = 1;
if (islower(s[i])) judge[1] = 1;
if (isdigit(s[i])) judge[2] = 1;
if (s[i] == '~' || s[i] == '!' || s[i] == '@' || s[i] == '#' ||
s[i] == '$' || s[i] == '%' || s[i] == '^') judge[3] = 1;
}
int type = 0;
for (int i = 0; i < 4; i++)
if (judge[i] == 1) type++;
if (type >= 3) printf("YES\n");
else printf("NO\n");
}
return 0;
}