跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F1219. Joty and Chocolate

    ID: 1225 传统题 2000ms 256MiB 尝试: 0 已通过: 0 难度: 4 上传者: 标签>模拟数学数论编程与模拟进阶难度共享题库Codeforces英文题面题目来源题面语言

Joty and Chocolate

题目描述

C. Joty and Chocolate
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Little Joty has got a task to do. She has a line of n tiles indexed from 1 to n. She has to paint them in a strange pattern.

An unpainted tile should be painted Red if it's index is divisible by a and an unpainted tile should be painted Blue if it's index is divisible by b. So the tile with the number divisible by a and b can be either painted Red or Blue.

After her painting is done, she will get p chocolates for each tile that is painted Red and q chocolates for each tile that is painted Blue.

Note that she can paint tiles in any order she wants.

Given the required information, find the maximumnumber of chocolates Joty can get.

Input

The only line contains five integers n, a, b, p and q (1≤n,a,b,p,q≤109).

Output

Print the only integer s − the maximum number of chocolates Joty can get.

Note that the answer can be too large, so you should use 64-bit integer type to store it. In C++ you can use the long long integer type and in Java you can use long integer type.

Examples
Input
5 2 3 12 15
Output
39
Input
20 2 3 3 5
Output
51


题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 700 题。保留原作者与原赛事署名。