# Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Who doesn’t get happy after getting money in the pockets of clothes before washing them? During this pandemic, Jenia washes clothes at home as they don’t keep a maid as outsiders are not allowed at home to avoid risk. Even though Jenia gets the money while washing, but she and her siblings end up in a fight while claiming the money. Jenia has twin siblings, Umair and Zuaina. Since school is closed so her siblings don’t study at all. Thus Jenia thought of a game to avoid the chaos for money as well as make her siblings practice mathematics. It’s a game where the twin will compete jenia as a team. So she gave the twins `$N$`

pieces of paper and asked them to write positive odd numbers sequentially but following a rule. The rule is :

- They will write one positive odd number in the first paper which is
`$1$`

. - In the second paper, they will write the next two positive odd numbers which are
`$3$`

,`$5$`

. - In the third paper, they will write the next three positive odd numbers which are
`$7$`

,`$9$`

,`$11$`

. - In the fourth paper, they will write
`$13$`

,`$15$`

,`$17$`

,`$19$`

. They must continue writing these papers until the Nth piece of paper following this rule.

Zuaina will keep the papers where the total number of numbers written on a paper is even. Umair will keep the rest. Both of them will separately find the sum of all the numbers in all the papers they currently have. Let Zuaina’s sum is `$S_1$`

and Umair’s sum is `$S_2$`

.

The next task of the twins is to find the total sum `$S$`

where `$S = S_1 + S_2$`

. The prize money of this game is, `$R_{actual} = S \% P$`

where `$P$`

is the money that was found in the pockets. It is always guaranteed that P is a prime number. The twins will try to find the correct value of prize money, but they might make mistakes in the calculation as they are still learning about modulo operation. Let’s say the prize money that twins calculated is `$R_{Twin's Answer}$`

.

If `$R_{Twin's Answer}$`

=`$R_{actual}$`

then the twins gets the prize money and Jenia will get to keep the rest of the money. If `$R_{Twin's Answer}$`

`$\neq$`

`$R_{actual}$`

then Jenia will keep the prize money and the twins will keep the rest of the money. It doesn’t matter if the prize money, `$R_{actual}$`

, is greater or less than the rest of the money, `$P-R_{actual}$`

. That’s the fun part of this game.

Jenia is busy with her online classes and is unable to check the result. Given `$N$`

, `$P$`

and `$R_{Twin's Answer}$`

, can you be the judge and let them know how much Jenia and the team of twins will get.

The input contains a single line with three integers `$N$`

, `$P$`

, `$R_{Twin's Answer}$`

where `$1≤N≤10^{12}$`

,`$P$`

is a prime in the range `$(1,5000)$`

and `$0≤R_{Twin's Answer}<P$`

.

Print two integers that indicate the amount Jenia and the team of twins will get sequentially separated by a space between them.

Input | Output |
---|---|

4 53 47 | 6 47 |

Input | Output |
---|---|

4 53 23 | 47 6 |

Here, N = 4 so there will be 4 papers. |

40% Solution Ratio

blizzardEarliest,

obaydullahmhsFastest, 0.0s

obaydullahmhsLightest, 131 kB

blizzardShortest, 155B

Login to submit