URI ONLINE JUDGE SOLUTION 1308 - Online Judge

Latest

This is an Online Judge Solution Base Site. We can discuss & Solve any contest solution in Programming.

Friday, April 10, 2020

URI ONLINE JUDGE SOLUTION 1308

Problem Number: 1308
Problem Name: Etruscan Warriors Never Play Chess
Author’s Name: Ginés García Mateos, UM Espanha
Timelimit: 1
Problem Category: AD-HOC
Problem Source: https://www.urionlinejudge.com.br/judge/en/problems/view/1308

Solution:

#include <stdio.h>
#include <math.h>

int main(){
   
    int n,i;
    long long int m;
    double delta, y;
   
    scanf("%d", &n);
   
    for(i = 0; i < n; i++){
          scanf("%lld", &m);
          delta = 1 + 8*m;
          y = (-1 + sqrt(delta))/2;
          printf("%lldn", (long long int)y);
    }
   
    return 0;
}

No comments:

Post a Comment

Thanks..