数学题。f(n) = 2^(n-1) mod (1e9+7)。

 #include <cstdio>

 #define MAXN 100005

 char buf[MAXN];
__int64 phi = 1e9+;
__int64 mod = 1e9+; __int64 power2(__int64 n) {
__int64 ret = , base = ; --n;
while (n) {
if (n & )
ret = ret * base % mod;
base = base*base%mod;
n >>= ;
}
return ret;
} int main() {
__int64 tmp;
__int64 i, j; while (scanf("%s", buf) != EOF) {
tmp = ;
for (i=; buf[i]; ++i) {
tmp = *tmp + (buf[i]-'');
tmp %= phi;
}
tmp += phi;
tmp = power2(tmp);
printf("%I64d\n", tmp);
} return ;
}

【HDOJ】4704 Sum的更多相关文章

  1. 【HDOJ】1258 Sum It Up

    典型的深搜,剪枝的时候需要跳过曾经搜索过的相同的数目,既满足nums[i]=nums[i-1]&&visit[i-1]==0,visit[i-1]==0可以说明该点已经测试过. #in ...

  2. 【LeetCode】129. Sum Root to Leaf Numbers 解题报告(Python)

    [LeetCode]129. Sum Root to Leaf Numbers 解题报告(Python) 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/pr ...

  3. 【Leetcode】404. Sum of Left Leaves

    404. Sum of Left Leaves [题目]中文版  英文版 /** * Definition for a binary tree node. * struct TreeNode { * ...

  4. 【LibreOJ】【LOJ】#6220. sum

    [题意]对于n个数,找出一些数使得它们的和能被n整除,输出任意一组方案,n<=10^6. [算法]构造/结论 [题解]引用自:http://www.cnblogs.com/Sakits/p/74 ...

  5. 【LeetCode】Two Sum II - Input array is sorted

    [Description] Given an array of integers that is already sorted in ascending order, find two numbers ...

  6. 【LeetCode】633. Sum of Square Numbers

    Difficulty: Easy  More:[目录]LeetCode Java实现 Description https://leetcode.com/problems/sum-of-square-n ...

  7. 【leetcode】907. Sum of Subarray Minimums

    题目如下: 解题思路:我的想法对于数组中任意一个元素,找出其左右两边最近的小于自己的元素.例如[1,3,2,4,5,1],元素2左边比自己小的元素是1,那么大于自己的区间就是[3],右边的区间就是[4 ...

  8. 【HDOJ】3473 Minimum Sum

    划分树解.主席树解MLE. /* 3473 */ #include <iostream> #include <sstream> #include <string> ...

  9. 【HDOJ】【3415】Max Sum of Max-K-sub-sequence

    DP/单调队列优化 呃……环形链求最大k子段和. 首先拆环为链求前缀和…… 然后单调队列吧<_<,裸题没啥好说的…… WA:为毛手写队列就会挂,必须用STL的deque?(写挂自己弱……s ...

随机推荐

  1. mysqladmin

    mysqladmin -r -i 2 ex | grep Innodb_rows_inserted

  2. Qt 学习之路:模型-视图高级技术

    PathView PathView是 QtQuick 中最强大的视图,同时也是最复杂的.PathView允许创建一种更灵活的视图.在这种视图中,数据项并不是方方正正,而是可以沿着任意路径布局.沿着同一 ...

  3. 关于 Cocoa Pods 的使用

    前提:电脑上已经安装好CocoaPods. 创建Podfile: 1.进入到项目的目录中: $ cd 目录 2.使用终端命令行: $ vim Podfile 3.然后按i键,进入编辑模式 我现在使用的 ...

  4. clearTimeout(timeoutfunc) 是否有必要执行

    当使用 setTimeout() 方法的时候,是否必须执行 clearTimeout() ? 在 setTimeout() 内的函数执行之前,如果想要阻止执行该方法,是有必要执行 cleartTime ...

  5. Activity的几种启动跳转方式

     一.显示调用方法 •Intent intent=new Intent(this,OtherActivity.class); //方法1 •Intent intent2=new Intent(); • ...

  6. 对 Xcode 菜单选项的详细探索(转)

    转自 http://www.cnblogs.com/dsxniubility/p/4983614.html 本文调研Xcode的版本是 7.1,基本是探索了菜单的每一个按钮.虽然从xcode4一直用到 ...

  7. NSString 的三种截取方法

    1.定义一个字符串a, 截取a 的某一个项目组,复制给b, b必须是int型 NSString *a = @"1.2.30"; int  b= [[a substringWithR ...

  8. HTML meta标签总结与属性使用介绍

    之前学习前端中,对meta标签的了解仅仅只是这一句. <meta charset="UTF-8"> 但是打开任意的网站,其head标签内都有一列的meta标签.比如我博 ...

  9. 【算法】数组与矩阵问题——找到无序数组中最小的k个数

    /** * 找到无序数组中最小的k个数 时间复杂度O(Nlogk) * 过程: * 1.一直维护一个有k个数的大根堆,这个堆代表目前选出来的k个最小的数 * 在堆里的k个元素中堆顶的元素是最小的k个数 ...

  10. hdu_5276

    //不管怎么样还是希望天天做笔记把,真是太懒了#include<iostream> #include<cstdio> #include<vector> #inclu ...