codeforces 630C Lucky Numbers
0.5 seconds
64 megabytes
standard input
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.
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 one integer — the maximum number of offices, than can have unique lucky numbers not longer than n digits.
2
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\n",f[n]);
}
return 0;
}
codeforces 630C Lucky Numbers的更多相关文章
- codeforces 630C - Lucky Numbers 递推思路
630C - Lucky Numbers 题目大意: 给定数字位数,且这个数字只能由7和8组成,问有多少种组合的可能性 思路: 假设为1位,只有7和8:两位的时候,除了77,78,87,88之外还哇哦 ...
- codeforces 244B-Undoubtedly Lucky Numbers 搜索
题意:给你一个n,求不大于n的并且仅由两种或者一种数字组成的数的个数.(有点绕,,简单点就是,看看小于等于n点数中,,有多少数字只有一种数字,或者有两种数字组成) “哎,自己还是太菜了,训练的时候只做 ...
- Codeforces Round #160 (Div. 2)---A. Roma and Lucky Numbers
Roma and Lucky Numbers time limit per test 1 second memory limit per test 256 megabytes input standa ...
- CodeForces 146A Lucky Ticket
Lucky Ticket Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submi ...
- Codeforces 121A Lucky Sum
Lucky Sum Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Origi ...
- 「CF630C」Lucky Numbers
更好的阅读体验 Portal Portal1: Codeforces Portal2: Luogu Description The numbers of all offices in the new ...
- HDU 5676 ztr loves lucky numbers (模拟)
ztr loves lucky numbers 题目链接: http://acm.hust.edu.cn/vjudge/contest/121332#problem/I Description ztr ...
- 数据结构(线段树):CodeForces 145E Lucky Queries
E. Lucky Queries time limit per test 3 seconds memory limit per test 256 megabytes input standard in ...
- hdu 5676 ztr loves lucky numbers(dfs+离线)
Problem Description ztr loves lucky numbers. Everybody knows that positive integers are lucky if the ...
随机推荐
- 1227. Rally Championship
1227 题意木看懂 是可以停在路上 任何地方 水题一枚 以下条件之一满足就可以 有环(并查集判) 重边 自己到自己的边 最长边大于s(用flod改写下) #include <iostream& ...
- sscanf() 和 sprintf()的用法。
因为感觉比较有用. 这几次比赛,用过几次,所以写个程序,总结一下. 如果用sscanf(s, "%d.%d", &a, &b); 的时候,一定要注意是否s里一定有小 ...
- 函数buf_page_address_fold
/********************************************************************//** Calculates a folded value ...
- bzoj2791
每个顶点有且仅有一条出边是什么意思呢 类似一棵树,树上的边都是由儿子指向父亲的,并且这个东西带着一个环 也就是一个个有向环套有向树…… 这题还是比较简单的,把环作为根然后类似lca做即可,注意细节的p ...
- Instruments-查看收集到的数据
由于Xcode调试工具Instruments指南篇幅太长,所以本篇blog继续上篇,介绍对Instruments收集到的数据去分析. 关于数据分析 Instruments不解决你代码中的任何问题,它帮 ...
- sqlserver 导入/导出Excel
--从Excel文件中,导入数据到SQL数据库中,很简单,直接用下面的语句: /*=========================================================== ...
- 监听某个div或其它标签的大小改变来执行相应的处理
jquery 默认的resize只能监听到浏览器窗口大小的改变,但我们在实际使用过程中有可能还需要监听某个div或其它标签的大小改变来执行相应的处理,如果使用默认的resize就无能为力了.怎么办呢, ...
- 物联网操作系统HelloX V1.78测试版正式发布
经过HelloX开发团队近四个月的努力,在HelloX V1.77版本基础上,增加许多功能特性,并对V1.77版本的一些特性进行了进一步优化之后,正式形成HelloX V1.78测试版本,经相对充分的 ...
- directdraw的多画面显示rgb
// showpicDlg.cpp : 实现文件 // #include "stdafx.h" #include "showpic.h" #include &q ...
- [端API] 控件在一个页面里open了,但其他页面打开这个控件怎么关闭
加在控件的参数里<script type="text/javascript" src="../script/api.js"></script& ...