江苏省首届大学生程序设计大赛赛题及解答(二)——Cow Counting

这只是模拟acm的比赛。模式都是照acm的。当然和真正的acm还是很有差距的。acm的比赛什么题都有,而这次的比赛仅涉及算法问题。

即使如此在比赛的时候还是吃力的很。毕竟大家都没有在这种状况下进行编程:在五个小时内三人用一台电脑搞定十题。尤其南大的队伍坐在咱后面,开始比赛后一两分钟就把第一题搞定了(当然不是上篇我贴的题目,我先贴的是练习赛三题)。此后题目基本上是十分钟搞定一题的。键盘敲的劈里啪啦的,就没停过,跟聊QQ似的,听的我心里慌慌的……

最后是复旦大学第一是搞定8题,南大第二是7题……

---------------------------------------------------------

Problem B

Cow counting

Input File:count.in

Time: 1s Memory: No limitations

Description

Farmer John wants to labeled his N(1<=N<=1000) cows, but cows don’t like having the digit L(0<=L<=9) written on them, so he avoids that.

If the cows are labeled with smallest set of N positive integers that don’t have the digital L, what is the largest number that Farmer John has to write on any cow?

Input

The input file contains multiple test cases. Every test case have two positive integers N,L.

Proceed to the end of the input file.

Output

For each case, output a single integer that is the largest number that Farmer John has to write on any cow. Please output as the format in the Sample Output.

Sample Input

8 1

9 1

10 1

Sample Output

9

20

22

Code list:

// cowcounting.cpp : Defines the entry point for the console application.
//

#include 
#include 

using namespace std;

int main()
{
	int N,L,i,counter;
	char temp[5],num;

	ifstream fin("count.in");
	if(!fin)
	{
		cerr<<"error: unable to open input file: count.in"<
            
            

            

Shawn Xie

Read more posts by this author.