首页 > 其他分享 >UVa 11723 Numbering Roads (water ver.)

UVa 11723 Numbering Roads (water ver.)

时间:2023-04-12 13:06:54浏览次数:62  
标签:integers ver name streets Numbering number water roads suffixes


11723 - Numbering Roads


Time limit: 1.000 seconds

http://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;
}





标签:integers,ver,name,streets,Numbering,number,water,roads,suffixes
From: https://blog.51cto.com/u_5535544/6185476

相关文章

  • UVa 457 Linear Cellular Automata (water ver.)
    457-LinearCellularAutomataTimelimit:3.000secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=show_problem&problem=398AbiologistisexperimentingwithDNAmodificationofbacterialcolonies......
  • UVa 10783 Odd Sum (water ver.)
    10783-OddSumTimelimit:3.000secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=19&page=show_problem&problem=1724Givenarange [a, b],youaretofindthesummationofalltheoddintegersinthisran......
  • sqlserver 使用脚本创建作业 (by me)
    usemastergo--定义创建作业DECLARE@jobiduniqueidentifier,@jobnamesysnameSET@jobname=N'testInterval'IFEXISTS(SELECT*FROMmsdb.dbo.sysjobsWHEREname=@jobname)EXECmsdb.dbo.sp_delete_job@[email protected]_add_job@job_......
  • 【Serverless】云数据库端云一体化问题
     【关键字】AGC、HarmonyOS、端云一体化 【问题描述】开发者反馈在鸿蒙应用集成了AGC云数据库服务,在引入AGC服务时遇到了一些问题。具体如下所述:1、HarmonyOSArkTS语言开发,参数是number类型,但是查询的云数据库字段是Integer类型,这要怎么处理。2、样例中querybook的字段b......
  • SpringBoot 集成 MybatisPlus 六——ActiveRecord 增、删、改
    1向表中插入记录1.1插入所有列在创建实体对象时,指定所有字段的内容,包括ID列。@TestpublicvoidtestAddUser(){Useruser=newUser(20,"成吉思汗","男","一代天骄");booleanres=user.insert();System.out.println(res);}调用MyBatisPlus时,后台执行的......
  • 第九篇 手写原理代码 - 数组 【 实现 forEach、map、filter、every、some 】
    1、forEachArray.prototype.my_forEach=function(callback){for(leti=0;i<this.length;i++){callback(this[i],i,this);}};2、mapArray.prototype.my_map=function(callback){constarr=[];for(leti=0;i<this.length;......
  • 广州大学第十七届ACM大学生程序设计竞赛 L. 因子模仿 - hard version 线段树维护矩阵
    传送门大致思路:  观察发现,茉美香胜利会叠加对手所有状态,茉美香失败会被对手叠加所有状态。我们可以用矩阵[a1,a2,b1,b2]表示两个人的状态(其中a1,a2表示茉美香,b1,b2表示对手)茉美香赢了之后的状态是[a1+b1,a2+b2,b1,b2],茉美香输了之后的状态是[a1,b1,a1+b1,......
  • DBeaver安装与使用教程(超详细安装与使用教程),好用免费的数据库管理工具
    文章原链接http://t.csdn.cn/Jf4QN       ......
  • Docker CLI docker compose convert常用命令
    Docker是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的镜像中,然后发布到任何流行的Linux或Windows操作系统的机器上,也可以实现虚拟化。Docker是内核虚拟化,不使用Hypervisor是不完全虚拟化,依赖内核的特性实现资源隔离。本文主要介绍DockerCLI中d......
  • sql server 复制添加新表失败
    微软官方对sp_addarticle的解释:Whenyoupublishobjects,theirdefinitionsarecopiedtoSubscribers.Ifyouarepublishingadatabaseobjectthatdependsononeormoreotherobjects,youmustpublishallreferencedobjects.Forexample,ifyoupublishavi......