ACdream1062



面面數

Time Limit: 4000/2000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)

Problem Description

DS 看見過這麼一個題目: 

求在三維世界中,經過一個公共點的 n 個平面(但任意三個平面不過同一直線)把空間分成的塊數

DS發現整個平面被分成了 部分(N ≤ 2000000000),那麼最少需要用多少個平面呢?

致歉:

請 if (n == 0) cout << 1 << endl; .... Sorry

Input

第一行一個整數代表數據的組數 T (T ≤ 10000)

每組數據一個整數 N (1 ≤ N ≤ 2000000000)

Output

對於每組數據輸出一個整數

Sample Input

5
1
2
3
4
100

Sample Output

0
1
2
2
11
<span style="white-space:pre">		</span><span style="font-size:24px;color:#ff0000;">作爲結論:記下來!</span>

#include<iostream>
using namespace std;
long long a[60000];
int main()
{

    a[0]=1;a[1]=2;a[2]=4;a[3]=8;a[4]=14;
    for(int i=5;i<60000;i++)
    {
        a[i]=a[i-1]+2*(i-1);
    }
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        if(n==0)
        {
            cout<<"1"<<endl;
            continue;
        }
        for(int i=0;i<60000;i++)
        {
            if(a[i]>=n)
            {
                cout<<i<<endl;
                break;
            }
        }
    }
}




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章