CodeForces - 630I Parking Lot (数学排列组合)
2016-03-09 11:12
627 查看
CodeForces - 630I Parking Lot
Description To quickly hire highly skilled specialists one of the new IT City companies made an unprecedented move. Every employee was granted a car, and an employee can choose one of four different car makes. The parking lot before the office consists of one line of (2n - 2) parking spaces. Unfortunately the total number of cars is greater than the parking lot capacity. Furthermore even amount of cars of each make is greater than the amount of parking spaces! That's why there are no free spaces on the parking lot ever. Looking on the straight line of cars the company CEO thought that parking lot would be more beautiful if it contained exactly n successive cars of the same make. Help the CEO determine the number of ways to fill the parking lot this way. Input The only line of the input contains one integer n (3 ≤ n ≤ 30) — the amount of successive cars of the same make. Output Output one integer — the number of ways to fill the parking lot by cars of four makes using the described way. Sample Input Input 3 Output 24 Hint Let's denote car makes in the following way: A — Aston Martin, B — Bentley, M — Mercedes-Maybach, Z — Zaporozhets. For n = 3 there are the following appropriate ways to fill the parking lot: AAAB AAAM AAAZ ABBB AMMM AZZZ BBBA BBBM BBBZ BAAA BMMM BZZZ MMMA MMMB MMMZ MAAA MBBB MZZZ ZZZA ZZZB ZZZM ZAAA ZBBB ZMMM Originally it was planned to grant sport cars of Ferrari, Lamborghini, Maserati and Bugatti makes but this idea was renounced because it is impossible to drive these cars having small road clearance on the worn-down roads of IT City. Source Experimental Educational Round: VolBIT Formulas Blitz //题意:公司总共有四种类型的车 给你一个n,有2*n-2个停车位,经理要求要有n辆车为同一种类型的车连在一起,问总共有几种排列方法。 //思路: 没什么技巧,就是举几个例子找规律。 比如n=4,情况数为:4*3*4+3*4*3+4*3*4。 多列几种数据可以找到规律sum=(3*n-1)*3*4^(n-3)。 #include<stdio.h> #include<string.h> #include<math.h> #include<algorithm> #define INF 0x3f3f3f3f #define ll long long #define N 10010 #define M 1000000007 using namespace std; int main() { int n; while(scanf("%d",&n)!=EOF) { int m=3*n-1; int nn=n-3; ll sum=m*3*pow(4,nn); printf("%lld\n",sum); } return 0; } Submit Status |
相关文章推荐
- cmd命令以及window环境的端口转发例子
- weblogic下更改jsp不生效的解决办法
- Android文本输入框EditText的属性和方法
- WebPack系列教程(六):使用LOADERS
- 欧拉项目第五题 Smallest multiple
- Servlet3.0---异步支持
- 使用C#和.NET 4编写的并行应用程序“多核并发编程的规则”
- java.net.ConnectException: Connection refused
- 【OpenStack】OpenStack系列14之Dashboard定制开发
- jQuery实时刷新显示数据
- JS中常用正则表达式整理
- TCP/IP详解学习笔记
- 正确理解 ThreadLocal 的原理与应用场景
- Linux环境编程
- GCD 用法查询
- **在布局文件中设置Button的点击事件,代码中方法要传入View的原因分析**
- python 上传下载文件
- 学习进度条
- 学习进度条
- Android - 事件传递机制