oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

primesuspect Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

primesuspect.html

Poe the Penguin is working on a robbery case. He has a list of N suspects, labelled from 1 to N to conceal their identity, standing in front of him.

Poe the Penguin has innate skills in figuring out who is guilty and who is not. Therefore, he has narrowed down his selection of suspects to a set of prime suspects. A prime suspect is someone whose label is a prime. Out of all the prime suspects, Poe the Penguin believes that the oldest suspect commited the robbery. If there are more than 1 prime suspect with the same age, Poe the Penguin believes that the person with the biggest label committed the crime.

Given the above information, Poe the Penguin wants to know who committed the robbery. Help him.

Input

The first line contains a single integer N.

The next line contains N positive integers. The ith integer from the right denotes the age of the person with label i.

You can assume that 1 ≤ N ≤ 1000.

Output

Output the label of the prime suspect..

Sample Input

10
4 8 2 9 5 4 8 2 9 5

Sample Output

7  

Sample Explanation

The prime suspects are those with labels 2, 3, 5 and 7. Their ages are 9, 2, 4 and 9 respectively. The suspects with labels 2 and 7 are the oldest, but we know that the person with the greater label committed the crime. Therefore, suspect 7 committed the crime.

Tags

Number Theory

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
1100101s32MBAverage
2011s32MBAverage

Judge Compile Command

g++-8 ans.cpp -o primesuspect -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.