返回小组 开始 2025-04-19 13:00:00

测试

结束 2025-04-20 13:00:00
Contest is over.
当前 2025-05-15 00:13:49

一遍过

include <bits/stdc++.h>

using namespace std; typedef long long ll;

int qwert(ll a) {

int s = 0;
while (a) {
	s += a % 10;
	a /= 10;
}
return s;

}

bool p(int a) {

if (a == 1)
	return false;
for (int c = 2; c <= sqrt(a); c++)
	if (a % c == 0)
		return false;
return true;

}

int main() {

freopen("count.in", "r", stdin);
freopen("count.out", "w", stdout);
ll s, f;
cin >> s >> f;
int m = 0;
for (ll c = sqrt(s); c <= sqrt(f); c++) {
	ll a = c * c;
	if (a <= s)
		continue;
	if (a >= f)
		break;
	if (p(qwert(a)))
		m++;
}
cout << m;
return 0;

}


McQueen  •  25天前

比赛已结束。