HDU 2410 Barbara Bennett's Wild Numbers (想法题)

题目链接:HDU 2410 Barbara Bennett‘s Wild Numbers

题意:给出两串数w,s(长度同样),第一串中有“?”,问“?”取的值使w相应的数大于s相应的数 的最慷慨案数。

思路:W,S一一相应比較;

遇到第一个’?‘之前比較情况

1.w[i]<s[i] 方案数0种;break;

2.w[i]>s[i] break。

之后有n个‘’?‘ 方案数就有10的n次方种。

3.w[i]=s[i] 继续比較。反复1.2两个条件。

遇到’?‘

1.能取数个数是 ’9‘-x[i]。

之后10的n次方。

2.取等于x[i] ,继续比較。

AC代码:

#include<stdio.h>
#include<string.h>
char w[20],x[20];
int get(int i,int temp,int len)
{
    int j;
    for(j=i+1; j<len; j++)
    {
        if(w[j]==‘?

‘)
            temp*=10;
    }
    return temp;
}

int main()
{
    int len,i,j;
    while(scanf("%s",w)!=EOF)
    {
        if(strcmp(w,"#")==0)
            break;
        scanf("%s",x);
        len=strlen(w);
        int ans=0;
        for(i=0; i<len; i++)
        {
            if(w[i]==‘?‘)
                ans+=get(i,‘9‘-x[i],len);
            else
            {
                if(w[i]==x[i])
                    continue;
                if(w[i]>x[i])
                    ans+=get(i,1,len);
                break;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}
/*
12?

4?
12354
12?5?

12354
*/

HDU 2410 Barbara Bennett's Wild Numbers (想法题)

时间: 2024-09-30 18:10:06

HDU 2410 Barbara Bennett&#39;s Wild Numbers (想法题)的相关文章

POJ 3340 &amp; HDU 2410 Barbara Bennett&#39;s Wild Numbers(数学)

题目链接: PKU:http://poj.org/problem?id=3340 HDU:http://acm.hdu.edu.cn/showproblem.php?pid=2410 Description A wild number is a string containing digits and question marks (like 36?1?8). A number X matches a wild number W if they have the same length, and

HDU 2410 Barbara Bennett&#39;s Wild Numbers (想法题)

题目链接:HDU 2410 Barbara Bennett's Wild Numbers 题意:给出两串数w,s(长度相同),第一串中有"?",问"?"取的值使w对应的数大于s对应的数 的最大方案数. 思路:W,S一一对应比较: 遇到第一个'?'之前比较情况 1.w[i]<s[i] 方案数0种:break: 2.w[i]>s[i] break.之后有n个''?' 方案数就有10的n次方种. 3.w[i]=s[i] 继续比较,重复1.2两个条件. 遇到'?

poj 3340 Barbara Bennett&#39;s Wild Numbers(数位DP)

Barbara Bennett's Wild Numbers Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 3153   Accepted: 1143 Description A wild number is a string containing digits and question marks (like 36?1?8). A number X matches a wild number W if they hav

Print Article hdu 3507 一道斜率优化DP 表示是基础题,但对我来说很难

Print Article Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 4990    Accepted Submission(s): 1509 Problem Description Zero has an old printer that doesn't work well sometimes. As it is antique

POJ 2411 &amp;&amp; HDU 1400 Mondriaan&#39;s Dream (状压dp 经典题)

Mondriaan's Dream Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 12341   Accepted: 7204 Description Squares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One night, after producing the drawings in his 'toilet series

hdu 5288||2015多校联合第一场1001题

http://acm.hdu.edu.cn/showproblem.php?pid=5288 Problem Description OO has got a array A of size n ,defined a function f(l,r) represent the number of i (l<=i<=r) , that there's no j(l<=j<=r,j<>i) satisfy ai mod aj=0,now OO want to know ∑i

HDU 2966 Aragorn&#39;s Story 树链剖分第一题 基础题

Problem Description Our protagonist is the handsome human prince Aragorn comes from The Lord of the Rings. One day Aragorn finds a lot of enemies who want to invade his kingdom. As Aragorn knows, the enemy has N camps out of his kingdom and M edges c

HDU 4772 Zhuge Liang&#39;s Password (简单模拟题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4772 题面: Zhuge Liang's Password Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1404    Accepted Submission(s): 926 Problem Description In the anc

HDU 4028 The time of a day STL 模拟题

暴力出奇迹.. #include<stdio.h> #include<iostream> #include<algorithm> #include<vector> #include<cmath> #include<queue> #include<set> #include<map> using namespace std; #define ll __int64 #define N 42 ll n,m,ans;