A - Kth Term
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include <bits/stdc++.h> #define ll long long using namespace std; int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}; int main() { //freopen("in.txt","r",stdin); int n; scanf("%d",&n); printf("%d ",a[n-1]); return 0; }
B - Bishop
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include <bits/stdc++.h> #define ll long long using namespace std; int main() { //freopen("in.txt","r",stdin); ll n,m; scanf("%lld%lld",&n,&m); if(n==1||m==1) printf("1 "); else printf("%lld ",((n+1)/2)*((m+1)/2)+(n/2)*(m/2)); return 0; }
C - Sqrt Inequality
题意:给三个正整数a,b,c,判断$sqrt{a}+sqrt{b}<sqrt{c}$是否成立。
数据范围:$1leq a,b,c leq 10^{9}$
题解:$sqrt{a}+sqrt{b}<sqrt{c}Rightarrow a+b+sqrt{4 imes a imes b} <cRightarrow sqrt{4 imes a imes b}<=c-a-b$,若$c-a-bgeq 0$,再将两边同时平方即可。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include <bits/stdc++.h> #define ll long long using namespace std; int main() { //freopen("in.txt","r",stdin); ll a,b,c; scanf("%lld%lld%lld",&a,&b,&c); if(a+b>=c) printf("No "); else { c=c-a-b; if(4*a*b>=c*c) printf("No "); else printf("Yes "); } return 0; }
D - String Equivalence
题意:按字典序输出长度为N且只含有小写字母的字符串,满足当前输出的字符串与之前输出的字符串不同构。
数据范围:$1leq N leq 10$
题解:每一次往后面添一个字母,且该字母不能比之前的最大字母大2。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include <bits/stdc++.h> #define ll long long using namespace std; char s[105]; int n; void dfs(int pos,int x,int up) { s[pos]=x+'a'; if(pos==n-1) { printf("%s ",s); return; } for(int i=0;i<=up+1;i++) { dfs(pos+1,i,max(up,i)); } } int main() { //freopen("in.txt","r",stdin); scanf("%d",&n),s[n]='