小米OJ-优秀数字

题目:

https://code.mi.com/problem/list/view?id=86

代码:

import sys
import math

for line in sys.stdin:
    line = line.strip()
    num = int(line)
    f1 = f2 = True
    if num < 2:
        print('Bad')
    else:
        k = int(math.log(num - 1,2))
        if (num - 1) != (1 << k):
            f1 = False
        k = int(math.log(num + 1, 2))
        if (num + 1) != (1 << k):
            f2 = False
        if f1 and f2:
            print('Very Good')
        elif f1 and not f2:
            print('Good')
        elif not f1 and f2:
            print('Bad')
        else:
            print('Normal')         
        
    

 

你可能感兴趣的:(小米OJ-优秀数字)