|
0
pb will have junk value, but that would not contribute to answer, just that "break" will not be called. |
|
+1
In problem A Div 2, i got wrong answer because i do not see anywhere written that you cannot buy more that one unit of same sugar. I still do not see that, can someone please point out where it is mentioned in the problem A Div 2. |
|
+1
i got wrong answer because i do not see anywhere written that you cannot buy more that one unit of same sugar. I still do not see that, can someone please point out where it is mentioned in the problem A Div 2. |
|
0
Gave very bad contest but still +11. So sad.:( |
|
0
no we could not, becoz f[k]%m will always be same for a particular k, but real modulus depends on sequence of digits we have chosen. |
|
0
the thing is you do not actually know which modulus you will get when you will count upto a state like in case of 3, d[00100][3] = 1, but if say we reach a state i = 00111 we could have multiple modulo because of the sequence we took & we need this modulo at last. So make this modulus j a part of dp state itself & update it. |
|
0
j here is always modulo, & the beauty is you can always calculate next modulo after taking any other digit into account. |
|
0
yes. |
|
+1
This is the solution: say input is {15354} & m=9. The idea is dp[i][j] will contain sum of all cases for particular instance of problem. Say initially, you have counted number 3 only i.e. i = {00100} & j = {3}. Now you may go to i = {10100} (by using 1) or {01100} (by using 5) or {00110} (by using 5) or {00101} (by using 4). All these will be generated in loop-k. If you choose 1 then j = ((3)*10+1)%m i.e. ((earlier value of j)*10 + current value of j)%m, similarly we can calculate 5 or 4. Coverage of all cases is done like this: initially we set for all single digits in the given number, so i-variable will be executing for {00001, 00010, 00100, 01000, 10000} Now to reach 01110 we have following ways: 01000 --> 01100 --> 011100 & 01000 --> 00100 --> 011100 {this will be covered while using i = 01000 first & then applying above logic} 00100 --> 01100 --> 011100 & 00100 --> 00110 --> 011100{this will be covered while using i = 00100 first & then applying above logic} 00010 --> 00110 --> 011100 & 00010 --> 01010 --> 011100{this will be covered while using i = 00010 first & then applying above logic} Now if extend this logic to every case, you will see that indeed all the permutation has been covered. To sum up, with each combination we need to do OR operation with all possible Shifts of 1 so that next set of combination is generated for some specific permutations & similarly all the permutation is being generated. |
|
0
My bad..they have mentioned it in the contest post...:( |
|
0
Please somebody tell m why i am getting time limit exceeded in the following code,while i could run the exact same code on code::blocks, http://mirror.codeforces.com/contest/253/submission/2723001 |
|
+1
I have found a very easy approach for problem A. The idea is to calculate like this if a>1 && b>1 && c>1 //it means its a hexagon: so ans = ans + 2*(a+b+c)-6 (calculating the tiles on perimeter)... else //i.e. a==1 || b==1 || c==1 it means its a square now... ans = ans + (a*b*c); |