Wild Number

Description

Wild Number是一个有数字和问号组成的字符串(例如36?1?8)。一个数字与一个WildNumber匹配,当且仅当它们长度相等且不是问号的位置上对应相等。例如365198匹配36?1?8,但360199,361028,36128都不匹配。

Input

输入有相同长度的两行,第一行表示Wild Number,第二行一个整数X,X无前导零。数字长度在1-10之间。

Output

输出大于X且匹配Wild Number的n位数有多少个。(n是Wild Number的长度。)

Sample Input

?

5

Sample Output

4

Data Constraint

Hint

数据范围
N<=10
?的个数小于等于7

 

分析:用数据说话。

 数据1:???

706 (某个LY的生日,don’t吐槽)

输出: 293

分析:如果我们的第一位比8要大,后面就可以不管了,然后选7,求后面的答案。

      Ans=ans+(9-7)*10^s  (s为后面1的个数)

 数据2:8??     14??

       623     1314 (另 一个LY的生日,don’t吐槽)

  输出:100     100

如果前面的位比x大,直接输出10^s次方;

数据3:6?4 1??5  5?0

       623 1314 520

输出:8 69 7

 如果后面的确定数比x大,说明最后一个?可以等于x的对应位,答案加1,等于不管。

 

 

var

 s1,s2:string;

 l,ans:longint;

 b:boolean;

procedure main;

var

 i,j,sum,k:longint;

begin

 l:=length(s1);

  k:=0;ans:=0;

  fori:=1 to l do

    ifs1[i]='?' then inc(k);

 b:=true;

  fori:=1 to l do

    ifs1[i]='?' then

     begin

       sum:=1;

       for j:=1 to k-1 do

         sum:=sum*10;

       if b then sum:=sum*(9-(ord(s2[i])-48)) else

         begin

           sum:=sum*10;

           write(ans+sum);

           halt;

         end;

       ans:=ans+sum;

       dec(k);

     end else

     begin

       if (s2[i]>s1[i]) and b then

         begin

           writeln(ans);

           halt;

         end;

       if s2[i]<s1[i] then b:=false;

     end;

end;

 

begin

 readln(s1);

 readln(s2);

 main;

  if notb then writeln(ans+1)

          else writeln(ans);

end.

 

下面有篇英文课文,请编程找出课文中所有的单词,统计单词出现的次,统计时不区分字母的大小写,最后按出现的次从大到小显示出现3次以上各个单词及次。例如,结果显示如下: the 18 a 14 puma 9 in 8 it 8 ...(略) 英文课文如下: Pumas are large, cat-like animals which are found in America. When reports came into London Zoo that a wild puma had been spotted forty-five miles south of London, they were not taken seriously. However, as the evidence began to accumulate, experts from the Zoo felt obliged to investigate, for the descriptions given by people who claimed to have seen the puma were extraordinarily similar. The hunt for the puma began in a small village where a woman picking blackberries saw 'a large cat' only five yards away from her. It immediately ran away when she saw it, and experts confirmed that a puma will not attack a human being unless it is cornered. The search proved difficult, for the puma was often observed at one place in the morning and at another place twenty miles away in the evening. Wherever it went, it left behind it a trail of dead deer and small animals like rabbits. Paw prints were seen in a number of places and puma fur was found clinging to bushes. Several people complained of 'cat-like noises' at night and a businessman on a fishing trip saw the puma up a tree. The experts were now fully convinced that the animal was a puma, but where had it come from ? As no pumas had been reported missing from any zoo in the country, this one must have been in the possession of a private collector and somehow managed to escape. The hunt went on for several weeks, but the puma was not caught. It is disturbing to think that a dangerous wild animal is still at large in the quiet countryside.
06-06
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值