题意:

有一种数只会有7或者8构成,给一个n,问你前n位上有多少个这样的数。

思路:

对于一个 i 位,有2^i个数,然后前n项和就是2^(n+1)-2;

复习一下等比数列求和,等差数列求和吧;

①:等差数列;

首项: a; 公差: d; 第n项: a+(n-1)d; 前n项和: (a+a+(n-1)d)n/2=na+nd(n-1)/2;

②:等比数列;

首项: a; 公比: d; 第n项: ad^(n-1); 前n项和: (a-aq^n)/(1-d);

贴一发挫code…..

#include<iostream>
#include<cstdio>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define eps 1e-8
typedef __int64 LL;
int main()
{
int n;
scanf("%d",&n);
printf("%I64d",(1LL<<(n+1))-2);
return 0;
}

Codeforces630C【水题】的更多相关文章

  1. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  2. ACM :漫漫上学路 -DP -水题

    CSU 1772 漫漫上学路 Time Limit: 1000MS   Memory Limit: 131072KB   64bit IO Format: %lld & %llu Submit ...

  3. ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)

    1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 154  Solved: 112[ ...

  4. [poj2247] Humble Numbers (DP水题)

    DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...

  5. gdutcode 1195: 相信我这是水题 GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,

    1195: 相信我这是水题 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 821  Solved: 219 Description GDUT中有个风云人 ...

  6. BZOJ 1303 CQOI2009 中位数图 水题

    1303: [CQOI2009]中位数图 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 2340  Solved: 1464[Submit][Statu ...

  7. 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题

    B - 大还是小? Time Limit:5000MS     Memory Limit:65535KB     64bit IO Format: Description 输入两个实数,判断第一个数大 ...

  8. ACM水题

    ACM小白...非常费劲儿的学习中,我觉得目前我能做出来的都可以划分在水题的范围中...不断做,不断总结,随时更新 POJ: 1004 Financial Management 求平均值 杭电OJ: ...

  9. CF451C Predict Outcome of the Game 水题

    Codeforces Round #258 (Div. 2) Predict Outcome of the Game C. Predict Outcome of the Game time limit ...

  10. CF451B Sort the Array 水题

    Codeforces Round #258 (Div. 2) Sort the Array B. Sort the Array time limit per test 1 second memory ...

随机推荐

  1. ``Accordian&#39;&#39; Patience

    ``Accordian'' Patience  You are to simulate the playing of games of ``Accordian'' patience, the rule ...

  2. LINQ解决依据某个字段去重

    想要List结果反复 的数据非常easy.仅仅要.Dinstinct()就好了 可是假设想要依据某个字段去除反复的数据,上面的方法就帮不上忙了.我们须要重写一个方法.直接上样例吧 [Serializa ...

  3. 阿里云serverMySQL无法连接问题解决纪实

    作者:fbysss QQ:溜酒酒吧酒吧吾散 blog:blog.csdn.net/fbysss 声明:本文由fbysss原创,转载请注明出处 背景: 在调试程序的时候,发现数据库訪问相关的环节出现错误 ...

  4. Linux安装Axis C构建WebService服务

    在安装Axis C++之前有两个组件是必须安装的,分别是Apache HTTP Server以及用于处理XML的程序Xerces:为了编译Axis以及Apache HTTPD,你的Linux机器还应该 ...

  5. Android研究之游戏开发摄像头更新

     游戏中摄像头的原理介绍        在游戏开发中更新摄像头的位置能够决定屏幕显示的内容,尤其是RPG类游戏摄像头有着很关键的数据.我举一个样例 有时候我们在玩RPG游戏的时候进入一个新的场景 ...

  6. adb pull 与 push

    adb pull <remote> <local> Copies a specified file from an emulator/device instance to yo ...

  7. HDU 6086 Rikka with String AC自动机 + DP

    Rikka with String Problem Description As we know, Rikka is poor at math. Yuta is worrying about this ...

  8. Microsoft.XMLHTTP基本用法

    客户端调用XMLHTTP的过程很简单,只有5个步骤:1.创建XMLHTTP对象2.打开与服务端的连接,同时定义指令发送方式,服务网页(URL)和请求权限等.客户端通过Open命令打开与服务端的服务网页 ...

  9. codeforces 696B B. Puzzles(树形dp+概率)

    题目链接: B. Puzzles time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  10. UIFont 字体样式 [UIFont fontWithName~];

    设置字体样式代码:[UIFont fontWithName:@"Arial-BoldMT" size:15] 下边一一列举: 一:Font Family: American Typ ...