zoukankan      html  css  js  c++  java
  • codeforces 630C Lucky Numbers

    C. Lucky Numbers
    time limit per test
    0.5 seconds
    memory limit per test
    64 megabytes
    input
    standard input
    output
    standard output

    The numbers of all offices in the new building of the Tax Office of IT City will have lucky numbers.

    Lucky number is a number that consists of digits 7 and 8 only. Find the maximum number of offices in the new building of the Tax Office given that a door-plate can hold a number not longer than n digits.

    Input

    The only line of input contains one integer n (1 ≤ n ≤ 55) — the maximum length of a number that a door-plate can hold.

    Output

    Output one integer — the maximum number of offices, than can have unique lucky numbers not longer than n digits.

    Examples
    input
    2
    output
    6

     题意:所有只有7或者只有8,或者只有7和8组成的数成为幸运数,给你一个n表示最多有n位的数,现在问你在这n位数之内有多少个幸运数

    题解:当n为1时幸运数是7和8当n为两位数时,两位的数中有77,78,88,87,我们可以发现,这是对7和8在n个位置上进行组合数排列n位数是

    (只说n位数的幸运数个数)是c1(2,1)*c2(2,1)*...*cn(2,1)     n位数时所有的幸运数个数就是一位数是幸运数个数加上两位数时幸运数个数+...+n位数是幸运数个数   打表储存

    #include<stdio.h>    //codeforce   c
    #include<string.h>
    #include<stdlib.h>
    #include<algorithm>
    #include<math.h>
    #include<queue>
    #include<stack>
    #define INF 0x3f3f3f
    #define MAX 100100
    #define LL long long
    using namespace std;
    LL f[MAX];
    void biao()
    {
    	f[1]=2;
    	f[2]=6;
    	for(int i=3;i<=55;i++)
    		f[i]=f[i-1]+pow(2,i);
    }
    int main()
    {
    	int i,j,n,m;
    	biao();
        while(scanf("%d",&n)!=EOF)
        {
        	printf("%lld
    ",f[n]);  	
        }
    	return 0;
    }
    

      

  • 相关阅读:
    ESP32 SDA和SCL
    ESP32的HSPI和VSPI区别
    ffmpeg生成视频封面图
    小程序读取几种不同格式json数据(小程序json解析)
    ajax
    使用Java语言,连接linux服务器,并远程执行shell 脚本
    Echarts饼图的使用
    js提取对象数组中的某一个属性
    java读取文件推送报文
    java读取本地文件内容TXT文件
  • 原文地址:https://www.cnblogs.com/tonghao/p/5202153.html
Copyright © 2011-2022 走看看