-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import sys | ||
readline = sys.stdin.readline | ||
|
||
|
||
def main(): | ||
a = readline().rstrip() | ||
if a.lower() == a: | ||
print("a") | ||
else: | ||
print("A") | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import sys | ||
readline = sys.stdin.readline | ||
|
||
def main(): | ||
N, K = map(int, readline().rstrip().split()) | ||
P = list(map(int, readline().rstrip().split())) | ||
P.sort() | ||
|
||
print(sum(P[:K])) | ||
|
||
if __name__ == '__main__': | ||
main() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import sys | ||
readline = sys.stdin.readline | ||
alp = "abcdefghijklmnopqrstuvwxyz" | ||
|
||
|
||
def main(): | ||
N = int(readline()) | ||
start = 1 # 各範囲でのスタートの値s | ||
cnt = 1 # 文字数 | ||
while True: | ||
last = start * 26 | ||
if start <= N <= last: | ||
break | ||
start = last + 1 | ||
cnt += 1 | ||
|
||
idx = N - start # その文字数の中で何番目か (0番目スタート) | ||
|
||
res = "" | ||
while cnt: | ||
chara = idx // 26 ** (cnt - 1) | ||
idx -= 26 ** (cnt - 1) * chara | ||
chara = alp[chara] | ||
res += chara | ||
cnt -= 1 | ||
|
||
print(res) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import sys | ||
readline = sys.stdin.readline | ||
from collections import Counter | ||
|
||
|
||
def main(): | ||
N = int(readline()) | ||
A = list(map(int, readline().rstrip().split())) | ||
counter = Counter(A) | ||
res = sum(A) | ||
|
||
Q = int(readline()) | ||
for _ in range(Q): | ||
b, c = map(int, readline().rstrip().split()) | ||
res = res - b * counter[b] + c * counter[b] | ||
counter.setdefault(c, 0) | ||
counter[c] += counter[b] | ||
counter.setdefault(b, 0) | ||
counter[b] = 0 | ||
|
||
print(res) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import sys | ||
readline = sys.stdin.readline | ||
|
||
|
||
def main(): | ||
N = int(readline()) # 偶数 | ||
A = list(map(int, readline().rstrip().split())) # [自分以外の全ての整数のxor, ...] | ||
|
||
if N == 2: | ||
print(*A[::-1]) | ||
return | ||
|
||
xor = [] | ||
for i in range(N-1): | ||
xor.append(A[i] ^ A[i+1]) # a xor b, b xor c, c xor d ... | ||
|
||
# bを求める | ||
b = A[0] | ||
for i in range(2, N, 2): | ||
b ^= xor[i] | ||
|
||
# aを求める | ||
a = xor[0] ^ b | ||
|
||
res = [a, b] | ||
pre = b | ||
|
||
# c以降を求める | ||
for x in xor[1:]: | ||
next = pre ^ x | ||
res.append(next) | ||
pre = next | ||
|
||
|
||
print(*res) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import sys | ||
readline = sys.stdin.readline | ||
|
||
|
||
def main(): | ||
N = int(readline()) # 偶数 | ||
A = list(map(int, readline().rstrip().split())) # [自分以外の全ての整数のxor, ...] | ||
|
||
xor = 0 | ||
for a in A: | ||
xor ^= a | ||
|
||
res = [a ^ xor for a in A] | ||
print(*res) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
File renamed without changes.