A12523 | Frog Jumping
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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$ .
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
In the first example, we must find $f(0)+f(1)+\ldots+f(7)$ . We have $f(0) = 1, f(1) = 1, f(2) = 1, f(3) = 1, f(4) = 1, f(5) = 3, f(6) = 3, f(7) = 8$ . The sum of these values is $19$ .
In the second example, we have $f(i) = i+1$ , so we want to find $\sum_{i=0}^{10^9} i+1$ .
In the third example, the frog can't make any jumps in any case.
In the second example, we have $f(i) = i+1$ , so we want to find $\sum_{i=0}^{10^9} i+1$ .
In the third example, the frog can't make any jumps in any case.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted