From 3a96e4f7d33110911667525174bb04b0c699b724 Mon Sep 17 00:00:00 2001 From: Skullheadx <94652084+Skullheadx@users.noreply.github.com> Date: Sat, 24 Sep 2022 22:27:29 -0400 Subject: [PATCH] S3 WIP --- .gitignore | 1 + .idea/CCC.iml | 1 + Main/Python/2022/S3.py | 59 ++++++++++++++++++++++++++++++++++++++++++ Main/Python/S3.py | 27 ------------------- 4 files changed, 61 insertions(+), 27 deletions(-) create mode 100644 Main/Python/2022/S3.py delete mode 100644 Main/Python/S3.py diff --git a/.gitignore b/.gitignore index d9b0101..12e39a0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.xml *.iml +*.iml diff --git a/.idea/CCC.iml b/.idea/CCC.iml index 82cb658..4954722 100644 --- a/.idea/CCC.iml +++ b/.idea/CCC.iml @@ -3,6 +3,7 @@ + diff --git a/Main/Python/2022/S3.py b/Main/Python/2022/S3.py new file mode 100644 index 0000000..60549ed --- /dev/null +++ b/Main/Python/2022/S3.py @@ -0,0 +1,59 @@ +# WIP +n, m, k = tuple(map(int, input().split())) + +# N number of notes +# M highest note +# K number good samples + +# best piece +# 1, 2, 1, 2, 1, 2 + +# MAX length of good sample = M +# number of good samples in pattern core = m*(m+1)/2 +output = -1 +for M in range(1, 1+m): + # num_good = (m * (m+1) /2) * n//m + (n%m * (n%m+1)/2) + num_good = n * (n + 1) / 2 - (n - M) * (n - M + 1) / 2 + # print(M, num_good, end= ' | ') + # for i in range(n): + # print((i % M) + 1, end=" ") + # print() + if num_good == k: + output = M + # break + +if output > 0: + for i in range(n): + print(m-((i % output) + 1) + 1, end=" ") +else: + print(output) + +# n = 5, m = 4 +# 1 2 3 4 1 + +# 1, 2, 3, 4, 1,(5) +# 1 2, 2 3, 3 4, 4 1, (4) +# 1 2 3, 2 3 4, 3 4 1, (3) +# 1 2 3 4, 2 3 4 1 (2) +# total = 5+4+3+2 = 14 + +# input : n=6, m=4 +# 1 2 3 4 1 2 +# 1, 2, 3, 4 ,1, 2 (6) +# 1 2, 2 3, 3 4, 5 1, 1 2 (5) +# 1 2 3, 2 3 4, 3 4 1, 4 1 2 (4) +# 1 2 3 4, 2 3 4 1, 3 4 1 2 (3) +# good samples = 6(6+1)/2 - (6-4)(6-4+1)/2 = 21-3 = 18 + +# n = 10, m = 2 +# 1 2 1 2 1 2 1 2 1 2 +# 1 2 1 2 1 2 1 2 1 2 (10) +# 12 21 12 21 12 21 12 21 12 (9) +#good samples = 10 + 9= 19 +# 10(11)/2 - (10-2)(10-2+1)/2 = 55 - 36 = 19 + +# n = 11, m = 2 +# 1 2 1 2 1 2 1 2 1 2 1 +# 1 2 1 2 1 2 1 2 1 2 1 (11) +# 12 21 12 21 12 21 12 21 12 21 (10) +# total = 11 + 10 = 21 \ No newline at end of file diff --git a/Main/Python/S3.py b/Main/Python/S3.py deleted file mode 100644 index 06e3fbe..0000000 --- a/Main/Python/S3.py +++ /dev/null @@ -1,27 +0,0 @@ -n,M,k = tuple(map(int, input().split())) - -# N number of notes -# M highest note -# K number good samples - -# best piece -# 1, 2, 1, 2, 1, 2 - -# MAX length of good sample = M -# number of good samples in pattern core = m*(m+1)/2 -output = -1 -for m in range(1,1+M): - # num_good = (m * (m+1) /2) * n//m + (n%m * (n%m+1)/2) - print(m, num_good) - if num_good == k: - output = m - break - -print(output) - -# input = 5 5 14 -# 1 2 3 4 1 -# 1, 2, 3, 4, 1,(5) -# 1 2, 2 3, 3 4, 4 1, (4) -# 1 2 3, 2 3 4, 3 4 1, (3) -# 1 2 3 4, 2 3 4 1 (2) -- 2.54.0