QOJ.ac

QOJ

Límite de tiempo: 2 s Límite de memoria: 1024 MB

#23974. แอปเปิล

Estadísticas

โจทย์ปัญหา

JOI คุงกำลังจะไปซื้อแอปเปิล

การซื้อแอปเปิล $1$ ผลมีราคา $X$ เยน และหากซื้อแอปเปิลเป็นแพ็กคู่ $2$ ผล จะสามารถซื้อได้ในราคาผลละ ($1$ ผล) $Y$ เยน (แพ็กละ $1$ แพ็ก ราคา $2Y$ เยน) โดยที่ $Y < X$

เมื่อนำการซื้อแบบแยก $1$ ผลและแบบแพ็กคู่ $2$ ผลมารวมกันเพื่อซื้อแอปเปิลให้ได้จำนวนรวมกันเท่ากับ $N$ ผลพอดี จงหาจำนวนเงินขั้นต่ำที่ต้องจ่าย

ข้อจำกัด

  • $1 \le X \le 100$
  • $1 \le Y \le 100$
  • $1 \le N \le 100$
  • $Y < X$
  • ค่าที่รับเข้ามาทั้งหมดเป็นจำนวนเต็ม

ข้อมูลนำเข้า

ข้อมูลนำเข้าจะถูกกำหนดให้ในรูปแบบต่อไปนี้:

X Y N

ข้อมูลส่งออก

แสดงจำนวนเงินขั้นต่ำที่ต้องจ่ายเมื่อซื้อแอปเปิลรวมกันเท่ากับ $N$ ผลพอดี โดยไม่ต้องใส่หน่วย (เยน)

ห้ามแสดงผลสิ่งอื่นใดนอกจากคำตอบ (ห้ามแสดงข้อความแจ้งให้ป้อนข้อมูล ฯลฯ)

สำหรับรูปแบบคำตอบ คุณสามารถอ้างอิงจาก โจทย์ฝึกหัดและตัวอย่างคำตอบ ได้


ตัวอย่างข้อมูลนำเข้า $1$

4 3 5

ตัวอย่างข้อมูลส่งออก $1$

16

หากซื้อแอปเปิลในราคา $4$ เยนจำนวน $1$ ผล และซื้อแพ็กคู่ $2$ ผลจำนวน $2$ แพ็ก (รวม $2 \times 2 = 4$ ผล) จะเป็นเงินรวมทั้งสิ้น $4 \times 1 + 3 \times 4 = 16$ เยน เนื่องจากไม่สามารถซื้อด้วยวิธีอื่นให้ถูกกว่านี้ได้ จึงแสดงผลเป็น $16$


ตัวอย่างข้อมูลนำเข้า $2$

3 1 6

ตัวอย่างข้อมูลส่งออก $2$

6

การซื้อแพ็กคู่ $2$ ผลจำนวน $3$ แพ็กถูกที่สุด ดังนั้นรวมเป็นเงิน $1 \times 2 \times 3 = 6$ เยน


ตัวอย่างข้อมูลนำเข้า $3$

10 2 1

ตัวอย่างข้อมูลส่งออก $3$

10

เนื่องจากซื้อในราคา $10$ เยนจำนวน $1$ ผล จึงรวมเป็นเงิน $10 \times 1 = 10$ เยน สังเกตว่าในที่นี้จำเป็นต้องซื้อแอปเปิลให้ได้รวมกันเท่ากับ $N$ ผลพอดี จึงไม่สามารถจ่าย $2 \times 2 = 4$ เยนเพื่อซื้อแพ็ก $2$ ผลเกินมาได้

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.