编程介的小学生 2017-03-13 12:11 采纳率: 20.5%
浏览 840
已采纳

Banal Tickets

Peter is fond of number theory. That's why he is looking for interesting bus tickets.
Ticket with the number of length 2N is called interesting if the product of the first N digits of its number is equal to the product
of the last N digits. Other tickets are called banal.

Peter has found a used ticket in his pocket. Unfortunately the ticket was punched, so Peter cannot recognize some digits. He wonders whether this ticket was an interesting one. Moreover he wants to know how many different interesting and banal tickets could be punched to get this one.

Help Peter to find answers to his questions.

Input

The first line of the input contains an integer N (1 <= N <= 18). The next line contains a string representing the ticket number. If some digit is punched out it is denoted by "?"' otherwise it is denoted by itself.

Output

On the first line of the output print the number of interesting tickets. On the second line print the number of banal tickets.

This problem contains multiple test cases!

The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.

The output format consists of N output blocks. There is a blank line between output blocks.

Sample Input

2

2
2??3

3
2?6??3

Sample Output

4
96

46
954

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-03-23 15:52
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 echarts动画效果失效的问题。官网下载的例子。
  • ¥60 许可证msc licensing软件报错显示已有相同版本软件,但是下一步显示无法读取日志目录。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加