测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A9704. Tennis Game

编程题 普及/提高-

题目描述

Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores $t$ points, he wins the set; then the next set starts and scores of both players are being set to 0. As soon as one of the players wins the total of $s$ sets, he wins the match and the match is over. Here $s$ and $t$ are some positive integer numbers.

To spice it up, Petya and Gena choose new numbers $s$ and $t$ before every match. Besides, for the sake of history they keep a record of each match: that is, for each serve they write down the winner. Serve winners are recorded in the chronological order. In a record the set is over as soon as one of the players scores $t$ points and the match is over as soon as one of the players wins $s$ sets.

Petya and Gena have found a record of an old match. Unfortunately, the sequence of serves in the record isn't divided into sets and numbers $s$ and $t$ for the given match are also lost. The players now wonder what values of $s$ and $t$ might be. Can you determine all the possible options?

输入格式

Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores $t$ points, he wins the set; then the next set starts and scores of both players are being set to 0. As soon as one of the players wins the total of $s$ sets, he wins the match and the match is over. Here $s$ and $t$ are some positive integer numbers.

To spice it up, Petya and Gena choose new numbers $s$ and $t$ before every match. Besides, for the sake of history they keep a record of each match: that is, for each serve they write down the winner. Serve winners are recorded in the chronological order. In a record the set is over as soon as one of the players scores $t$ points and the match is over as soon as one of the players wins $s$ sets.

Petya and Gena have found a record of an old match. Unfortunately, the sequence of serves in the record isn't divided into sets and numbers $s$ and $t$ for the given match are also lost. The players now wonder what values of $s$ and $t$ might be. Can you determine all the possible options?

输出格式

Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores $t$ points, he wins the set; then the next set starts and scores of both players are being set to 0. As soon as one of the players wins the total of $s$ sets, he wins the match and the match is over. Here $s$ and $t$ are some positive integer numbers.

To spice it up, Petya and Gena choose new numbers $s$ and $t$ before every match. Besides, for the sake of history they keep a record of each match: that is, for each serve they write down the winner. Serve winners are recorded in the chronological order. In a record the set is over as soon as one of the players scores $t$ points and the match is over as soon as one of the players wins $s$ sets.

Petya and Gena have found a record of an old match. Unfortunately, the sequence of serves in the record isn't divided into sets and numbers $s$ and $t$ for the given match are also lost. The players now wonder what values of $s$ and $t$ might be. Can you determine all the possible options?

输入输出样例

输入 #1
5
1 2 1 2 1
输出 #1
2
1 3
3 1
输入 #2
4
1 1 1 1
输出 #2
3
1 4
2 2
4 1
输入 #3
4
1 2 1 2
输出 #3
0
输入 #4
8
2 1 2 1 1 1 1 1
输出 #4
3
1 6
2 3
6 1
上一题 去做题 下一题