• Codeforces--630I--Parking Lot(规律)


    
    I - Parking Lot

    Crawling in process... Crawling failed Time Limit:500MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

    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

    Sample Output

    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.

    2*n-2个停车位,4种类型的车,n辆同一类型的A车要停在一起,旁边也不能是同一类型的A,问有多少种方法

    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<algorithm>
    using namespace std;
    int main()
    {
    	int n;
    	while(scanf("%d",&n)!=EOF)
    	{
    		__int64 a=3*n-1;
    		__int64 aa=n-3;
    		__int64 ans=a*3*pow(4,aa);
    		printf("%lld
    ",ans);
    	}
    	return 0;
    }

  • 相关阅读:
    DS博客作业03--树
    DS博客作业02--栈和队列
    DS博客作业01--线性表
    C语言博客作业05--指针
    C语言博客作业04--数组
    C语言博客作业03--函数
    DS博客作业05--查找
    DS博客作业04--图
    DS博客作业02--栈和队列
    C博客作业05-指针
  • 原文地址:https://www.cnblogs.com/playboy307/p/5273403.html
Copyright © 2020-2023  润新知