Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:悬赏Q币喽,谁帮我找出我代码错哪儿了,奖励Q币啦。。。或者给出一些让我错的数据

Posted by RucJan at 2007-10-19 21:10:09 on Problem 3340
In Reply To:悬赏Q币喽,谁帮我找出我代码错哪儿了,奖励Q币啦。。。或者给出一些让我错的数据 Posted by:123454321 at 2007-08-26 23:17:14
> 
> #include <iostream>
> #include <string>
> #include <stdio.h>
> using namespace std;
> 
> string s1,s2;
> int l1;
> string min,max;
> 
> __int64 power(int a,int b)
> {
> 	__int64 result=1;
> 	for(int i=1;i<=b;i++)
> 		result=result*a;
> 	return result;
> }
> int main()
> {
> 	int i;
> 	int n;
> 	while(cin>>s1 && s1!="#")
> 	{
> 		cin>>s2;
> 		n=0; 
> 		l1=s1.length();
> 		for(i=0;i<l1;i++)
> 			if(s1[i]=='?')
> 				n++;
> 
> 		min=s1;
> 		max=s1;
> 	
> 			for(i=0;i<l1;i++)
> 				if(s1[i]=='?')
> 					min[i]='0';
> 			for(i=0;i<l1;i++)
> 				if(s1[i]=='?')
> 					max[i]='9';
> 		
> 		if(max<=s2)
> 			printf("0\n");
> 		else
> 		{
> 			if(min>s2)
> 			{
> 				__int64 sum=0;
> 				for(i=0;i<l1;i++)
> 					if(s1[i]=='?')
> 					{
> 						n--;
> 						sum+=(9-(min[i]-'0'))*power(10,n);
> 					}
> 				sum++;
> 				printf("%I64d\n",sum);
> 			}
> 			else 
> 			{
> 				min=s2;
> 				__int64 sum=0;
> 				for(i=0;i<l1;i++)
> 					if(s1[i]=='?')
> 					{
> 						n--;
> 						sum+=(9-(min[i]-'0'))*power(10,n);
> 					}
> 				printf("%I64d\n",sum);
> 			}
> 		}
> 	}
> 	return 0;
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator