博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
How Many Roads?
阅读量:6580 次
发布时间:2019-06-24

本文共 1596 字,大约阅读时间需要 5 分钟。

1005: 【2012四川省热身赛】Problem B. How Many Roads?

Time Limit: 1 Sec  Memory Limit: 32 MB

Description

As a director of cities transportation construction, Elfness is given a mission to connect n cities by
a lot of roads. Of course, the more roads to be built, the more convenient it would be. But if there
are two roads cross each other, traffic accidents may happen. So it means on Elfness’s ACM(All
Cities’ Map), there are no cross roads. And now, Elfness wants to know how many roads can be
built at most(Attention: a road won’t have to be a segment, it can be a straight line or a ray)?

Input

The first line of input is a single number T(T < 1000),means the number of test cases.Then T
cases followed, each case contains only one line with a single number n(0 < n ≤ 10
8),the number
of cities.

Output

For each test case,you should output one line. First, output “Case #t: ”, t means the number
of the test case which is from 1 to T. Then, output an integer indicates the maximal number of
roads can be built.

Sample Input

3
1
2
3

Sample Output

Case #1: 0
Case #2: 1
Case #3: 3

HINT

Source

当城市等于4个的时候,就比3个城市的时候多三条路

当城市等于5个的时候,就比4个城市的时候多三条路

依次类推

#include
int main(){ int n,m,i,t=1; scanf("%d",&n); while(n--) { scanf("%d",&m); if(m>0&&m<=100000000) { if(m==1) printf("Case #%d: %d\n",t++,0); else if(m>1&&m<=3) printf("Case #%d: %d\n",t++,2*m-3); else printf("Case #%d: %d\n",t++,(m-2)*3); } } return 0;}

 

转载于:https://www.cnblogs.com/tianmin123/p/4734898.html

你可能感兴趣的文章
盘点2012年应用交付网络 谈2013年网络技术趋势(2)
查看>>
36插件化开发_slots_radd
查看>>
38线程1-Thread-local-Timer
查看>>
CentOS 6.5使用 安装ansible
查看>>
为Exchange server 2013 申请多域名证书
查看>>
处理svn的 File '/aa' is out of date
查看>>
解决 Ubuntu 16.04 LTSSublime text3中文问题
查看>>
阿里云自定义监控tomcat进程数
查看>>
Python之Win字符编码详解
查看>>
为什么微服务一定要有网关?
查看>>
Linux练习题-文本处理工具sed
查看>>
十个你可能知道,但容易错的PCB设计。
查看>>
Python网络爬虫是什么?学完Python后可以从事什么职业
查看>>
如何在Linux 中获取硬盘分区或文件系统的UUID?
查看>>
Jmeter + Grafana搭建实时监控可视化
查看>>
互联网创业之门 — 设计师。
查看>>
MySQL高性能优化规范建议
查看>>
在XP和win7上添加UltraEdit到鼠标右键菜单
查看>>
不要让临时表空间影响Oracle数据库性能
查看>>
我的友情链接
查看>>