Created
September 18, 2015 18:13
-
-
Save slayerjain/0e6f1119093efe707bea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() { | |
int t = 0; | |
scanf("%d", &t); | |
for (int k = 0; k < t; k++) { | |
long amount_of_water = 0; | |
long buckets_filled = 0; | |
scanf("%ld", &amount_of_water); | |
int i = 0; | |
bool b = true; | |
while (b) { | |
buckets_filled = (i*(2*i +1)*(i+1))/2; | |
b = false; | |
if (buckets_filled + (i+1)*(i+1) <= amount_of_water ) { | |
i++; | |
b = true; | |
} | |
} | |
printf("%d\n", i); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment