zoukankan      html  css  js  c++  java
  • Wild Number (Standard IO)

    题意/Description:

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

     

    读入/Input

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

     

    输出/Output

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

     

    题解/solution

           第一,这是一个数,只要第一位数大(题目说位数相同),这个数肯定大,即后面的“?”随便取。第一位数相同,后面的数字大,这数大。......然后看程序吧。

           点赞,点赞,点赞,点赞,点赞,点赞,点赞

     

    代码/Code

    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;
      for i:=1 to l do
        if s1[i]='?' then inc(k);
      b:=true;
      for i:=1 to l do
        if s1[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 not b then writeln(ans+1)
               else writeln(ans);
    end.



  • 相关阅读:
    Docker服务启动报错:Job for docker.service failed because the control process exited with error code.
    mysql忘记密码如何重置及修改密码
    linux下的/opt目录作用
    linux防火墙查看状态firewall、iptable
    nmap基本使用方法
    HTTP响应码大全
    端口镜像
    查看占用端口
    restful规范 APIview 解析器组件 Postman
    状态码301和302的区别
  • 原文地址:https://www.cnblogs.com/zyx-crying/p/9319649.html
Copyright © 2011-2022 走看看