Skip to content

Commit

Permalink
multof2019
Browse files Browse the repository at this point in the history
  • Loading branch information
megargayu committed Oct 15, 2022
1 parent 368e4d4 commit 9b6e70d
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
37 changes: 37 additions & 0 deletions google/roundC2020/countdown/countdown.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// https://codingcompetitions.withgoogle.com/kickstart/round/000000000019ff43/00000000003380d2

#include <bits/stdc++.h>
using namespace std;

int main()
{
int T;
cin >> T;

int N, K, a;
int seenSoFar, ans;
for (int t = 1; t <= T; ++t)
{
cin >> N >> K;

seenSoFar = 0, ans = 0;
for (int i = 0; i < N; ++i)
{
cin >> a;
if (seenSoFar == K)
{
++ans;
seenSoFar = 0;
}

if (a == K - seenSoFar)
++seenSoFar;
else
seenSoFar = a == K;
}

cout << "Case #" << t << ": " << ans + (seenSoFar == K) << '\n';
}

return 0;
}
25 changes: 25 additions & 0 deletions google/roundC2020/countdown/tmp.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
1 3 9 8 2

x2 x4 x6
1 9 2
3 8



1 10 12
2 38 50

50 - 2 = 48 - 2 * (12 - 1) = 26

-9 x 2 + -2 x 4 = 26











0 comments on commit 9b6e70d

Please sign in to comment.