We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
int t;
scanf("%d",&t);
while (t--) {
unsigned long long int a;
scanf("%lld",&a);
long n = sqrt(2*a);
if (n*(n+1) == 2*a) printf("%ld\n",n);
else printf("-1\n");
}
return 0;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #42: Coded triangle numbers
You are viewing a single comment's thread. Return to all comments →
simple code in c:
int main() {
}