[SWEA] 12741. ๋ ์ ๊ตฌ(python)
๐๋ฌธ์
๐ช์์ด๋์ด
์ ๊ตฌ๊ฐ ๋ง์ง๋ง์ ์ผ์ง๋ ์๊ฐ์ ์ต์๊ฐ - ์ ๊ตฌ๊ฐ ์ฒ์์ ์ผ์ง๋ ์๊ฐ์ ์ต๋๊ฐ์ ๋นผ๋ฉด ๊ฒน์น๋ ์ด๊ฐ ๋ฐํ๋๋ค. ์์๋ฉด ๊ฒน์น์ง ์๋๋ค๊ณ ํ๋จํ๊ณ 0์ ๋ฐํํ๋ค.
๐ฅ์ฝ๋
1
2
3
4
5
6
7
8
9
answers=[]
for _ in range(int(input())):
a,b,c,d = map(int,input().split())
light = min(b,d)-max(a,c)
if light>0: answers.append(light)
else: answers.append(0)
for i,answer in enumerate(answers):
print('#{} {}'.format(i+1,answer))
This post is licensed under CC BY 4.0 by the author.
Comments powered by Disqus.