ปานกลาง 0 ข้อที่แก้แล้ว อัตราผ่าน 0%

Count Dice Sequences

Count ordered die-roll sequences with a given total.

A standard die produces an integer from 1 through 6. Count all nonempty ordered sequences of outcomes whose sum is target. Different orders count separately. Return the count modulo 1,000,000,007.

Implement dice_combinations(target).

Input

target: The required sum of all rolls.

Output

Return the number of sequences modulo 1,000,000,007.

เงื่อนไข

1 ≤ target ≤ 1,000,000. Taking a count modulo 1,000,000,007 means returning its remainder after division by that number.

ตัวอย่าง

ตัวอย่างที่ 1
อินพุต:
target = 2

ผลลัพธ์ที่คาดหวัง:
expected = 2
อินพุต:
long long target = 2;

ผลลัพธ์ที่คาดหวัง:
long long expected = 2;
อินพุต:
long target = 2;

ผลลัพธ์ที่คาดหวัง:
long expected = 2;

คำอธิบาย

The two sequences are [2] and [1, 1].

ตัวอย่างที่ 2
อินพุต:
target = 4

ผลลัพธ์ที่คาดหวัง:
expected = 8
อินพุต:
long long target = 4;

ผลลัพธ์ที่คาดหวัง:
long long expected = 8;
อินพุต:
long target = 4;

ผลลัพธ์ที่คาดหวัง:
long expected = 8;

คำอธิบาย

The sequences are [4], [1,3], [3,1], [2,2], [1,1,2], [1,2,1], [2,1,1], and [1,1,1,1].

แหล่งอ้างอิง

โจทย์นี้ปรับให้เหมาะกับ CodeUtility กรุณาทำตามคำชี้แจงและข้อจำกัดด้านบน

เรียนรู้จากคนอื่น

แนวทางจากชุมชน

ยังไม่มีวิธีทำที่เผยแพร่ ลองแก้โจทย์นี้เพื่อแชร์วิธีแรก