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 |
WA到死了···帮我看看,有注释!#include <iostream> #include <cstdio> #include <cstring> using namespace std; __int64 res; char s1[1000]; char s2[1000]; int flag; int len; __int64 dfs(int t,int cnt,int k) //k代表当前的大小关系 K=0表示等于 k=1表示s1大于s2 初始化为k=0 { if(t==len) { res = cnt; return res; } if(k==0) //若前面相等 { if(s1[t]!='?') { if(s1[t]<s2[t]) //当前小于,无解 return 0; if(s1[t]>s2[t]) //当前大于,保留结果向后递归 ,更改为大于 return dfs(t+1,cnt,1); if(s1[t]==s2[t]) //当前等于,保留结果向后递归 ,更改为等于 return dfs(t+1,cnt,0); } else if(s1[t]=='?') return dfs(t+1,((cnt==0)?1:cnt)*(9-s2[t]+'0'),1) + dfs(t+1,cnt,0); } if(k==1) //若前面s1大于s2 { if(s1[t] !='?') return dfs(t+1,cnt,1); else return dfs(t+1,((cnt==0)?1:cnt)*10,1); } } int main() { while(1) { scanf("%s",s1); if(!strcmp(s1,"#")) break; scanf("%s",s2); len = strlen(s2); res = dfs(0,0,0); printf("%I64d\n",res); } system("pause"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator