Friday, February 18, 2011

11614 - Etruscan Warriors Never Play Chess


#include<stdio.h>
#include<math.h>
#define M 4501

int main()
{
    int t;
    long long n,m;
    //freopen("in.txt","r",stdin);

    scanf("%d",&t);
    while(t--)
    {
        scanf("%lld",&n);
        m=(long long)sqrt(2*n)-1;

        while(m*(m+1)/2<=n)
            m++;

        printf("%lld\n",m-1);
    }
    return 0;
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.