Python/2.7 simple coding(+ c++)

Security Override Programming 8

qkqhxla1 2014. 12. 18. 13:27

level 8.






요러한 원이 있다. A의 반지름, CD,AB의 길이가 주어져있고 A,B는 정원이다. 주어진 3개의 정보만으로


BC의 길이를 구하는건데. 오른쪽 사진은 예시값을 대입한 것이다. 피타고라스로 잘 변형해서 풀면 된다.


코드를 짜 봤는데.. 반반의 확률로 에러가 뜬다. math domain error라고 뜨는데


아마도 루트씌운값을 몇자리까지 쓰겠다. 그런 말 없이 바로 제곱에 쓰니 범위가 길어져서 에러가 뜨는


것 같다. 답이 나오는 경우가 있어서 고치기 귀찮다.


import urllib2,re
from math import *

req = urllib2.Request('http://securityoverride.org/challenges/programming/8/index.php')
req.add_header('cookie','PHPSESSID=쿠키')
page = urllib2.urlopen(req).read()

ac = int(re.findall("Radius of A = (.*?)<br />",page)[1])
ab = int(re.findall("Length of AB = (.*?)<br />",page)[0])
cd = int(re.findall("Length of CD = (.*?)<br />",page)[0])

answer = '%.3f' %sqrt(pow( ab-sqrt(pow(ac,2)-pow(cd/2,2)),2 )+pow(cd/2,2))

req = urllib2.Request('http://securityoverride.org/challenges/programming/8/index.php','CSRF_TOKEN=%3C%3Fphp+echo+%24_SESSION%5B%27CSRF_TOKEN%27%5D%3B%3F%3E&string='+answer+'&submitbutton=+Time+Has+Expired+')
req.add_header('cookie','PHPSESSID=쿠키')
print urllib2.urlopen(req).read()




'Python > 2.7 simple coding(+ c++)' 카테고리의 다른 글

Security Override Programming 10  (0) 2014.12.18
Security Override Programming 9  (0) 2014.12.18
Security Override Programming 6~7  (0) 2014.12.17
Security Override Programming 4~5  (0) 2014.12.17
Security Override Programming 1~3  (0) 2014.12.17