Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a11c304

Browse files
committed
Add Solution for fbuniversal [OpenKattis]
1 parent a9430c2 commit a11c304

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

‎OpenKattis/fbiuniversal/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<img src="problem.png" />

‎OpenKattis/fbiuniversal/problem.png

229 KB
Loading[フレーム]

‎OpenKattis/fbiuniversal/solution.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
UCN = '0123456789ACDEFHJKLMNPRTVWX'
2+
special = {
3+
'B': '8', 'G':'C','I': '1', 'O': '0', 'Q': '0',
4+
'S': '5', 'U':'V', 'Y':'V', 'Z':'2'
5+
}
6+
T = int(input())
7+
8+
def to_base_10(base27):
9+
total = 0
10+
for ind, el in enumerate(base27[::-1]):
11+
total += ((27**ind) * UCN.index(el))
12+
return total
13+
14+
for i_i in range(T):
15+
K, inp = input().split()
16+
new_str = ''
17+
for el in inp[:-1]:
18+
if el not in UCN:
19+
new_str += special[el]
20+
else:
21+
new_str += el
22+
mul = 2
23+
tot = 0
24+
for el in new_str:
25+
while mul % 3 == 0:
26+
mul += 1
27+
tot += (mul * UCN.index(el))
28+
mul += 1
29+
tot %= 27
30+
if (UCN[tot] == inp[-1]):
31+
print(K, to_base_10(new_str))
32+
else:
33+
print(K, 'Invalid')

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /