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 ...
随机推荐
- [POJ3177]Redundant Paths(双连通图,割边,桥,重边)
题目链接:http://poj.org/problem?id=3177 和上一题一样,只是有重边. 如何解决重边的问题? 1. 构造图G时把重边也考虑进来,然后在划分边双连通分量时先把桥删去,再划分 ...
- c# webbrowser 随机点击链接 2
找到广告代码所在的div或table ,然后用WebBrowser执行js去点这个div(或table) 那个广告是js实现的,你浏览的时候是看不到图片和连接的,请问各位大虾应该怎么实现?给点思路.. ...
- Ural1076(km算法)
题目大意 给出n*n表格,第a[i,j]表示i到j的权值,现在我们要将每个a[i,j]=sum[j]-a[i,j], 求出当前二分图a[][]最小匹配 最小匹配只需将权值取负后,求二分图最大匹配,使用 ...
- android开发中eclipse里xml开发的自动提示和使用帮助快捷键提示
Eclipse Android 代码自动提示功能 Eclipse for android 设置代码提示功能 打 开 Eclipse 依次选择 Window > Preferences > ...
- php yii框架使用MongoDb
1.安装 运行 php composer.phar require --prefer-dist yiisoft/yii2-mongodb or add "yiisoft/yii2-mongo ...
- UVA 1001 Say Cheese 奶酪里的老鼠(最短路,floyd)
题意:一只母老鼠想要找到她的公老鼠玩具(cqww?),而玩具就丢在一个广阔的3维空间(其实可以想象成平面)上某个点,而母老鼠在另一个点,她可以直接走到达玩具的位置,但是耗时是所走过的欧几里得距离*10 ...
- LeetCode: 3SumClosest
Title : Given an array S of n integers, find three integers in S such that the sum is closest to a g ...
- LeetCode: Interval
(1)Merge Intervals https://leetcode.com/problems/merge-intervals/ Given a collection of intervals, m ...
- Mysqlbackup 备份详解(mysql官方备份工具)
A.1全库备份. 命令: mysqlbackup --defaults-file=/home/mysql-server/mysql3/my.cnf --user=root --password=ro ...
- 【Mysql】安装 mysql-5.7.5 指南
因为同学需要安装mysql,安装过程,一路百度,在这里记录一下步奏.以后还会用到. 1.mysql-5.7.5-m15-winx64.zip下载 官方网站下载地址:http://cdn.mysql.c ...