306101: CF1146D. Frog Jumping
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Frog Jumping
题意翻译
yyb大神仙在数轴的$0$位置。yyb大神仙有两个正整数$a,b$,如果当前yyb大神仙在位置$k$,yyb大神仙可以用神仙的力量将自己传送到$k+a$或者$k-b$位置。 但是yyb大神仙感觉这样很无聊所以打算将自己限制在一段区间里。$f(x)$表示yyb大神仙只能在$[0,x]$区间里移动,从$0$开始能到达的整点数量。yyb大神仙想求$\sum_{i=0}^mf(i)$。题目描述
A frog is initially at position $ 0 $ on the number line. The frog has two positive integers $ a $ and $ b $ . From a position $ k $ , it can either jump to position $ k+a $ or $ k-b $ . Let $ f(x) $ be the number of distinct integers the frog can reach if it never jumps on an integer outside the interval $ [0, x] $ . The frog doesn't need to visit all these integers in one trip, that is, an integer is counted if the frog can somehow reach it if it starts from $ 0 $ . Given an integer $ m $ , find $ \sum_{i=0}^{m} f(i) $ . That is, find the sum of all $ f(i) $ for $ i $ from $ 0 $ to $ m $ .输入输出格式
输入格式
The first line contains three integers $ m, a, b $ ( $ 1 \leq m \leq 10^9, 1 \leq a,b \leq 10^5 $ ).
输出格式
Print a single integer, the desired sum.
输入输出样例
输入样例 #1
7 5 3
输出样例 #1
19
输入样例 #2
1000000000 1 2019
输出样例 #2
500000001500000001
输入样例 #3
100 100000 1
输出样例 #3
101
输入样例 #4
6 4 5
输出样例 #4
10