题目链接:

https://cn.vjudge.net/problem/FZU-1759

题目大意:

求A^B%C

解题思路:

注意,这里long long需要用%I64读入,不能用%lld

 #include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
typedef long long ll;
const int maxn = 2e6 + ;
int euler_phi(int n)//求单个
{
int m = (int)sqrt(n + 0.5);
int ans = n;
for(int i = ; i <= m; i++)if(n % i == )
{
ans = ans / i * (i - );
while(n % i == )n /= i;
}
if(n > )ans = ans / n * (n - );
return ans;
}
ll mul(ll a, ll b, ll m)
//求a*b%m
{
ll ans = ;
a %= m;
while(b)
{
if(b & )ans = (ans + a) % m;
b /= ;
a = (a + a) % m;
}
return ans;
}
ll pow(ll a, ll b, ll m)
{
ll ans = ;
a %= m;
while(b)
{
if(b & )ans = mul(a, ans, m);
b /= ;
a = mul(a, a, m);
}
ans %= m;
return ans;
}
ll super_pow(ll a, char b[], ll c)
{
ll t = euler_phi(c), n = strlen(b), tot = ;
for(int i = ; i < n; i++)
{
tot = tot * + b[i] - '';
tot %= t;
}
tot += t;
return pow(a, tot, c);
}
char b[maxn];
int main()
{
ll a, c;
while(~scanf("%I64d%s%I64d", &a, b, &c))
{
printf("%I64d\n", super_pow(a, b, c));
}
return ;
}

FZU-1759 Super A^B mod C---欧拉降幂&指数循环节的更多相关文章

  1. HDU - 5728:PowMod (欧拉函数&指数循环节)

    Declare: k=∑ m i=1 φ(i∗n) mod 1000000007 k=∑i=1mφ(i∗n) mod 1000000007 n n is a square-free number. φ ...

  2. FZU 1759 Super A^B mod C 指数循环节

    Problem 1759 Super A^B mod C Time Limit: 1000 mSec    Memory Limit : 32768 KB  Problem Description G ...

  3. FZU:1759-Problem 1759 Super A^B mod C (欧拉降幂)

    题目链接:http://acm.fzu.edu.cn/problem.php?pid=1759 欧拉降幂是用来干啥的?例如一个问题AB mod c,当B特别大的时候int或者longlong装不下的时 ...

  4. FOJ ——Problem 1759 Super A^B mod C

     Problem 1759 Super A^B mod C Accept: 1368    Submit: 4639Time Limit: 1000 mSec    Memory Limit : 32 ...

  5. fzou 1759 Super A^B mod C

    Problem 1759 Super A^B mod CAccept: 456    Submit: 1488Time Limit: 1000 mSec    Memory Limit : 32768 ...

  6. FZU 1759 题解 欧拉降幂

    本题考点:欧拉降幂 Super A^B mod C Given A,B,C, You should quickly calculate the result of A^B mod C. (1<= ...

  7. FZU1759(SummerTrainingDay04-B 欧拉降幂公式)

    Problem 1759 Super A^B mod C Accept: 1056    Submit: 3444Time Limit: 1000 mSec    Memory Limit : 327 ...

  8. 【转】【关于 A^x = A^(x % Phi(C) + Phi(C)) (mod C) 的若干证明】【指数循环节】

    [关于 A^x = A^(x % Phi(C) + Phi(C)) (mod C) 的若干证明][指数循环节] 原文地址:http://hi.baidu.com/aekdycoin/item/e493 ...

  9. hdu4549 矩阵快速幂 + 欧拉降幂

    R - M斐波那契数列 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit  ...

随机推荐

  1. 批量查找ip地址归属地脚本

    #!/bin/bash ip_list=`cat $1` for i in $ip_listdocurl http://www.ip.cn/index.php?ip=$idoneexit 0

  2. 系统对象的使用——Cookie,ViewState,Session,Application

    Normal 0 7.8 磅 0 2 false false false EN-US ZH-CN X-NONE /* Style Definitions */ table.MsoNormalTable ...

  3. HTTP 错误 404.11 - Not Found 请求筛选模块被配置为拒绝包含双重转义序列的请求。

    一些URL中可能会包含+号等符号,然后IIS7以上的版本会默认拒绝请求此URL,需要进行如下的修改. <configuration> <system.webServer> &l ...

  4. Expression Blend实例中文教程(9) - 行为快速入门Behaviors

    在Blend强大的设计功能支持下,设计人员和开发人员可以无代码实现Silverlight/WPF动画效果,例如上文介绍的StoryBoard,就是一个典型例子,设计人员和开发人员仅需提供必要元素,即可 ...

  5. C# 委托,事件, 异步

    委托 ​ 委托可以说是方法的集合,里面放着方法列表,当调用的时候就会调用全部的方法列表 ​ 个人理解 : 当声明和创建时委托时, 它是个 对象 当使用委托,调用方法时,它是个 方法 声明委托类型 de ...

  6. Nuxt.js学习心得

    一.官网 Nuxt.js - Universal Vue.js Applications https://nuxtjs.org/ 二.中文官网 Nuxt.js - Vue.js 通用应用框架 http ...

  7. 八、profile多环境配置

    通常我们的程序有着多个环境: 1.开发环境: 2.生产环境. 等 环境的配置各不相同,我们希望通过一个简单的配置来切换环境,而springboot轻松地实现了该功能: 一.多环境需要多配置文件 一般我 ...

  8. 监听域对象创建和销毁的Listener

    1.什么是Servlet监听器? 先来看看什么是监听器.监听器是专门用于对其它对象身上发生的事件或状态改变进行监听和相应处理的对象,当被监视的对象发生情况时立即采取相应的行动.Servlet监听器是S ...

  9. jquery对象与核心函数

    原生js入口函数与jQuery入口函数的区别 1.window.onload与document.ready在加载时间上的差异 document.ready会先触发,其次才是window.onload ...

  10. wampserver 点击跳转localhost变0.0.0.0的解决方法!

    最近下载新版本wampserver发现点击项目不会自动添加localhost了,导致访问项目很麻烦. 修改如下 修改wamp根目录下的wampmanager.conf urlAddLocalhost ...