406658: GYM102471 M Value
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
M. Valuetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output
Pang believes that one cannot make an omelet without breaking eggs.
For a subset $$$A$$$ of $$$\{1,2,\ldots,n\}$$$, we calculate the score of $$$A$$$ as follows:
- Initialize the score as $$$0$$$.
- For any $$$i\in A$$$, add $$$a_i$$$ to the score.
- For any pair of integers $$$(i, j)$$$ satisfying $$$i\ge 2$$$, $$$j\ge 2$$$, $$$i\in A$$$ and $$$j\in A$$$, if there exists positive integer $$$k > 1$$$ such that $$$i^k=j$$$, subtract $$$b_j$$$ from the score.
The first line contains a single integer $$$n$$$ $$$(1\le n\le 100000)$$$.
The second line contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ $$$(1\le a_i\le 1000000000)$$$.
The third line contains $$$n$$$ integers $$$b_1,b_2,\ldots,b_n$$$ $$$(1\le b_i\le 1000000000)$$$.
OutputPrint a single integer $$$x$$$ — the maximum possible score.
ExamplesInput4 1 1 1 2 1 1 1 1Output
4Input
4 1 1 1 1 1 1 1 2Output
3