zoukankan      html  css  js  c++  java
  • [水题]4242 果实计数&&3214 采访对象

    4242 果实计数

     

     时间限制: 1 s
     空间限制: 32000 KB
     题目等级 : 黄金 Gold
     
     
     
    题目描述 Description

      淘淘家有棵奇怪的苹果树,这棵树共有n+1层,标号为0~n。这棵树第0层只有一个节点,为根节点。已知这棵树为b叉树,且保证是一颗满b叉树。

    现在,该树第n层的每个节点上都结出了一个苹果,淘淘想知道共结了多少苹果。由于数量可能很大,答案要求输出mod k后的结果。

    输入描述 Input Description

    给出第1层的节点数b和层数n和k

    输出描述 Output Description

    输出苹果数mod k后的结果。

    样例输入 Sample Input

    2 10 9

    样例输出 Sample Output

    7

    数据范围及提示 Data Size & Hint

    30%的数据保证:b<=100,n<=10, k<=100.

    100%的数据保证:b<2^31,n<2^31,k<=2^15.

    分类标签 Tags 点此展开 

     
    暂无标签
    AC代码:
    #include<cstdio>
    #ifdef unix
    #define LL "%lld"
    #else
    #define LL "%I64d"
    #endif
    #define ll long long
    using namespace std;
    void fpow(ll a,ll p,ll mod){
        ll res=1;
        for(;p;p>>=1,a=a*a%mod) if(p&1) res=res*a%mod;
        printf(LL,res);
    }
    int main(){
        int a,n,mod;
        scanf("%d%d%d",&a,&n,&mod);
        fpow(a,n,mod);
        return 0;
    }

    3214 采访对象

     

     时间限制: 1 s
     空间限制: 32000 KB
     题目等级 : 黄金 Gold
     
     
     
    题目描述 Description

    有n个人站成一排,CCTV要采访其中一些人“你幸福吗?”。但是相邻两个人不能都被采访,否则这两个人就会因为相互影响而说出不真实的回答。CCTV想知道一共有多少种满足条件的采访方法呢?

    输入描述 Input Description

    一个整数n (0≤n≤90)

    输出描述 Output Description

    方法总数。

    样例输入 Sample Input

    2

    样例输出 Sample Output

    3

    数据范围及提示 Data Size & Hint

    CCTV可以都不采访,或者只采访第一个人,或者只采访第二个人

    分类标签 Tags 点此展开 

     
    暂无标签
    AC代码:
    #include<cstdio>
    using namespace std;
    const int N=100;
    int n;long long f[N];
    int main(){
        scanf("%d",&n);
        f[0]=1;f[1]=2;f[2]=3;
        for(int i=3;i<=n;i++) f[i]=f[i-1]+f[i-2];
        printf("%lld
    ",f[n]);
        return 0;
    }
  • 相关阅读:
    父子进程 signal 出现 Interrupted system call 问题
    一个测试文章
    《淘宝客户端 for Android》项目实战 html webkit android css3
    Django 中的 ForeignKey ContentType GenericForeignKey 对应的数据库结构
    coreseek 出现段错误和Unigram dictionary load Error 新情况(Gentoo)
    一个 PAM dbus 例子
    漫画统计学 T分数
    解决 paramiko 安装问题 Unable to find vcvarsall.bat
    20141202
    js
  • 原文地址:https://www.cnblogs.com/shenben/p/5930039.html
Copyright © 2011-2022 走看看