规律 欧拉定理:

找规律 2^n-1 ,n 非常大用欧拉定理

Sum

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)

Total Submission(s): 1465    Accepted Submission(s): 622

Problem Description
 
Sample Input
2
 
Sample Output
2
Hint
1. For N = 2, S(1) = S(2) = 1. 2. The input file consists of multiple test cases.
 
Source
 

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath> using namespace std; typedef long long int LL; const LL mod=1e9+7;
const LL phi=1e9+6; char str[200000]; LL quickpow(LL x)
{
if(x==0LL) return 1LL;
LL e=2,ret=1;
while(x)
{
if(x%2)
ret=(ret*e)%mod;
e=(e*e)%mod;
x/=2LL;
}
return ret;
} int main()
{
while(scanf("%s",str)!=EOF)
{
int len=strlen(str);
/// N - 1
if(str[len-1]>'0')
{
str[len-1]--;
}
else
{
int p=len-1;
while(str[p]=='0')
{
str[p]='9';
p--;
}
str[p]--;
}
LL ret=0;
for(int i=0;i<len;i++)
{
ret=ret*10LL+str[i]-'0';
while(ret>=phi)
ret-=phi;
}
cout<<quickpow(ret)<<endl;
}
return 0;
}

HDOJ 4704 Sum 规律 欧拉定理的更多相关文章

  1. 题解报告:hdu 4704 Sum(扩展欧拉定理)

    Problem Description Sample Input 2 Sample Output 2 Hint 1. For N = 2, S(1) = S(2) = 1. 2. The input ...

  2. 【HDOJ】4704 Sum

    数学题.f(n) = 2^(n-1) mod (1e9+7). #include <cstdio> #define MAXN 100005 char buf[MAXN]; __int64 ...

  3. 数论 --- 费马小定理 + 快速幂 HDU 4704 Sum

    Sum Problem's Link:   http://acm.hdu.edu.cn/showproblem.php?pid=4704 Mean: 给定一个大整数N,求1到N中每个数的因式分解个数的 ...

  4. HDU 4704 Sum (高精度+快速幂+费马小定理+二项式定理)

    Sum Time Limit:1000MS     Memory Limit:131072KB     64bit IO Format:%I64d & %I64u Submit Status  ...

  5. HDU 4704 Sum(隔板原理+组合数求和公式+费马小定理+快速幂)

    题目传送:http://acm.hdu.edu.cn/showproblem.php?pid=4704 Problem Description   Sample Input 2 Sample Outp ...

  6. HDU - 4704 sum 大数取余+欧拉降幂

    Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submi ...

  7. hdu 4704 Sum (整数和分解+快速幂+费马小定理降幂)

    题意: 给n(1<n<),求(s1+s2+s3+...+sn)mod(1e9+7).其中si表示n由i个数相加而成的种数,如n=4,则s1=1,s2=3.                  ...

  8. hdoj - 1258 Sum It Up && hdoj - 1016 Prime Ring Problem (简单dfs)

    http://acm.hdu.edu.cn/showproblem.php?pid=1258 关键点就是一次递归里面一样的数字只能选一次. #include <cstdio> #inclu ...

  9. HDOJ(1001) Sum Problem

    这一套题做错了几次,按理说直接用等差数列求和公式就行了,主要是要考虑一些运算符的结核性问题: 四则运算符(+.-.*./)和求余运算符(%)结合性都是从左到右. 于是,我自己写了一个版本,主要是考虑( ...

随机推荐

  1. 定位 UNIX 上常见问题的经验总结

    本文主要对 UNIX 平台常见的问题进行了分类,介绍一些常见问题分析时使用的方法和命令,对以下三种常见问题的分析方法做了简单介绍:UNIX 下 Crash 问题的分析方法.UNIX 下内存泄露问题的分 ...

  2. Python远程视频监控程序

    老板由于事务繁忙无法经常亲临教研室,于是让我搞个监控系统,让他在办公室就能看到教研室来了多少人.o(>﹏<)o||| 最初我的想法是直接去网上下个软件,可是找来找去不是有毒就是收费,无奈技 ...

  3. HDU 6206 Apple

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6206 判断给定一点是否在三角形外接圆内. 给定三角形三个顶点的坐标,如何求三角形的外心的坐标呢? 知乎 ...

  4. win7快捷键和ubuntu快捷键

    http://www.cnblogs.com/xfiver/archive/2010/12/08/1899905.html http://www.pc841.com/article/20121203- ...

  5. Xamarin XAML语言教程对象元素的声明方式

    Xamarin XAML语言教程对象元素的声明方式 XAML的对象元素的声明有两种形式,分别为包含属性的特性语法形式以及对象元素语法形式.在1.4小节中,我们看到了其中一种对XAML对象元素的声明方式 ...

  6. C# 生成二维码(带Logo)

    C# 生成二维码(带Logo) 第一种方式 我们需要引用 ThoughtWorks.QRCode.dll  生成带logo二维码(framework4.0以上) 下载地址:https://pan.ba ...

  7. HDU4372 Buildings

    @(HDU)[Stirling數, 排列組合] Problem Description There are N buildings standing in a straight line in the ...

  8. Eclipse安装Spring工具套件

    前言: 安装spring工具套件是为了更快捷的使用spring,但是我觉得既然已经有了maven,工具套件其实不那么重要. 而且装好后我发觉没什么两样,只是新建bean文件时比较爽一点. 安装步骤: ...

  9. Android 打开其他程序

    Intent intent = new Intent(); intent.setComponent(new ComponentName("所要打开的程序包名", "所要打 ...

  10. fastjson中Map与JSONObject互换,List与JOSNArray互换的实现

    1.//将map转换成jsonObject JSONObject itemJSONObj = JSONObject.parseObject(JSON.toJSONString(itemMap)); 将 ...