D: Knitting

January 24th, 2010 | Categories: 2009 Regionals

Knitting was one of the two easiest problems in the set (Minesweeper is the other), and was solved by most teams.

Here’s the Judge Input, the Judge Output, the main Solving Program, another solution, and another.

There’s a pseudocode solution in the spoiler.
[spoiler]
The only real trick is to recognize that the numbers are so small that you don’t need fancy math. Just iterate through it.

    Input numberOfRows, firstRow, numberOfDeltas, deltas
    stitchesOnRow = firstRow
    total = 0;
    For i = 0 to numberOfRows-1
        total = total + stitchesOnRow
        stitchesOnRow = stitchesOnRow + deltas[i mod numberOfDeltas]
    End
    Print total

[/spoiler]

No comments yet.
You must be logged in to post a comment.