]> Skullheadx's Git Forge - CCC.git/commitdiff
S3 WIP
authorSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Sun, 25 Sep 2022 02:27:29 +0000 (22:27 -0400)
committerSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Sun, 25 Sep 2022 02:27:29 +0000 (22:27 -0400)
.gitignore
.idea/CCC.iml
Main/Python/2022/S3.py [new file with mode: 0644]
Main/Python/S3.py [deleted file]

index d9b0101cc68f1e33f5ebff290298cf9206eb7e6d..12e39a0fe986b3c7989aad74748679372e6c70f9 100644 (file)
@@ -1,3 +1,4 @@
 *.xml
 *.iml
 
+*.iml
index 82cb658f8ea53541ce1741797168b429e4a305e8..49547220dac4729f530234e019a6bb3ebcc182e3 100644 (file)
@@ -3,6 +3,7 @@
   <component name="NewModuleRootManager">
     <content url="file://$MODULE_DIR$">
       <excludeFolder url="file://$MODULE_DIR$/Main/venv" />
+      <excludeFolder url="file://$MODULE_DIR$/venv" />
     </content>
     <orderEntry type="jdk" jdkName="Python 3.10 (CCC)" jdkType="Python SDK" />
     <orderEntry type="sourceFolder" forTests="false" />
diff --git a/Main/Python/2022/S3.py b/Main/Python/2022/S3.py
new file mode 100644 (file)
index 0000000..60549ed
--- /dev/null
@@ -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 (file)
index 06e3fbe..0000000
+++ /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)