QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#21054. ערבוב חלב

Statistics

חקלאות היא עסק תחרותי, במיוחד ייצור חלב. Farmer John חושב שאם לא יחדש את שיטות הייצור, עסק החלב שלו עלול להיות מובס!

למרבה המזל יש לו רעיון טוב. שלוש פרותיו עטורות הפרסים Bessie, Elsie ו-Mildred מפיקות חלב בעל טעמים מעט שונים, והוא מתכנן לערבב אותם לטעם מושלם.

הוא לוקח שלושה דליים עם החלב שלהן. קיבולותיהם עשויות להיות שונות והם אינם בהכרח מלאים. הוא מוזג מדלי $1$ ל-$2$, מ-$2$ ל-$3$, מ-$3$ ל-$1$, שוב מ-$1$ ל-$2$, במחזור עד 100 מזיגות (המזיגה ה-100 מ-$1$ ל-$2$). מ-$a$ ל-$b$ הוא מוזג ככל האפשר עד ש-$a$ ריק או $b$ מלא.

מצאו את כמות החלב בכל דלי לאחר כל 100 המזיגות.

קלט

השורה הראשונה מכילה שני מספרים שלמים מופרדים ברווח: קיבולת הדלי הראשון $c_1$ וכמות החלב בו $m_1$. שניהם חיוביים ולכל היותר $10^9$, עם $c_1 \geq m_1$. השורות השנייה והשלישית נותנות באופן דומה את הקיבולות והכמויות בדליים האחרים.

פלט

הדפיסו שלוש שורות עם כמות החלב הסופית בכל דלי אחרי 100 מזיגות.

דוגמאות

קלט 1

10 3
11 4
12 5

פלט 1

0
10
2

הערה

בדוגמה, כמויות החלב במהלך המזיגות הן:

מצב התחלתי: 3  4  5
1. מזיגה 1->2:  0  7  5
2. מזיגה 2->3:  0  0  12
3. מזיגה 3->1:  10 0  2
4. מזיגה 1->2:  0  10 2
5. מזיגה 2->3:  0  0  12
(שלושת המצבים האחרונים חוזרים לאחר מכן במחזור ...)

מחבר הבעיה: Brian Dean

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.