Bryce1010模板

http://acm.hdu.edu.cn/showproblem.php?pid=6063

打表发现规律是n^k

  1. #include <iostream>
  2. #include<string.h>
  3. #include<cmath>
  4. using namespace std;
  5. #define ll long long
  6. const int MOD=1e9+7;
  7. const int MAXN=1e6;
  8. bool check[MAXN+10];
  9. int prime[MAXN+10];
  10. int mu[MAXN+10];
  11. void moblus()
  12. {
  13. memset(check,false,sizeof(check));
  14. mu[1]=1;
  15. int tot=0;
  16. for(int i=2;i<MAXN;i++)
  17. {
  18. if(!check[i])
  19. {
  20. prime[tot++]=i;
  21. mu[i]=-1;
  22. }
  23. for(int j=0;j<tot;j++)
  24. {
  25. if(i*prime[j]>MAXN)break;
  26. check[i*prime[j]]=true;
  27. if(i%prime[j]==0)
  28. {
  29. mu[i*prime[j]]=0;
  30. break;
  31. }
  32. else
  33. {
  34. mu[i*prime[j]]=-mu[i];
  35. }
  36. }
  37. }
  38. }
  39. ll pow_mod(ll a,ll n,ll mod)
  40. {
  41. ll ret=1;
  42. //ll tmp=a%mod;
  43. a=a%mod;
  44. while(n)
  45. {
  46. if(n&1)ret=(ret*a)%mod;
  47. a=a*a%mod;
  48. n>>=1;
  49. }
  50. return ret%MOD;
  51. }
  52. int main()
  53. {
  54. ll n,k;
  55. ll Case=1;
  56. while(cin>>n>>k)
  57. {
  58. cout<<"Case #"<<Case++<<": "<<pow_mod(n,k,MOD)%MOD<<endl;
  59. }
  60. return 0;
  61. }

HDU - 6063 RXD and math的更多相关文章

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

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

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

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

  3. 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 ...

  4. 数学--数论--HDU 6063 RXD and math (跟莫比乌斯没有半毛钱关系的打表)

    RXD is a good mathematician. One day he wants to calculate: output the answer module 109+7. p1,p2,p3 ...

  5. HDU 5628 Clarke and math——卷积,dp,组合

    HDU 5628 Clarke and math 本文属于一个总结了一堆做法的玩意...... 题目 简单的一个式子:给定$n,k,f(i)$,求 然后数据范围不重要,重要的是如何优化这个做法. 这个 ...

  6. 2017 多校3 hdu 6061 RXD and functions

    2017 多校3 hdu 6061 RXD and functions(FFT) 题意: 给一个函数\(f(x)=\sum_{i=0}^{n}c_i \cdot x^{i}\) 求\(g(x) = f ...

  7. HDU 6061 - RXD and functions | 2017 Multi-University Training Contest 3

    每次NTT都忘记初始化,真的是写一个小时,Debug两个小时- - /* HDU 6061 - RXD and functions [ NTT ] | 2017 Multi-University Tr ...

  8. HDU 6060 - RXD and dividing | 2017 Multi-University Training Contest 3

    /* HDU 6060 - RXD and dividing [ 分析,图论 ] | 2017 Multi-University Training Contest 3 题意: 给一个 n 个节点的树, ...

  9. RXD and math

    RXD and math 题目链接 思路 \(u\)函数是莫比乌斯函数,这个不影响做题,这个式子算的是\([1,n^k]\)中能够写成\(a*b^2\)的数的个数,\(u(a)!=0\).然后我们可以 ...

随机推荐

  1. adb问题整理

    1.开启了两个adb,关掉一个,重启eclipse既可 java.io.IOException: 您的主机中的软件中止了一个已建立的连接. at sun.nio.ch.SocketDispatcher ...

  2. DCOS之Mesos-DNS介绍

    DCOS的Mesos-DNS它主要提供域名解析服务,Mesos-DNS 在DCOS框架中支持服务发现,同意应用程序和服务通过域名系统(DNS)来相互定位.DCOS中的 Mesos-DNS充当的角色和在 ...

  3. MUI-折叠面板效果accordion

    在做开发的过程中我们经经常使用到折叠面板. 那我们来看下折叠面板到底是怎么使用. 废话不多说. 代码粘下来: <!DOCTYPE html> <html> <head&g ...

  4. Leetcode(58)题解:Length of Last Word

    https://leetcode.com/problems/length-of-last-word/ 题目: Given a string s consists of upper/lower-case ...

  5. VC 无边框对话框的任务栏右键菜单

    MFC ,基于对话框的程序,属性为:Border : none. 程序运行后,在任务栏里面点右键,不会弹出类似下面的菜单: 在对话框的OnInitDialog里面添加如下语句即可: ModifySty ...

  6. POJ 2586 Y2K Accounting Bug(枚举大水题)

    Y2K Accounting Bug Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10674   Accepted: 53 ...

  7. java获取class的几种方式

    以获取Hello.class为例 public class Hello { public static void main(String[] args) { // TODO Auto-generate ...

  8. the hard problems when writing a great connector; type cohersion, data partitioning and data locality to name a few

    http://rosslawley.co.uk/introducing-a-new=mongodb-spark-connector/

  9. Delphi之萝莉调教篇

    本文纯属技术交流.如果各位看官想与小生一起探讨萝莉的问题的话...PM我吧 关于Delphi的萝莉调教技术,很久以前就有大牛做过了...其实技术早掌握了只是觉得太无聊~估计大家也都会于是就没有写~既然 ...

  10. 提升自身的iOS编程水平 (转载)

    阅读博客 在现在这个碎片化阅读流行的年代,博客的风头早已被微博盖过.而我却坚持写作博客,并且大量地阅读同行的iOS开发博客.博客的文章长度通常在3000字左右,许多iOS开发知识都至少需要这样的篇幅才 ...