码迷,mamicode.com
首页 > 其他好文 > 详细

Lost number (wild)

时间:2020-10-18 10:17:30      阅读:29      评论:0      收藏:0      [点我收藏+]

标签:script   ace   string   integer   span   some   相等   cstring   ups   

Description


Xiaoqiang wrote a decimal number \(X\), but some of the handwriting has been blurred (we replaced it with ?). Now given another decimal number \(Y\) with the same number of digits, he wants to know how many possibilities make \(X>Y\).

Format


Input

The first line is a positive integer \(t(\leq 100)\), indicating the number of data groups; in each group of data, the first line is a decimal number \(X\) within 16 digits, how many of them ? ; The second line is a decimal number \(Y\) with the same number of digits.

Output

Output the possible number of \(X>Y\).

Sample


Input

1
36?1?8
236428

Output

100

Sample Code


#include <cstdio>
#include <cstring>
typedef long long ll;
ll p10[18]={1};
int main(){
    freopen("wild.in","r",stdin);
    freopen("wild.out","w",stdout);
    for (int i=1; i<18; i++)
        p10[i]=p10[i-1]*10;
    int t;
    scanf("%d", &t);
    while (t--){
        char s[20], v[20];
        scanf("%s", s);
        scanf("%s", v);
        int n=strlen(s), w=0;
        for (int i=0; i<n; i++) 
            if (s[i]==‘?‘) w++;//统计?个数 
        ll ans=0ll;
        for (int i=0; i<n; i++)//分四种情况: 
            if (s[i]==‘?‘)     //1、? 
                ans+=(‘9‘-v[i])*p10[--w];
            else if (s[i]<v[i])//2、< 
                break;
            else if (s[i]>v[i]){//3、> 
                ans+=p10[w];
                break;
            }                   //4、相等,继续 
        printf("%lld\n", ans);
    }
    return 0;
}

Lost number (wild)

标签:script   ace   string   integer   span   some   相等   cstring   ups   

原文地址:https://www.cnblogs.com/jiupinzhimaguan/p/13832986.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!