题目链接:QAQ
题意:求出1到n满足题目要求的偶数的个数
思路:连个最基本的等比数列求和公式都没看出来(瞎了)。看出来后就很简单啦
附上代码:
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int main(void) {
int t;
scanf("%d", &t);
int ca = 1;
while (t--) {
long long n;
scanf("%lld", &n);
printf("Case %d: ", ca++);
long long tot = n;
tot -= (long long)sqrt(n);
tot -= (long long)sqrt((double)n / 2);
printf("%lld\n", tot);
}
return 0;
}