QOJ.ac

QOJ

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

#22332. הדרכים סביב החווה

Statistics

הפרות של Farmer John החלו להתעניין בחקר השטח סביב החווה. בתחילה, כל $N$ $(1 \le N \le 1,000,000,000)$ הפרות מתחילות ללכת בדרך בקבוצה גדולה אחת. כשהקבוצה מגיעה לפיצול בדרך, היא בוחרת לפעמים להתחלק לשתי קבוצות קטנות יותר ולא ריקות, וכל קבוצה ממשיכה באחת הדרכים. כשאחת מהן מגיעה לפיצול נוסף, היא עשויה להתחלק שוב, וכן הלאה.

הפרות פיתחו דרך מיוחדת להתחלק: אם הן יכולות להתחלק לשתי קבוצות שגודליהן נבדלים בדיוק ב־$K$ $(1 \le K \le 1000)$, הן מתחלקות כך; אחרת הן מפסיקות לחקור ופשוט מתחילות לרעות בשלווה.

בהנחה שתמיד יהיו פיצולים חדשים בדרך, חשבו את המספר הסופי של קבוצות פרות הרועות בשלווה.

קלט

  • שורה $1$: שני מספרים שלמים $N$ ו־$K$, מופרדים ברווח.

פלט

  • שורה $1$: מספר שלם אחד המייצג את מספר קבוצות הפרות הרועות.

דוגמאות

קלט 1

6 2

פלט 1

3

הערה

יש 6 פרות וההפרש בין גדלי הקבוצות הוא 2.

יש 3 קבוצות סופיות (ובהן 2, 1 ו־3 פרות).

   6
  / \
 2   4
    / \
   1   3

מחבר הבעיה: Aram Shatakhtsyan, 2007

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.