UVa 11723 Numbering Roads (water ver.)
来源:互联网 发布:拼人脸五官的软件 编辑:程序博客网 时间:2024/06/10 02:22
11723 - Numbering Roads
Time limit: 1.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2823
In my country, streets don’t have names, each of them are just given a number as name. These numbers are supposed to be unique but that is not always the case. The local government allocates some integers to name the roads and in many case the number of integers allocated is less that the total number of roads. In that case to make road names unique some single character suffixes are used. So roads are named as 1, 2, 3, 1A, 2B, 3C etc. Of course the number of suffixes is also always limited to 26 (A, B, …, Z). For example if there are 4 roads and 2 different integers are allocated for naming then some possible assignments of names can be:
1, 2, 1A, 2B
1, 2, 1A, 2C
3, 4, 3A, 4A
1, 2, 1B, 1C
Given the number of roads (R) and the numbers of integers allocated for naming (N), your job is to determine minimum how many different suffixes will be required (of all possible namings) to name the streets assuming that no two streets can have same names.
Input
The input file can contain up to 10002 lines of inputs. Each line contains two integers R and N (0<N,R<10001). Here R is the total number of streets to be named and N denotes number integers allocated for naming.
Output
For each line of input produce one line of output. This line contains the serial of output followed by an integer D which denotes the minimum number of suffixes required to name the streets. If it is not possible to name all the streets print “impossible” instead (without the quotes).
Sample Input Output for Sample Input
8 5
100 2
0 0
Case 1: 1
Case 2: impossible
完整代码:
/*0.019s*/#include<cstdio>int main(){int r, n, cas = 0, temp;while (scanf("%d%d", &r, &n), r){printf("Case %d: ", ++cas);temp = (r - 1) / n;if (temp <= 26) printf("%d\n", temp);else puts("impossible");}return 0;}
- UVa 11723 Numbering Roads (water ver.)
- UVa 11723 - Numbering Roads
- UVa 10082 WERTYU (water ver.)
- UVa 10696 f91 (water ver.)
- UVa 79 ClockHands (water ver.)
- UVa 11340 Newspaper (water ver.)
- UVa 514 Rails (water ver.)
- UVa 11150 Cola (water ver.)
- UVa 10300 Ecological Premium (water ver.)
- UVa 414 Machined Surfaces (water ver.)
- UVa 490 Rotating Sentences (water ver.)
- UVa 445 Marvelous Mazes (water ver.)
- UVa 488 Triangle Wave (water ver.)
- UVa 10783 Odd Sum (water ver.)
- UVa 457 Linear Cellular Automata (water ver.)
- UVa 621 Secret Research (water ver.)
- UVa 11044 Searching for Nessy (water ver.)
- UVa 102 Ecological Bin Packing (water ver.)
- Android 之 内存管理
- Java工具类之System(一)
- HDU 4701 Game
- 延时渲染(Deferred Shading)
- c++子类和父类成员函数重名
- UVa 11723 Numbering Roads (water ver.)
- Windows Socket programming 2
- hdu4292 Food (ISAP算法)
- Android简单、快速的网络库: Volley ( Google IO 2013 )
- Java工具类之Pattern和Matcher(一)
- VC++实现简单HTTP服务器
- hdu3980 Paint Chain
- C/C++ 程序设计员应聘常见面试试题
- 2013 ACM/ICPC Asia Regional Changchun Online (2013网络赛)