Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
简单#include<stdio.h> #include<string.h> char s1[100]="36?1?8"; char s2[100]="236428"; int num[100]; int ans; int length; /* 23??3?9 2341723 */ power(int n) { int a; int sum=1; for(a=1;a<=n;a++)sum*=10; return sum; } fun(int n) { if(n==length)return; if(s1[n]!='?') { if(s1[n]>s2[n]){ans+=power(num[n]); } else if(s1[n]==s2[n]){ fun(n+1); } else { } } else { ans+=('9'-s2[n])*power(num[n]); fun(n+1); }; } int main() {int a; while(gets(s1),strcmp(s1,"#")!=0) { gets(s2); length=strlen(s1); num[length-1]=0; for(a=length-2;a>=0;a--) num[a]=num[a+1]+(s1[a+1]=='?') ; ans=0; fun(0); printf("%d\n",ans); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator