#P7586. [COCI 2012/2013 #1] SNAGA
[COCI 2012/2013 #1] SNAGA
Description
Starting from a positive integer , find the smallest positive integer that is not divisible by . If we repeat this process using the obtained positive integer, we will eventually get .
Define as the length of the resulting sequence. For example, for , we can obtain the sequence , which consists of numbers, so .
Given two positive integers , compute:
Input Format
The input consists of one line containing two integers separated by a space.
Output Format
Output one integer on a single line, representing the result.
3 6
11
100 200
262
Hint
Constraints
For of the testdata, it is guaranteed that .
Notes
The scoring for this problem follows the original COCI settings, with a full score of .
Translated from COCI2012-2013 CONTEST #1 T5 SNAGA.
Translated by ChatGPT 5
京公网安备 11011102002149号