RXD is a good mathematician.

One day he wants to calculate:



output the answer module 109+7.

p1,p2,p3…pk are different prime numbers

Input

There are several test cases, please keep reading until EOF.

There are exact 10000 cases.

For each test case, there are 2 numbers n,k.

Output

For each test case, output “Case #x: y”, which means the test case number and the answer.

Sample Input

10 10

Sample Output

Case #1: 999999937

看见这个题不可能去正常做,尝试达标找规律,然后找了 n^K的规律


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll ksm(ll n, ll k)
{
ll r = 1;
for (; k; k >>= 1)
{
if (k & 1)
r = r * n % mod;
n = n * n % mod;
}
return r;
} int main()
{
ll x, y, ca = 1;
while (~scanf("%lld%lld", &x, &y))
{
// x大于mod这题就没法做了
x=x%mod; //利用费马小定理
cout << "Case #" << ca++ << ": " << ksm(x, y) << endl;
}
}

数学--数论--HDU 6063 RXD and math (跟莫比乌斯没有半毛钱关系的打表)的更多相关文章

  1. 2017 ACM暑期多校联合训练 - Team 3 1008 HDU 6063 RXD and math (莫比乌斯函数)

    题目链接 Problem Description RXD is a good mathematician. One day he wants to calculate: ∑i=1nkμ2(i)×⌊nk ...

  2. HDU 6063 - RXD and math | 2017 Multi-University Training Contest 3

    比赛时候面向过题队伍数目 打表- - 看了题解发现确实是这么回事,分析能力太差.. /* HDU 6063 - RXD and math [ 数学,规律 ] | 2017 Multi-Universi ...

  3. hdu 6063 RXD and math(快速幂)

    RXD and math Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)To ...

  4. HDU - 6063 RXD and math

    Bryce1010模板 http://acm.hdu.edu.cn/showproblem.php?pid=6063 打表发现规律是n^k #include <iostream> #inc ...

  5. 数学--数论--HDU - 6395 Let us define a sequence as below 分段矩阵快速幂

    Your job is simple, for each task, you should output Fn module 109+7. Input The first line has only ...

  6. 数学--数论-- HDU 2601 An easy problem(约束和)

    Problem Description When Teddy was a child , he was always thinking about some simple math problems ...

  7. 数学--数论--HDU 1098 Ignatius's puzzle (费马小定理+打表)

    Ignatius's puzzle Problem Description Ignatius is poor at math,he falls across a puzzle problem,so h ...

  8. 数学--数论--HDU 2582 F(N) 暴力打表找规律

    This time I need you to calculate the f(n) . (3<=n<=1000000) f(n)= Gcd(3)+Gcd(4)+-+Gcd(i)+-+Gc ...

  9. [数论] hdu 5974 A Simple Math Problem (数论gcd)

    传送门 •题意 一直整数$a,b$,有 $\left\{\begin{matrix}x+y=a\\ LCM(x*y)=b \end{matrix}\right.$ 求$x,y$ •思路 解题重点:若$ ...

随机推荐

  1. 使用ping命令探测系统

    什么是ping命令 ping命令是测试网络连接.信息发送和接收状况的实用型工具,是系统内置的探测性工具.它的原理是:每台网络上的主机都有唯一确定的IP地址,用户给目标IP发送一个数据报,对方就要返回一 ...

  2. Java第六天,API中常用的类,StringBuffer、StringBuilder、包装类、System类的使用

    System (1)这个类中有很多可以获取系统信息的类. public class SystemLearn { public static void main(String[] args) { lon ...

  3. matplotlib AffineBase, Affine2DBase, Affine2D

    2020-04-10 09:02:59 --Edit by yangray 仿射变换矩阵参考资料-->https://blog.csdn.net/robert_chen1988/article/ ...

  4. posix系统线程调度-设置线程优先级

    #include <thread> #include <mutex> #include <iostream> #include <chrono> #in ...

  5. 自己模拟的ftl 用法:

    基类 public class Ftl_object_data_model { //三种基本属性 private boolean canRead=true;//是否能读取 ;//长度 private ...

  6. Android | 教你如何在安卓上实现二代身份证识别,一键实名认证

    @ 目录 前言 场景 开发前准备 android studio 安装 在项目级gradle里添加华为maven仓 在应用级的build.gradle里面加上SDK依赖 在AndroidManifest ...

  7. Bi-shoe and Phi-shoe LightOJ - 1370

    欧拉函数. 欧拉函数打表模板: #define maxn 3000010 int p[maxn]; void oula(){ int i,j; ; i<=maxn; i++) p[i]=i; ; ...

  8. 论JDK5/7/8版本都做出了哪些革新

    在Java发展的里程碑上,有三个版本做出的改动,是革命性的 为什么说是革命性的呢? 因为这三个版本所推出的有些新机制,在之后的Java框架开发.新类的产生等等中, 都被广泛使用了. 那么,这三个版本的 ...

  9. 【学习笔记】 $learn \ from \ failure \ ? ( 雾$

    \(1.\)变量名不要用 \(next\) ,在某些编译器里可能是关键词,可以用 \(nxt\) 代替 \(\\\) \(2.\)在判断某些条件时应该写成 flag = 条件 ? 1 : flag; ...

  10. 用多线程,实现并发,TCP

    首先,开启新的线程,是不会新开辟内存空间的,即,子线程和主线程 都在同一个进程里,也就是主进程里,用os.pid(),os.ppid() 服务器: 方式一:Thread实例化 def task(con ...