/*
Time:2019.11.7
Author: Goven
type:完全平方数
err:
ref:题目理解: https://www.cnblogs.com/platalcigarette/archive/2012/08/02/2620138.html
代码:https://blog.csdn.net/weixin_43216252/article/details/90114832
题目:a = x1 * x2当round为x1,x2时,开关会抵消(保持原状态),只有 a = x1 * x1时,最终才可以改变状态
所以题目等价为求解a以内的完全平方数
*/
//暴力 O(n*n)
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
int a[105];
memset(a, 0, sizeof(a));// 用bool a[105]也可,赋值的时候就用 a[j] = !a[j]
for (int i = 2; i < 101; i++) {
for (int j = i; j < 101; j += i) {
a[j]++;
}
}
for (int i = 1; i < 101; i++) {
if (a[i] % 2 == 0) a[i] = a[i - 1] + 1;
else a[i] = a[i - 1];
}
int t, n;
cin >> t;
while (t--) {
cin >> n;
cout << a[n] << endl;
}
return 0;
}
//完全平方数
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int t, n;
cin >> t;
while (t--) {
cin >> n;
cout << (int)sqrt((double)n) << endl;
}
return 0;
}
网友评论