Showing posts with label Triangular Number. Show all posts
Showing posts with label Triangular Number. Show all posts

Tuesday, November 22, 2011

[UVa] 11614 - Etruscan Warriors Never Play Chess

#include <set>
#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    long long n, lim, x1, x2;

    int tst;
    cin >> tst;

    while (tst--)
    {

        cin >> n;
        lim = (int)(ceil(sqrt(double(n*2))));

        x1 = lim * (lim+1) / 2;
        x2 = (lim-1)*lim/2;



        if (x1 <= n)
        {
            cout << lim << endl;
        } else if (x2<=n)
        {
            cout << lim-1 << endl;
        } else
        {
            cout << lim-2 << endl;
        }

    }
    return 0;
}

Connect Rapoo MT750S with Linux (Tested on Manjaro)

 I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...