Skip to content

Instantly share code, notes, and snippets.

@slayerjain
Created September 18, 2015 18:13
Show Gist options
  • Save slayerjain/0e6f1119093efe707bea to your computer and use it in GitHub Desktop.
Save slayerjain/0e6f1119093efe707bea to your computer and use it in GitHub Desktop.
#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