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 ...
随机推荐
- UVa 1400 (线段树) "Ray, Pass me the dishes!"
求一个区间的最大连续子序列,基本想法就是分治,这段子序列可能在区间的左半边,也可能在区间的右半边,也有可能是横跨区间中点,这样就是左子区间的最大后缀加上右子区间的最大前缀之和. 线段树维护三个信息:区 ...
- LA 5059 (找规律 SG函数) Playing With Stones
题意: 有n堆石子,两个人轮流取,每次只能取一堆的至少一个至多一半石子,直到不能取为止. 判断先手是否必胜. 分析: 本题的关键就是求SG函数,可是直接分析又不太好分析,于是乎找规律. 经过一番“巧妙 ...
- 用Java Servlets代替CGI
从网络的早期阶段开始,人们就希望他们的网络服务器不仅能够显示静态文档,通用网关接口(CGI) 扩展了服务器的能力,但其代价是增加了额外的处理进程.FastCGI则把外部CGI 处理进程同网络服务器更紧 ...
- Brew 编译mod错误Error: L6265E: Non-RWPI Section libspace.o(.bss) cannot be assigned to PI Exec region ER_ZI
Error: L6265E: Non-RWPI Section libspace.o(.bss) cannot be assigned to PI Exec region ER_ZI.: Error: ...
- ffmpeg+rtsp+dss
1. push stream to dss ffmpeg -f mpegts -re -i film.v -c:v libx264 -s 352x288 -aspect 4:3 -b:v 300k - ...
- ORACLE RAC 监听配置 (listener.ora tnsnames.ora)
Oracle RAC 监听器的配置与单实例稍有不同,但原理和实现方法基本上是相同的.在Oracle中 tns进程用于为指定网络地址上的一个或多个Oracle 实例提供服务注册,并响应来自客户端对该服务 ...
- HTML5之video元素
一.video元素支持的视频格式 HTML5中的video标签支持3种常用的视频格式: 1.Ogg = 带有Theora 视频编码和Vorbis 音频编码的 Ogg 文件: 2.MPEG4 = 带有H ...
- wap版和pc版的旋转js
<script type="text/javascript"> var evt = "onorientationchange" in window ...
- delphi中计算指定日期是该月第几周的函数
NthDayOfWeek 计算并返回指定日期是该月第几周 Unit:DateUtils function NthDayOfWeek(const AValue: TDateTime): Word; ...
- Oracle 课程三之表设计
完成本课程的学习后,您应该能够: •普通堆表优点和缺点 •理解rowid •全局临时表优点.缺点和适用场景 •分区表的类型和原理.优点和缺点.适用场景 •表字段的高效设计 •sequence的设计 ...