数学题。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. 删除右键菜单的“用阿里旺旺发送此文件”项

    在运行对话框里的输入框内输入Regedit.exe,点击确定按钮就启动了注册表编辑器程序. 在注册表编辑器窗口左侧展开HKEY_CLASSES_ROOT\CLSID{0DE1378D-F811-40E ...

  2. oracle查看死锁和处理方法

    在操作数据库中经常会遇到表死锁问题,特别是不良的数据库设计和操作的时候,更容易遇到死锁问题.今天在系统中往oracle中添加数据时,特意快速多点几次添加的时候,就出现了死锁问题,而且刚好在读取和更新表 ...

  3. Java 6 Thread States and Life Cycle.

    Ref: Java 6 Thread States and Life Cycle This is an example of UML protocol state machine diagram sh ...

  4. Linux下安装Nginx1.9.3-0303(本人亲手实践)

    Linux下安装Nginx1.9.3 Linux操作系统 Oel 5.8 64bit 最新版Nginx: 1.9.3 最近同事让我帮忙搞 ngix,两天时间 安装.配置搞定了.继续 Nginx 1.9 ...

  5. 谈谈oracle中的临时表

    --------------------创建临时表 临时保存从xml字符串解析来的数据--------------------------- 会话级别临时表SQL> create global ...

  6. 【转】iOS- 详解文本属性Attributes

    原文: http://www.cnblogs.com/qingche/p/3574995.html?utm_source=tuicool 1.NSKernAttributeName: @10 调整字句 ...

  7. 十三、C# 事件

    1.多播委托 2.事件 3.自定义事件   在上一章中,所有委托都只支持单一回调. 然而,一个委托变量可以引用一系列委托,在这一系列委托中,每个委托都顺序指向一个后续的委托, 从而形成了一个委托链,或 ...

  8. java 保留小数点后N位数(若干位),几种实现的方式总结

    import java.math.BigDecimal;import java.text.DecimalFormat;import java.text.NumberFormat;/** * java ...

  9. [LeetCode OJ] Gas Station

    问题描述: There are N gas stations along a circular route, where the amount of gas at station i is gas[i ...

  10. SGU 197.Nice Patterns Strike Back

    时间限制:0.5s 空间限制:6M 题意: 给出长n(n<=10^100)和宽m(m<=5)的地面,铺上黑色和白色的地板,使得没有任意一个2*2大小的地面铺同种颜色的方案数是多少. Sol ...