算是一题普通数论+思维题吧。

大概很多人是被题意绕晕了。

思路:

   首先常规操作求出X的质因子。

   然后题目要求的是,X的每个质因子p,在g(i,p)的连乘。i∈[1,n];

   我们转换下思维,不求每一个g(i,p)中最终是哪些 p的幂次,而是反求 每个p的幂次对结果的贡献。

   显而易见,p^k在1~n的出现的次数就是  [n/(p^k)].

   这样枚举所有质因子,计算中再利用快速幂取模便可以得到答案

//#pragma comment(linker, "/STACK:1024000000,1024000000")
//#pragma GCC optimize(2)
#include <bits/stdc++.h> using namespace std;
typedef double dou;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<int, int> mii; #define pai acos(-1.0)
#define M 200007
#define inf 0x3f3f3f3f
#define mod 1000000007
#define IN inline
#define W(a) while(a)
#define lowbit(a) a&(-a)
#define left k<<1
#define right k<<1|1
#define lson L, mid, left
#define rson mid + 1, R, right
#define ms(a,b) memset(a,b,sizeof(a))
#define Abs(a) (a ^ (a >> 31)) - (a >> 31)
#define random(a,b) (rand()%(b+1-a)+a)
#define false_stdio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0) ll x, n;
ll ans = ;
vector<ll>num; void init(ll tmp) {
for (ll i = ; i * i <= tmp; i++) {
if (tmp % i == ) {
num.push_back(i);
W(tmp % i == )tmp /= i;
}
}
if (tmp != )num.push_back(tmp);
} ll Pow(ll base, ll sup) {
ll sum = ;
W(sup) {
if (sup & )sum = (sum * base) % mod;
sup >>= ;
base = (base * base) % mod;
}
return sum % mod;
} int main() {
false_stdio;
cin >> x >> n;
init(x);
for (auto p : num) {
ll tmp = ;
W(tmp <= n / p) {//条件应该理解为 tmp*p<=n,而n%p==0,所以可以利用除法防止爆精度
tmp *= p;
ans = (ans * Pow(p, n / tmp)) % mod;
}
}
cout << ans << endl;
return ;
}

code force 1228C的更多相关文章

  1. pycharm debug后会出现 step over /step into/step into my code /force step into /step out 分别表示

    1.debug,全部打印 2.打断点debug,出现单步调试等按钮,只运行断点前 3.setup over 调试一行代码 4.setup out 运行断点后面所有代码 5.debug窗口显示调试按钮 ...

  2. 【Code Force】Round #589 (Div. 2) D、Complete Tripartite

    题目链接 大致题意 把一个图分成三块,要求任意两块之间是完全图,块内部没有连线 分析 首先根据块内没有连线可以直接分成两块 假定点1是属于块1的,那么所有与点1连接的点,都不属于块1:反之则是块1的 ...

  3. code force 424 A - Office Keys

    There are n people and k keys on a straight line. Every person wants to get to the office which is l ...

  4. code force 403C.C. Andryusha and Colored Balloons

    C. Andryusha and Colored Balloons time limit per test 2 seconds memory limit per test 256 megabytes ...

  5. code force 403B.B. The Meeting Place Cannot Be Changed

    B. The Meeting Place Cannot Be Changed time limit per test 5 seconds memory limit per test 256 megab ...

  6. code force 401B. Game of Credit Cards

    B. Game of Credit Cards time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  7. Code Force 21B Intersection

    B. Intersection time limit per test1 second memory limit per test256 megabytes inputstandard input o ...

  8. Code Force 429B Working out【递推dp】

    Summer is coming! It's time for Iahub and Iahubina to work out, as they both want to look hot at the ...

  9. .htaccess 基础教程(三)RewriteCond标志符,RewriteRule适用的标志符

    1.利用 .htaccess 防止盗链 如果不喜欢别人在他们的网页上链接自己的图片.文档的话,也可以通过htaccess的指令来做到.当然这样也可以对你的网站服务器压力变小! 这次先给出‘代码’,然后 ...

随机推荐

  1. 《动手学深度学习》系列笔记 —— 语言模型(n元语法、随机采样、连续采样)

    目录 1. 语言模型 2. n元语法 3. 语言模型数据集 4. 时序数据的采样 4.1 随机采样 4.2 相邻采样 一段自然语言文本可以看作是一个离散时间序列,给定一个长度为\(T\)的词的序列\( ...

  2. 7.5 Varnish VCL的变量和应用片段

  3. setTimeout的异步

    http://www.cnblogs.com/littledu/articles/2607211.html http://www.cnblogs.com/rubylouvre/archive/2009 ...

  4. 《ES6标准入门》(阮一峰)--7.数值的扩展

    1.二进制和八进制表示法 ES6 提供了二进制和八进制数值的新的写法,分别用前缀0b(或0B)和0o(或0O)表示. 0b111110111 === 503 // true 0o767 === 503 ...

  5. S7-200 smart输入输出接口试验

    工具 西门子 s7-200smart PLC 西门子s7-200 smart 试验 CPU型号是 SR30 这个 编译环境 符号 选择 了 "输入1"以后, 会自动的编地址为I0. ...

  6. P1054 求平均值

    P1054 求平均值 转跳点:

  7. Kafka--生产者

    一个应用程序在很多情况下需要往Kafka写入消息:记录用户的活动(用于审计和分析),记录度量指标,保存日志消息,记录智能家电的信息,与其他应用程序进行异步通信,缓冲即将写入到数据库的数据,等等. 多样 ...

  8. 官网英文版学习——RabbitMQ学习笔记(十)RabbitMQ集群

    在第二节我们进行了RabbitMQ的安装,现在我们就RabbitMQ进行集群的搭建进行学习,参考官网地址是:http://www.rabbitmq.com/clustering.html 首先我们来看 ...

  9. linux添加一个已经存在用户到一个用户组

    在使用virtual-box的共享文件时,在虚拟机中共享文件的用户为root,用户组为vboxsf, 所以需要将自己添加到vboxsf这组当中去,一开始使用useradd老是失败,后来才查到要用use ...

  10. 一百零五、SAP中ALV事件之十七,让ALV表格修改后保存到数据库

    一.我们来到代码界面设置保存按钮的代码 二.i_grid_settings这个属性用来编辑单元格之后,返回给程序编辑后的值 三.我们双击点  'REUSE_ALV_GRID_DISPLAY',来到定义 ...