【度小满2018-09-26在线笔试】ONU

版权声明:本文为阿木寺的原创文章,未经本人允许不得转载。 https://blog.csdn.net/amusi1994/article/details/82855791

题目描述

ONU是一种新型桌游,一副牌有若干种花色,总共N张,且每种花色的牌的张数一样。现在每次给定N,M,表示这幅总共N张的牌至少有M种花色,请问这副牌可能的花色有多少种?

输入

共一行,两个整数N,M。(1<=N<=1012,0<=M<=1012

输出

一个整数,表示可能的花色种数。

样例输入

30

样例输出

2

Hint

可能有15或者30种花色,所以总共两种花色数。

在这里插入图片描述

Python代码

# Summary: ONU
# Author:  Amusi
# Date:    2018-09-26
# Reference: https://blog.csdn.net/yong_ss/article/details/79356836

n,m = map(int, input("").split())

def process(m, n):
    count = 0
    i = 1
    while i*i<n:
        if 0==n%i:
            if i<m and (n//i)>m:
                count+=1
            if i>m and (n//i)>m:
                count+=2
            if i==m and (n//i)==m:
                count+=1
            if i==m and (n//i)!=m:
                count+=2
            
        i+=1
    if(i*i==n):
        count+=1
    return count
    
print(process(m, n))

猜你喜欢

转载自blog.csdn.net/amusi1994/article/details/82855791