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 main() {
int t; // Number of test cases
scanf("%d", &t);
while (t > 0) {
long int k;
scanf("%ld", &k);
if(k%2==0)
{
long int i = k / 2 ; // Divide by 2 and store as double
// Convert to integer by truncating decimal part
long int j = k - i; // Remaining cuts for the other dimension
// Calculate maximum pieces as a product of integers
long int maxPieces = i * j;
printf("%ld\n", maxPieces); // Print result as integer
}
else {
long double i = ( long double)k / 2 + 0.5; // Divide by 2 and store as double
// Convert to integer by truncating decimal part
long double j = k - i; // Remaining cuts for the other dimension
// Calculate maximum pieces as a product of integers
long int maxPieces = i * j;
printf("%ld\n", maxPieces); // Print result as integer}
}
t--;
}
return 0;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Halloween party
You are viewing a single comment's thread. Return to all comments →
include
include
include
include
include
include
include
include
include
include
char* readline(); char* ltrim(char*); char* rtrim(char*);
int main() { int t; // Number of test cases scanf("%d", &t);
}