CF117B.Very Interesting Game

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

In a very ancient country the following game was popular. Two people play the game. Initially first player writes a string s1s_{1} , consisting of exactly nine digits and representing a number that does not exceed aa . After that second player looks at s1s_{1} and writes a string s2s_{2} , consisting of exactly nine digits and representing a number that does not exceed bb . Here aa and bb are some given constants, s1s_{1} and s2s_{2} are chosen by the players. The strings are allowed to contain leading zeroes.

If a number obtained by the concatenation (joining together) of strings s1s_{1} and s2s_{2} is divisible by modmod , then the second player wins. Otherwise the first player wins. You are given numbers aa , bb , modmod . Your task is to determine who wins if both players play in the optimal manner. If the first player wins, you are also required to find the lexicographically minimum winning move.

输入格式

The first line contains three integers aa , bb , modmod ( 0<=a,b<=1090<=a,b<=10^{9} , 1<=mod<=1071<=mod<=10^{7} ).

输出格式

If the first player wins, print "1" and the lexicographically minimum string s1s_{1} he has to write to win. If the second player wins, print the single number "2".

输入输出样例

  • 输入#1

    1 10 7
    

    输出#1

    2
    
  • 输入#2

    4 0 9
    

    输出#2

    1 000000001
    

说明/提示

The lexical comparison of strings is performed by the < operator in modern programming languages. String xx is lexicographically less than string yy if exists such ii ( 1<=i<=91<=i<=9 ), that x_{i}<y_{i} , and for any jj ( 1<=j<i ) xj=yjx_{j}=y_{j} . These strings always have length 9.

首页