def kod(a,b):
if (a<=500 and b<=500):
return(a+500, b+500)
elif (a>500 and b>500):
return(a-500, b-500)
elif (a>500 and b<=500):
a+=1
b+=1
if a>1000:
a=501
if b>500:
b=1
return(a,b)
elif (a<=500 and b>500):
a+=1
b+=1
if b>1000:
b=501
if a>500:
a=1
return(a,b)
return('błąd')
def dekod(a,b):
if (a<=500 and b<=500):
return(a+500, b+500)
elif (a>500 and b>500):
return(a-500, b-500)
elif (a>500 and b<=500):
a-=1
b-=1
if a==500:
a=1000
if b==0:
b=500
return(a,b)
elif (a<=500 and b>500):
a-=1
b-=1
if a==0:
a=500
if b==500:
b=1000
return(a,b)
else:
return('bład')
def test():
t = [(501,500),(500,501), (1000,999), (1000,1), (500, 1000), (993,333),(334,564)]
for a,b in t:
print(a,b)
a,b = kod(a,b)
print(" ",a,b)
a,b = dekod(a,b)
print(a,b)
print()
def main():
kto=input()
if kto == "Algosia":
a, b = map(int, input().split())
a,b = kod(a,b)
print(a, b, flush=True)
else:
a, b = map(int, input().split())
a,b = dekod(a,b)
print(a, b, flush=True)
main()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | def kod(a,b): if (a<=500 and b<=500): return(a+500, b+500) elif (a>500 and b>500): return(a-500, b-500) elif (a>500 and b<=500): a+=1 b+=1 if a>1000: a=501 if b>500: b=1 return(a,b) elif (a<=500 and b>500): a+=1 b+=1 if b>1000: b=501 if a>500: a=1 return(a,b) return('błąd') def dekod(a,b): if (a<=500 and b<=500): return(a+500, b+500) elif (a>500 and b>500): return(a-500, b-500) elif (a>500 and b<=500): a-=1 b-=1 if a==500: a=1000 if b==0: b=500 return(a,b) elif (a<=500 and b>500): a-=1 b-=1 if a==0: a=500 if b==500: b=1000 return(a,b) else: return('bład') def test(): t = [(501,500),(500,501), (1000,999), (1000,1), (500, 1000), (993,333),(334,564)] for a,b in t: print(a,b) a,b = kod(a,b) print(" ",a,b) a,b = dekod(a,b) print(a,b) print() def main(): kto=input() if kto == "Algosia": a, b = map(int, input().split()) a,b = kod(a,b) print(a, b, flush=True) else: a, b = map(int, input().split()) a,b = dekod(a,b) print(a, b, flush=True) main() |
English