Given a positive integer n, you need to find out the minimum integer k such that for any subset T of the set {1,2,⋯,n} of size k, there exist two different integers u,v in T,u,v∈T ,that u is a factor of v.
Input
The first line contains an integer T(1≤T≤10^5) indicating the number of test cases.
Each of the following T lines contains an integer n (2≤n≤10^9) describing a test case.
Output
For each test case, output a line containing an integer which indicates the answer.
Sample Input
4 2 3 4 5
Sample Output
2 3 3 4
题意解析:
给定一个数n,然后在{1,2,3,....,n}中找出最小的子集,这个子集内需要有数u和v,然后满足u是v的因子,输出这个子集的大小
是任意长度为K的子集都存在两个数u,v,满足u是v的因子。
例如1 . 2. 3, 如果是2的话,那么2,3就不符合, 所以得是3.
要在k里能找到两个互为2倍数关系的,或者也可以直接列举出前几个的结果,可以得到一个通项 (n+1)/2+1,是个水题。
AC代码:
#include<iostream>
using namespace std;
int main() {
int t;
cin>>t;
while(t--) {
int n;
cin>>n;
cout<<(n+1)/2+1<<endl;
}
return 0;
}