F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Hearthstone

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1    Accepted Submission(s): 1


Problem Description
  Cdfpysw loves playing a card game called "Hearthstone".
  Now he has N cards, he wants to split these cards into 4 piles. Let's assume the number of cards in each pile is a1, a2, a3, a4.
  It must be satisfied that:
    a1 * k1 = a2 + a3 + a4
    a2 * k2 = a1 + a3 + a4
    a3 * k3 = a1 + a2 + a4
    a1, a2, a3, a4 must be positive
  Because Cdfpysw is clever, there must be a way to split there card. Can you tell Cdfpysw what is the way?
 

Input
  The first line is an integer T, means the number of cases.
  Then T lines, each line contains 4 integers, N, k1, k2, k3, meaning of these have been shown in the description.
  T <= 100
  1 <= N <= 109
  1 <= k1, k2, k3 <= 200
 

Output
  For each case, you should output "Case #i: " first, i is the case number.
  Then output 4 integers a1, a2, a3, a4, represent the number of cards in each pile.
 

Sample Input
1 120 2 3 4
 

Sample Output
Case #1: 40 30 24 26
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2025 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2025-03-29 19:37:33, Gzip enabled