【HDOJ】4704 Sum
数学题。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的更多相关文章
- 【HDOJ】1258 Sum It Up
典型的深搜,剪枝的时候需要跳过曾经搜索过的相同的数目,既满足nums[i]=nums[i-1]&&visit[i-1]==0,visit[i-1]==0可以说明该点已经测试过. #in ...
- 【LeetCode】129. Sum Root to Leaf Numbers 解题报告(Python)
[LeetCode]129. Sum Root to Leaf Numbers 解题报告(Python) 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/pr ...
- 【Leetcode】404. Sum of Left Leaves
404. Sum of Left Leaves [题目]中文版 英文版 /** * Definition for a binary tree node. * struct TreeNode { * ...
- 【LibreOJ】【LOJ】#6220. sum
[题意]对于n个数,找出一些数使得它们的和能被n整除,输出任意一组方案,n<=10^6. [算法]构造/结论 [题解]引用自:http://www.cnblogs.com/Sakits/p/74 ...
- 【LeetCode】Two Sum II - Input array is sorted
[Description] Given an array of integers that is already sorted in ascending order, find two numbers ...
- 【LeetCode】633. Sum of Square Numbers
Difficulty: Easy More:[目录]LeetCode Java实现 Description https://leetcode.com/problems/sum-of-square-n ...
- 【leetcode】907. Sum of Subarray Minimums
题目如下: 解题思路:我的想法对于数组中任意一个元素,找出其左右两边最近的小于自己的元素.例如[1,3,2,4,5,1],元素2左边比自己小的元素是1,那么大于自己的区间就是[3],右边的区间就是[4 ...
- 【HDOJ】3473 Minimum Sum
划分树解.主席树解MLE. /* 3473 */ #include <iostream> #include <sstream> #include <string> ...
- 【HDOJ】【3415】Max Sum of Max-K-sub-sequence
DP/单调队列优化 呃……环形链求最大k子段和. 首先拆环为链求前缀和…… 然后单调队列吧<_<,裸题没啥好说的…… WA:为毛手写队列就会挂,必须用STL的deque?(写挂自己弱……s ...
随机推荐
- Java实现常见排序算法
常见的排序算法有冒泡排序.选择排序.插入排序.堆排序.归并排序.快速排序.希尔排序.基数排序.计数排序,下面通过Java实现这些排序 1.冒泡排序 package com.buaa; import j ...
- Spring AOP + AspectJ Annotation Example---reference
In this tutorial, we show you how to integrate AspectJ annotation with Spring AOP framework. In simp ...
- android开发之broadcast学习笔记 分类: android 学习笔记 2015-07-19 16:33 32人阅读 评论(0) 收藏
android中的广播用的太多了,今天稍微总结一下. 按注册方式分为两种: 1.静态注册广播: 静态注册广播就是在androidManifest.xml文件中注册广播,假设我们要实现这样一个效果,在一 ...
- css考核点整理(三)-css选择器的使用
css选择器的使用
- Bginfo软件在域的部署和应用
在企业的IT管理中,很多用户都不知道怎么去查看自己计算机的IP地址.登陆帐户.而对于网络管理人员来说,他们可能需要知道用户在域中登录的一些信息,如那些用户登录过,在什么时间登录,IP和MAC地址是多少 ...
- codevs1506传话(kosaraju算法)
- - - - - - - - 一个()打成[] 看了一晚上..... /* 求强连通分量 kosaraju算法 边表存图 正反构造两个图 跑两边 分别记下入栈顺序 和每个强连通分量的具体信息 */ ...
- 某PHP代码加密
<?php /* 本程序已加密: 2014-11-15 10:10:11 */ xs_run('JGxosS9QplmqLA6qjYo/LiX5ecUe0DH7p42Ww/Mdkf5/ybZDs ...
- xml中报错,验证是否是xml报错
1.xml中写入sql有时报错,例如有大于号小于号,要用<![CDATA[ ]]>扩起来 2.验证xml有错的方式,以浏览器方式打开,如果正常打开,无错. ...
- Scrum教练不应兼任product owner
ScrumMasters Should Not Also Be Product Owners(中文翻译) December 2, 2014 by Mike Cohn 翻译:2015.2.18 by o ...
- node http.request请求
var http = require('http'); var querystring = require('querystring'); var path = '/cricket/getRecord ...