306472: CF1202F. You Are Given Some Letters...

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

You Are Given Some Letters...

题意翻译

# 题目描述 给你一个 $a$ ,一个 $b$ ,让你找出所有字符串,满足它仅由 $a$ 个 _A_ 和 $b$ 个 _B_ ,并且分别求出它们的最小周期 $k$ (设该串为 $s$ ,即k满足s[i]=s[i%k])。 输出共有多少不同的 $k$ 。 # 输入格式 输入一行两个数,即 $a$ , $b$ 。 # 输出格式 输入一行一个数,即 $k$ 的个数 。 # 样例解释 ### 样例1: 四个可能: "BBABBA" k = 3 "BBAABB" k = 4 "BBBAAB" k = 5 "AABBBB" k = 6 ### 样例2: 五个可能: "BAABAABA" k = 3 "BAABABAA" k = 5 "BABAAABA" k = 6 "BAABAAAB" k = 7 "AAAAABBB" k = 8

题目描述

You are given $ a $ uppercase Latin letters 'A' and $ b $ letters 'B'. The period of the string is the smallest such positive integer $ k $ that $ s_i = s_{i~mod~k} $ ( $ 0 $ -indexed) for each $ i $ . Note that this implies that $ k $ won't always divide $ a+b = |s| $ . For example, the period of string "ABAABAA" is $ 3 $ , the period of "AAAA" is $ 1 $ , and the period of "AABBB" is $ 5 $ . Find the number of different periods over all possible strings with $ a $ letters 'A' and $ b $ letters 'B'.

输入输出格式

输入格式


The first line contains two integers $ a $ and $ b $ ( $ 1 \le a, b \le 10^9 $ ) — the number of letters 'A' and 'B', respectively.

输出格式


Print the number of different periods over all possible strings with $ a $ letters 'A' and $ b $ letters 'B'.

输入输出样例

输入样例 #1

2 4

输出样例 #1

4

输入样例 #2

5 3

输出样例 #2

5

说明

All the possible periods for the first example: - $ 3 $ "BBABBA" - $ 4 $ "BBAABB" - $ 5 $ "BBBAAB" - $ 6 $ "AABBBB" All the possible periods for the second example: - $ 3 $ "BAABAABA" - $ 5 $ "BAABABAA" - $ 6 $ "BABAAABA" - $ 7 $ "BAABAAAB" - $ 8 $ "AAAAABBB" Note that these are not the only possible strings for the given periods.

Input

题意翻译

# 题目描述 给你一个 $a$ ,一个 $b$ ,让你找出所有字符串,满足它仅由 $a$ 个 _A_ 和 $b$ 个 _B_ ,并且分别求出它们的最小周期 $k$ (设该串为 $s$ ,即k满足s[i]=s[i%k])。 输出共有多少不同的 $k$ 。 # 输入格式 输入一行两个数,即 $a$ , $b$ 。 # 输出格式 输入一行一个数,即 $k$ 的个数 。 # 样例解释 ### 样例1: 四个可能: "BBABBA" k = 3 "BBAABB" k = 4 "BBBAAB" k = 5 "AABBBB" k = 6 ### 样例2: 五个可能: "BAABAABA" k = 3 "BAABABAA" k = 5 "BABAAABA" k = 6 "BAABAAAB" k = 7 "AAAAABBB" k = 8

加入题单

上一题 下一题 算法标签: