CF678C.Joty and Chocolate

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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

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

After her painting is done, she will get pp chocolates for each tile that is painted Red and qq 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 maximum number of chocolates Joty can get.

输入格式

The only line contains five integers nn , aa , bb , pp and qq ( 1<=n,a,b,p,q<=1091<=n,a,b,p,q<=10^{9} ).

输出格式

Print the only integer ss — the maximum number of chocolates Joty can get.

Note that the answer can be too large, so you should use 6464 -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.

输入输出样例

  • 输入#1

    5 2 3 12 15
    

    输出#1

    39
    
  • 输入#2

    20 2 3 3 5
    

    输出#2

    51
    
首页