Last active
August 23, 2020 12:15
-
-
Save chaidhat/3a4a95a208afec0ecc244ef7b344ddb5 to your computer and use it in GitHub Desktop.
Kick Start round C 17/05/2020
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17-MAY-2020 | |
Chaidhat Chaimongkol | |
Stuti Shah | |
45th percentile | |
6270/13650 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = [30000] | |
T = int(input()) | |
for i in range(T): | |
N, K = input().split() | |
N = int(N) | |
K = int(K) | |
test = K | |
c = 0 | |
num = input().split() | |
for n in num: | |
n = int(n) | |
if n == test: | |
test = test - 1 | |
else: | |
test = K | |
if n == K: | |
test = K - 1 | |
if test == 0: | |
c = c + 1 | |
test = K | |
print("case #" + str(i + 1) + ": " + str(c)) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# TLE | |
squares = [1000] * 100 | |
for i in range(100): | |
squares[i] = i*i | |
T = int (input()) | |
for i in range(T): | |
N = int(input()) | |
num = input().split() | |
c = 0 | |
for n in range(N): | |
sum = 0 | |
for j in range(n,N): | |
sum = sum + int(num[int(j)]) | |
k = 0 | |
while sum > squares[k]: | |
k = k + 1 | |
if sum == squares[k]: | |
c = c + 1 | |
print("case #" + str(i + 1) + ": " + str(c)) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include <sstream> | |
using namespace std; | |
int main () | |
{ | |
long long int squares[100]; | |
for (int i = 0; i < 100; i++) | |
{ | |
squares[i] = i*i; | |
} | |
int T; | |
cin >> T; | |
for (int i = 0; i < T; i++) | |
{ | |
int N; | |
cin >> N; | |
int num[N]; | |
for (int n = 0; n < N; n++) | |
{ | |
cin >> num[n]; | |
} | |
int c = 0; | |
for (int n = 0; n < N; n++) | |
{ | |
int sum = 0; | |
for (int j = n; j < N; j++) | |
{ | |
sum += num[j]; | |
int k = 0; | |
while (sum > squares[k]) | |
k++; | |
if (sum == squares[k]) | |
c++; | |
} | |
} | |
cout << "case #" << (i + 1) << ": " << c << "\n"; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment