Bläddra i källkod

Merge in practice data (use git subtree merge to update)

master
Yorick van Pelt 2 år sedan
förälder
incheckning
0dca41fffb
4 ändrade filer med 53 tillägg och 0 borttagningar
  1. 3
    0
      practice/A.py
  2. 6
    0
      practice/A_.py
  3. 39
    0
      practice/B.py
  4. 5
    0
      practice/C.py

+ 3
- 0
practice/A.py Visa fil

@@ -0,0 +1,3 @@
1
+import sys
2
+N = int(sys.stdin.readline())
3
+print(N**0.5*4)

+ 6
- 0
practice/A_.py Visa fil

@@ -0,0 +1,6 @@
1
+import sys
2
+N = int(sys.stdin.readline())
3
+if "PyPy" in sys.version:
4
+  print(N**0.5*4)
5
+else:
6
+  raise RuntimeError("WTF")

+ 39
- 0
practice/B.py Visa fil

@@ -0,0 +1,39 @@
1
+from __future__ import print_function
2
+import sys
3
+
4
+s, e      = map(int, sys.stdin.readline().split())
5
+es        = map(int, sys.stdin)
6
+
7
+OK        = [ [0]*(s+1) for i in xrange(e+1) ]
8
+OK[0][0]  = 1
9
+
10
+for i in xrange(e):
11
+  for j in xrange(s+1):
12
+    if OK[i][j]: OK[i+1][j] = 1
13
+    if es[i] > j: continue
14
+    if OK[i][j-es[i]]: OK[i+1][j] = 2
15
+
16
+ns = []; i, j = e, s
17
+while i > 0 and j >= 0:
18
+  x = OK[i][j]
19
+  if x == 2:
20
+    ns.append(i-1)
21
+    i -= 1
22
+    j -= es[i]
23
+  else:
24
+    i -= 1
25
+
26
+# print(ns)
27
+# import pprint; pprint.pprint(OK)
28
+
29
+print(e+1)
30
+k, l = 1, 3
31
+for n in ns[:-1]:
32
+  print(k, l, es[n])
33
+  k = l; l += 1
34
+print(k, 2, es[ns[-1]])
35
+ns = set(ns); k = 2
36
+for i,j in enumerate(es):
37
+  if i not in ns:
38
+    print(k, l, j)
39
+    k = l; l += 1

+ 5
- 0
practice/C.py Visa fil

@@ -0,0 +1,5 @@
1
+from __future__ import print_function
2
+import sys
3
+P = sys.stdin.readline().rstrip()
4
+N = 26-len(set(P))
5
+print(N if N != 0 else "impossible")

Laddar…
Avbryt
Spara