OJ-Problems-Source/HDOJ/CCPC Pre Online Contest 2017/1005_Richard.cpp

54 lines
924 B
C++
Raw Normal View History

//#include "stdafx.h"
#include <cstdio>
#include <string>
#include <cmath>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define LL long long
LL t[1000010];
#define MAXN 1e9
int Count = 0;
//ֱ<><D6B1>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
int calc(int n){
return std::lower_bound(t, t + Count, n) - t;
}
int main() {
int T;
LL p = 0;
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
memset(t, 0, sizeof(t));
for (LL i = 4; i < 1000010; i++) {
if ((i % 4)==0) {
t[i] = i * i / 8;
p = t[i] - t[i - 1];
}
else if ((i & 1)==0) {
t[i] = t[i - 1] + p;
}
else {
t[i] = t[i - 1] + (i + 1) / 4 - 1;
}
Count = i;
if (t[i] > MAXN)
break;
}
cin >> T;
while (T--) {
int n;
cin >> n;
cout << calc(n) << endl;
}
}