Cod sursa(job #2692941)

Utilizator catalin69420Gogu Popescu catalin69420 Data 4 ianuarie 2021 13:36:31
Problema Cifra Scor 0
Compilator py Status done
Runda Arhiva de probleme Marime 0.52 kb
#!/usr/bin/python3

import sys

def last_digit_pow(a, b):
    if a == 0 and b == 0:
        return 1
    if a == 0 or b == 0:
        return 0

    la = a % 10
    lb = b % 4
    if b % 4 == 0:
        lb = 4
    return (la ** lb) % 10


l = [last_digit_pow(i, i) for i in range(100)]

file = open("cifra.in", "r")
out = open("cifra.out", "w")

file.readline()

for line in file.readlines():
    try:
        val = int(line)
    except:
        print("Error bad  input")
        sys.exit(-1)

    out.write(l[val].__str__() + '\n')