@burada
If you're brand new to programming, and don't understand the question, then why on earth are you trying to tackle competitive programming challenges?
n=int(raw_input) -1 n=n-1 //rolled into above.
y=n%26
z=n//26
if(y<2): //better comparison
print(2**z, 0, 0)
elif(y<10): //y already checked against 2 in the previous if, and comparisons cost
print(0, 2**z, 0) //do you need a lookup table of powers of 2 for these?
else:
print(0, 0, 2**z)
What are these competitive programming challenges anyway?
Are you supposed to show the extent of your knowledge in there? If you demonstrate that you know nothing, that is also a success (in showing what you actually know).
Lets say that I would participate. To win, of course. It would then be in my interest to sabotage every rival by offering "help", wouldn't it?
to jab1jaby, iamdad6, shinok1, maxdaen, Dum:
create your own damn thread and provide all the info there (like, for example, the problem statement)
@op: read the limits of your problem
1≤N≤10^5
0≤M≤10^18
you decided to traverse M doing N operations each time, so 1e23 in total, that's too much
you need to change your approach to have 10e6 at most, so perhaps O(n lg n)
¿how the hell I'm supposed to guess that its name?
for binary search
say that the answer is x, now simply verify if you can reach x
so traverse the array giving balloons to make sure that the cost does not exceed x in all the days. If you don't run out of ballons then it was possible and you may decrease `x', else you need to increase it
1 2 3 4 5 6 7 8
low = 0
high = M
while low < high:
answer = floor( (low+high)/2 )
if posible(demand, cost, balloons, answer):
low = answer
else:
high = answer
the order then would be O(N lg M) which is quite good
> what should i take 'x' as initially?
suppose that you give no balloons at all, that would be the maximum possible cost, the upper limit.
may start at limit/2
by the way, the pseudocode fails in corner cases, fix that first.
If this is a Codechef problem, you should know that the Codechef adjudicators are aware of this forum, and that people use it to cheat on their contests. If you use this forum to try and cheat, you run the risk of being disqualified.