CF1202F.You Are Given Some Letters...
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 si=si 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≤a,b≤109 ) — 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.