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

primepie Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

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

primepie.html

Problem Description

Bradley is eating an entire series of pies for lunch. However, since Bradley is an epic math geek, these pies are not just normal pies, they are PRIME PIES. Prime pies have a very special property. Their weights are always prime. Thus, there will be a prime pie of 2kg, 3kg, 5kg, but not 4kg. The prime pies are also always sorted in order. So the first prime pie will be one with 2kg, the second one will be 3kg, the third one will be 5kg, etc.

Bradley wants to eat N prime pies for lunch today. He will always start eating the prime pies from the smallest one first. So, in a case where N = 4, Bradley will eat the 2kg pie, then the 3kg pie, then the 5kg pie and then the 7kg pie. Thus, Bradley would have eaten a total of 2+3+5+7=17 kg of prime pies. Given N, help Bradley find out the total amount of prime pies he would have eaten in kg.

Your program should implement the following functions:

  1. long long int amountEaten(int N), which should return the total amount of prime pies Bradley would have eaten.

Limits

Subtask 1 (9%): 1 <= N <= 100
Subtask 2 (12%): 1 <= N <= 1 000
Subtask 3 (27%): 1 <= N <= 10 000
Subtask 4 (52%): 1 <= N <= 1 000 000
It is also guranteed that the millionth prime is less than 20 000 000.

Sample Input 1

4

Sample Output 1

17

Tags

Number Theory

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
19502.5s64MBMinimum
212502.5s64MBMinimum
327502.5s64MBMinimum
452502.5s64MBMinimum
5012.5s64MBMinimum

Attachments

Attachment Filesize Last Updated
primepie.h56B8 Aug 2013, 12:48:03
grader.cpp161B8 Aug 2013, 12:48:54
ans.cpp82B8 Aug 2013, 12:48:10

Judge Compile Command

g++-8 grader.cpp ans.cpp -o primepie -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.