Date: 2011-12-27 22:15:43
Fault is here:
'a' can be as large as 10^17 int data type gets overflow here. Just replace it with unsigned long long.
You are doing next_permutation() over the number of digits of n. But number of digits may be 18. Shouldn't (18!) get time limit exceeded?
But I got AC with your code! How is it possible in 0.5 seconds?
| 22.10.12 - The problems from the Southern Subregional Programming Contest 2012 added to the problemset archive (542 - 553). |
22.10.12 - After the start of the contest the statements in PDF will be available by the link.
23.10.11 - The problems from the Southern Subregional Programming Contest 2011 added to the problemset archive (530 - 541).