You are assigned a task to travel to different villages to make some profit. In each village, you gain some profit. From a
village i, you can only move to a village j if and only if i<j and the profit gain from village j is a multiple of the profit ga
from village i
You are required to determine the maximum profit you can gain while traveling.
Input format
• First line: A single integer N denoting the total number of villages
• Second line: N space-separated integers, each denoting the profit gain P; from village i
2
Output format
Print the maximum profit you can gain.
Answers
Answered by
9
Answer:
You are assigned a task to travel to different villages to make some profit. In each village, you gain some profit. From a
village i, you can only move to a village j if and only if i<j and the profit gain from village j is a multiple of the profit ga
from village i
You are required to determine the maximum profit you can gain while traveling.
Input format
• First line: A single integer N denoting the total number of villages
• Second line: N space-separated integers, each denoting the profit gain P; from village i
2
Output format
Print the maximum profit you can gain.
Similar questions