We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Data Structures
- Queues
- Down to Zero II
- Discussions
Down to Zero II
Down to Zero II
Sort by
recency
|
236 Discussions
|
Please Login in order to post a comment
solution via relatively straightforward dynamic programming. weirdly this doesn't fit with the way the problem wants you to compute the values for each query separately - for this you'd have to maintain the value table w/o knowing its final size, which is very awkward - a lot easier to change the input parsing code so that it sends all queries at once so that they can be processed together.
include
include
include
define MAX_N 1000001
int dp[MAX_N];
void precompute_min_moves() { dp[0] = 0; dp[1] = 1;
}
int main() { precompute_min_moves();
int Q; scanf("%d", &Q);
while (Q--) { int N; scanf("%d", &N); printf("%d\n", dp[N]); }
return 0;[](https://)
def downToZero(n): if n == 0: return 0 queue = deque([(n, 0)]) visited = set([n])
include
include
include
include
include
include
include
using namespace std;
int testCase(int n) { if (n == 0) { return 0; }
}
int main() { int q; cin >> q;
}