听写

数位分离

while (x){ //只要x不为0
	int t = x % 10; //x的个位
	x /= 10; //去掉x的各位
}

int n;
cin>>n;
for (int i=1;i<=n;i++){
		int x;
		cin>>x;
		int res = 0; //当前数字的数位和
		while (x){
			res += x%10;
			x/=10;
		}
		if (x%7==0)
			cout<<"Yes\\n";
		else
			cout<<"No\\n";
}

判断质数

自幂数

int n;
cin>>n;
int cnt = 0; //个数
int x = n;
int f[100];
while (x){
	f[cnt++] = x%10;
	x/=10;
}
int ans = 0;
for (int i=0;i<cnt;i++){
	ans += pow(f[i],cnt);
}

枚举

#include<bits/stdc++.h>
using namespace std;

int main(){
	int l,r;
	cin>>l>>r;
	int ans = 0;
	for (int i=l;i<=r;i++){  //10^4
		for (int x=0;pow(2,x)<i;x++){ //15
			for (int y=x;pow(2,y)<i;y++){ //15
				 //ans += (pow(2,x)+pow(2,y))==i;
				 if ((pow(2,x)+pow(2,y))==i) ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

幂函数