题目

最近比赛的题目好多签到题都是找规律的考验智商的题目啊,,,我怎么越来越笨了,,,,

通过列举,可以发现规律:

从左往右按位扫这个数:

当数的长度大于1时:

当首位大于3时,答案就是4*4*4*……*4*3(即pow(4,后面的长度-1)*3);

否则,则是 首位的数字*4*4*4*……*4*3;

当数的长度为1时,并且之前的(即其他的)都没有进位,则直接判断一下ans要加多少个;

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
__int64 n ,ans;
char s[]; int main()
{
while(scanf("%s",s)!=EOF)
{
ans=;
int len=strlen(s);
int i=;
int flag=;
while(len>)
{
if(s[i]>''){ans=ans+pow(,len-)*;i++;flag=;break;}
ans=ans+(s[i]-'')*pow(,len-)*;
len--;i++;
}
if(flag){
if(s[i]>'')ans+=;
else ans+=(s[i]-'');
}
printf("%I64d\n",ans);
} return ;
}

HDU 2451 Simple Addition Expression(找规律,考验智商)的更多相关文章

  1. 组合数学第一发 hdu 2451 Simple Addition Expression

    hdu 2451 Simple Addition Expression Problem Description A luxury yacht with 100 passengers on board ...

  2. HDU 2451 Simple Addition Expression(组合数学)

    主题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2451 Problem Description A luxury yacht with 100 pass ...

  3. HDU 2451 Simple Addition Expression

    题目大意:有一个关于 简单加法表达式  的定义告诉你,就是  选一个数字i  如果 i+(i+1)+(i+2) 它的和,没有任何一位进位的话,那就是 一个i的简单加法表达式,求小于n的表达式数目. 题 ...

  4. hdu 2451 Simple Addition Expression(数位DP )成败在于细节

    亚洲区域赛的题,简单的数位DP题,注重细节. 任何细节都有可能导致wa,所以没有绝对的水题. 把握好细节,此题便A. #include<stdio.h> __int64 getans(__ ...

  5. 【HDOJ】2451 Simple Addition Expression

    递推,但是要注意细节.题目的意思,就是求s(x) = i+(i+1)+(i+2),i<n.该表达中计算过程中CA恒为0(包括中间值)的情况.根据所求可推得.1-10: 31-100: 3*41- ...

  6. 【计数】Simple Addition Expression

    [来源] 2008年哈尔滨区域赛 [题目链接]: http://acm.hdu.edu.cn/showproblem.php?pid=2451 [参考博客]: HDU 2451 Simple Addi ...

  7. HDU2451:Simple Addition Expression

    Problem Description A luxury yacht with 100 passengers on board is sailing on the sea in the twiligh ...

  8. HDU 3032 multi-sg 打表找规律

    普通NIM规则加上一条可以分解为两堆,标准的Multi-SG游戏 一般Multi-SG就是根据拓扑图计算SG函数,这题打表后还能发现规律 sg(1)=1 sg(2)=2 sg(3)=mex{0,1,2 ...

  9. hdu 1030 Delta-wave(数学题+找规律)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1030 Delta-wave Time Limit: 2000/1000 MS (Java/Others ...

随机推荐

  1. Python3基础(九) 错误和异常

    本文主要介绍Python中的错误和异常,涉及到简单的异常处理.抛出异常以及清理动作.至于自定义异常类,将在介绍类与继承的时候讲到. 一.定义 常见的两种错误:语法错误 和 异常. 1.语法错误(Syn ...

  2. Android BroadcastAnyWhere(Google Bug 17356824)漏洞具体分析

    Android BroadcastAnyWhere(Google Bug 17356824)漏洞具体分析 作者:简行(又名 低端码农) 继上次Android的LaunchAnyWhere组件安全漏洞后 ...

  3. LeetCode 389. Find the Difference (找到不同)

    Given two strings s and t which consist of only lowercase letters. String t is generated by random s ...

  4. install yael on the ubuntu 12.04

    1. bits/predefs.h no such file or directory  ??? sudo apt-get install gcc-multilib 2. sudo gedit /et ...

  5. debian使用过程中常见的问题

    1 wget https://www.dropbox.com ERROR: The certificate of `www.dropbox.com' is not trusted. ERROR: Th ...

  6. HDU 1299Diophantus of Alexandria

    Diophantus of Alexandria Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java ...

  7. Android之利用EventBus进行消息传递

    什么是EventBus EventBus是一个 发布/订阅 模式的消息总线库,它简化了应用程序内各组件间.组件与后台线程间的通信,解耦了事件的发送者和接收者,避免了复杂的.易于出错的依赖及生命周期问题 ...

  8. Codeforces Round #367 (Div. 2) 套题

    吐槽:只能说是上分好场,可惜没打,唉 A:Beru-taxi (水题,取最小值) #include <cstdio> #include <cstring> #include & ...

  9. 什么是JavaScript对象?

    对象是JavaScript的基本数据类型.对象是一种复合值:它将很多值(原始值或者其他对象)聚合在一起,可通过名字访问这些值.对象也可看做是属性的无序集合,每个属性都是一个名/值对.属性名是字符串,因 ...

  10. IDEA新项目代码上传到gitlab远程仓库

    IDEA新项目代码上传到gitlab远程仓库 具体步骤 创建本地仓库 IDEA:VCS-->Import into Version Control-->Create Git Reposit ...