import sys final_string = '' final_count = 0 class BinarySearch: def getPos(self, val): A = [] for i in xrange(0, 181): A.append(i-90) self.findPos(A, 0, 180, val) print final_string def findPos(self, A, start, end, value): final_count = final_count + 1 if final_count > 6: return if start == end: if (A[end] == value): final_string = final_string+'1' return else: return if A[(end+start)/2] == value: final_string = final_string+'1' return elif A[(end+start)/2] < value: final_string = final_string+'0' return self.findPos(A, (end+start)/2+1, end, value) else: final_string = final_string+'1' return self.findPos(A, start, (end+start)/2-1, value) if __name__ == '__main__': for line in sys.stdin: BinarySearch b b.getPos(int(line)) ''' 二分法求解 '''