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. Centos7 安装redis 5.0.8 开机自启动

    redis安装 将安装包移动到linux上 执行解压 tar -xvf redis-5.0.8.tar.gz 修改redis文件夹名称 mv redis- redis 修改redis权限 chmod ...

  2. HBase Shell 十大花式玩儿法

    前言:工欲善其事必先利其器,今天给大家介绍一下HBase Shell十大花式利器,在日常运维工作中,可以试着用起来. 1. 交互模式 也就是我们最常用到的Shell命令行的方式. $ hbase sh ...

  3. Powershell基础---帮助系统

    帮助系统能带给我们什么? 1.快速找到命令,无需使用Bing或者Google 2.运行命令时候返回了错误信息,帮助系统可以告诉我们如何正确使用该命令 3.多个命令组合执行完成复杂的工作,帮助系统告诉我 ...

  4. mysql 多个属性排序查询

    查询 排序(order by) 语法:order by 字段 asc/desc asc 顺序,正序.数值 :递增,字母:自然顺序(a-z) desc 倒序 反序 数值:递减, 字母:自然反序 查询的宗 ...

  5. 刮刮乐自定义view

    说明:该代码是参考鸿洋大神的刮刮乐自定义view来写的. 实现:刮刮乐-刮奖的效果,如下效果 下面直接放代码了:只有一个自定义view,要实现真正的功能还需要进一步封装 /** * 自定义view-刮 ...

  6. java nio消息半包、粘包解决方案

    问题背景 NIO是面向缓冲区进行通信的,不是面向流的.我们都知道,既然是缓冲区,那它一定存在一个固定大小.这样一来通常会遇到两个问题: 消息粘包:当缓冲区足够大,由于网络不稳定种种原因,可能会有多条消 ...

  7. Linux访问Window共享文件夹的配置步骤

    1. Window下创建用户XXX(作用:Linux mount时需要提供用户和密码) 2. Window下共享文件夹给XXX用户,并根据实际需要设置读取/写入权限 3. Linux下创建挂载的目录 ...

  8. Thinking in Java,Fourth Edition(Java 编程思想,第四版)学习笔记(二)之Introduction to Objects

    The genesis of the computer revolution was a machine. The genesis of out programming languages thus ...

  9. jquery 延迟执行方法

    setTimeout方法使用时需注意: //以下两种方式都行: setTimeout(function () { test(); }, ); //或者 setTimeout(); function t ...

  10. G - Number Transformation BFS

    In this problem, you are given an integer number s. You can transform any integer number A to anothe ...