比赛 20150711暑期B班 评测结果 AAAAAAAAAA
题目名称 计数问题 最终得分 100
用户昵称 Aeons 运行时间 0.113 s
代码语言 C++ 内存使用 38.46 MiB
提交时间 2015-07-11 09:07:02
显示代码纯文本
#include <fstream>
using namespace std;
int a[10]={0,1,2,3,4,5,6,7,8,9},b[10000001];
ifstream fin("count2013.in");
ofstream fout("count2013.out");
int main()
{
	int n,x,jishu=0,i;
	fin>>n>>x;
	for(i=1;i<=n;i++)
	{
		b[i]=i;
		if(b[i]<10)
		{
			if(b[i]==x)
				jishu++;
		}
		if(b[i]>=10 && b[i]<=99)
		{
			if(b[i]%10==x)
				jishu++;
			if(b[i]/10==x)
				jishu++;
		}
		if(b[i]>=100 && b[i]<=999)
		{
			if(b[i]%10==x)
				jishu++;
			if((b[i]%100-b[i]%10)/10==x)
				jishu++;
			if(b[i]/100==x)
				jishu++;
		}
		if(b[i]>=1000 && b[i]<=9999)
		{
			if(b[i]%10==x)
				jishu++;
			if((b[i]%100-b[i]%10)/10==x)
				jishu++;
			if((b[i]%1000-b[i]%100)/100==x)
				jishu++;
			if(b[i]/1000==x)
				jishu++;
		}
		if(b[i]>=10000 && b[i]<=99999)
		{
			if(b[i]%10==x)
				jishu++;
			if((b[i]%100-b[i]%10)/10==x)
				jishu++;
			if((b[i]%1000-b[i]%100)/100==x)
				jishu++;
			if((b[i]%10000-b[i]%1000)/1000==x)
				jishu++;
			if(b[i]/10000==x)
				jishu++;
		}
		if(b[i]>=100000 && b[i]<=999999)
		{
			if(b[i]%10==x)
				jishu++;
			if((b[i]%100-b[i]%10)/10==x)
				jishu++;
			if((b[i]%1000-b[i]%100)/100==x)
				jishu++;
			if((b[i]%10000-b[i]%1000)/1000==x)
				jishu++;
			if((b[i]%100000-b[i]%10000)/10000==x)
				jishu++;
			if(b[i]/100000==x)
				jishu++;
		}
		if(b[i]==1000000)
		{		
			if(b[i]%10==x)
				jishu++;
			if((b[i]%100-b[i]%10)/10==x)
				jishu++;
			if((b[i]%1000-b[i]%100)/100==x)
				jishu++;
			if((b[i]%10000-b[i]%1000)/1000==x)
				jishu++;
			if((b[i]%100000-b[i]%10000)/10000==x)
				jishu++;
			if((b[i]%1000000-b[i]%100000)/100000==x)
				jishu++;
			if(b[i]/1000000==x)
				jishu++;
		}
	}
	fout<<jishu<<endl;
	fin.close();
	fout.close();
	return 0;
}