HDU - 4074 - Sum
先上题目:
Sum
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 206 Accepted Submission(s): 113

1. For N = 2, S(1) = S(2) = 1.
2. The input file consists of multiple test cases.
#include <stdio.h>
#include <string.h>
#define MAX 1000001
#define MOD 1000000007
using namespace std; char s[MAX]; void Sub(int &len)
{
int i;
if(s[len-]>'') s[len-]--;
else
{
for(i=len-;i>= && s[i]=='';i--) s[i]='';
s[i]--;
if(s[i]==''){s[i]=''; len--;s[len]='\0';}
//if(len==0){s[0]='0';len=1;}
} } long long Fast_Mod(long long a,int p)
{
if(p==) return ;
if(p==) return a%MOD;
long long t=Fast_Mod(a,p>>);
t=t*t%MOD;
if(p&) t=t*a%MOD;
return t;
} int main()
{
int i,len,t;
long long ans;
//freopen("data.txt","r",stdin);
while(scanf("%s",s)!=EOF)
{
len=strlen(s);
Sub(len);
ans=;
//printf("%s\n",s);
for(i=;i<len;i++)
{
t=s[i]-'';
ans=Fast_Mod(ans,);
ans=ans*Fast_Mod(,t)%MOD;
}
printf("%I64d\n",ans);
}
return ;
}
4074
HDU - 4074 - Sum的更多相关文章
- HDOJ(HDU).1258 Sum It Up (DFS)
HDOJ(HDU).1258 Sum It Up (DFS) [从零开始DFS(6)] 点我挑战题目 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架/双 ...
- hdu 1258 Sum It Up(dfs+去重)
题目大意: 给你一个总和(total)和一列(list)整数,共n个整数,要求用这些整数相加,使相加的结果等于total,找出所有不相同的拼凑方法. 例如,total = 4,n = 6,list = ...
- 数论 --- 费马小定理 + 快速幂 HDU 4704 Sum
Sum Problem's Link: http://acm.hdu.edu.cn/showproblem.php?pid=4704 Mean: 给定一个大整数N,求1到N中每个数的因式分解个数的 ...
- HDU 1231 最大连续子序列 &&HDU 1003Max Sum (区间dp问题)
C - 最大连续子序列 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit ...
- HDU 4704 Sum (高精度+快速幂+费马小定理+二项式定理)
Sum Time Limit:1000MS Memory Limit:131072KB 64bit IO Format:%I64d & %I64u Submit Status ...
- HDU 5776 sum (模拟)
sum 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5776 Description Given a sequence, you're asked ...
- hdu 5586 Sum 最大子段和
Sum Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5586 Desc ...
- hdu 5586 Sum【dp最大子段和】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5586 Sum Time Limit: 2000/1000 MS (Java/Others) Me ...
- hdu 4432 Sum of divisors(十进制转其他进制)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4432 代码: #include<cstdio> #include<cstring&g ...
随机推荐
- oc34--instancetype和id的区别
// Person.h #import <Foundation/Foundation.h> @interface Person : NSObject @property int age; ...
- android Service not registered
Caused by: java.lang.IllegalArgumentException: Service not registered:com.broadcom.bt.app.settings.S ...
- 【SDOI 2010】 魔法猪学院
[题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=1975 [算法] A*求k短路 [代码] #include<bits/stdc+ ...
- 使用 Polyfill 而不再是 bable 来实践js新特性
现状 我们想要用ES6 语法来写 JavaScript.然而由于我们需要兼容老版本的浏览器,那些浏览器不支持 ES6,我们需要解决这个问题. 有一个标准的做法是:写 ES6 代码 → 将所有代码编译成 ...
- Rancher 2:添加 NFS client provisioner 动态提供 Kubernetes 后端存储卷
一.前提说明 1.说明: NFS client provisioner 利用 NFS Server 给 Kubernetes 作为持久存储的后端,并且动态提供PV. 默认 rancher 2 的存储类 ...
- [跨域]js设置document.domain实现跨域
document.domain用来得到当前网页的域名.比如在地址栏里输入: 代码如下: javascript:alert(document.domain); //www.jb51.net 我们也可以给 ...
- I2C controller core之Bit controller(03)
FPGA proven, AISC proven, I2C controller core from OpenCores http://opencores.org/project,i2c Bit-co ...
- 用js制作一个计算器
使用js制作计算器 <!doctype html> <html lang="en"> <head> <meta charset=" ...
- 5、scala数组转换
1.使用yield和函数式编程转换数组 2.算法案例:移除第一个负数之后的所有负数 1.使用yield和函数式编程转换数组 使用yield进行数组转换 结合if守卫,仅转换需要转换的元素 使用函数式编 ...
- 阿里巴巴矢量库IconFont__使用小录
使用阿里巴巴矢量库方法虽然不难,但本人记性不好,遂在次记录几笔 阿里巴巴矢量库地址:http://www.iconfont.cn/plus 阿里巴巴矢量库图标好处: 1:图标矢量化 2:自己总结:ic ...