CF1228C. Primes and Multiplication(数学)
Let’s introduce some definitions that will be needed later.
Let ?????(?) be the set of prime divisors of ?. For example, ?????(140)={2,5,7}, ?????(169)={13}.
Let ?(?,?) be the maximum possible integer ?? where ? is an integer such that ? is divisible by ??. For example:
?(45,3)=9 (45 is divisible by 32=9 but not divisible by 33=27),
?(63,7)=7 (63 is divisible by 71=7 but not divisible by 72=49).
Let ?(?,?) be the product of ?(?,?) for all ? in ?????(?). For example:
?(30,70)=?(70,2)⋅?(70,3)⋅?(70,5)=21⋅30⋅51=10,
?(525,63)=?(63,3)⋅?(63,5)⋅?(63,7)=32⋅50⋅71=63.
You have integers ? and ?. Calculate ?(?,1)⋅?(?,2)⋅…⋅?(?,?)mod(109+7).
Input
The only line contains integers ? and ? (2≤?≤109, 1≤?≤1018) — the numbers used in formula.
Output
Print the answer.
Examples
inputCopy
10 2
outputCopy
2
inputCopy
20190929 1605
outputCopy
363165664
inputCopy
947 987654321987654321
outputCopy
593574252
Note
In the first example, ?(10,1)=?(1,2)⋅?(1,5)=1, ?(10,2)=?(2,2)⋅?(2,5)=2.
In the second example, actual value of formula is approximately 1.597⋅10171. Make sure you print the answer modulo (109+7).
In the third example, be careful about overflow issue.
思路:求出x的素因子,求其在1-n中所有数的贡献
#include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<cmath> #include<stack> #include<cstdlib> #include<queue> #include<set> #include<string.h> #include<vector> #include<deque> #include<map> using namespace std; #define INF 0x3f3f3f3f #define eps 1e-10 #define bug printf("*********\n") #define debug(x) cout<<#x"=["<<x<<"]" <<endl typedef long long LL; typedef long long ll; const int MAXN = 150000 + 5; const int mod = 1e9 + 7;vector<LL>v; LL qpow(LL a,LL b) {LL res = 1;while(b) {if(b & 1)res = res * a % mod;a = a * a % mod;b >>= 1;}return res; }void primeFactor(LL n){LL tmp = n;if(n % 2 == 0) {v.push_back(2);while (n % 2 == 0) {n /= 2;}}for(LL i = 3; i * i <= tmp; i += 2){if(n % i == 0) {v.push_back(i);}while(n % i == 0){n /= i;}}if(n > 2)v.push_back(n); } int main() {LL x,n;cin >> x;cin >> n;primeFactor(x);LL ans = 1;for(int i = 0; i < v.size(); i++) {LL tt = 0,nn = n;while(nn > 0) {nn /= v[i];tt += nn;}ans = (ans % mod * qpow(v[i],tt)) % mod;}cout << ans << endl;}
View Code
转载于:https://www.cnblogs.com/smallhester/p/11614893.html
CF1228C. Primes and Multiplication(数学)相关推荐
- 史上最全的SGU题目分类
由于SGU上神题遍地,特列此表,便于训练时分类训练. 101 Domino 欧拉路 102 Coprime 枚举/数学方法 103 Traffic Lights 最短路 104 Little Shop ...
- UVA960 Gaussian Primes【数学】
The complex numbers a+bi, where i =−1\sqrt{−1}−1 and a and b are integers, are called the Gaussian ...
- 当代数学大师迈克尔阿蒂亚证明黎曼猜想
去9月24日,89岁高龄的当代数学大师迈克尔阿蒂亚先生亲自前往海德堡高级数学论坛公开证明黎曼猜想,此举吸引了全球数学界的目光. 阿蒂亚指出:黎曼猜想的核心问题是素数分布定理,两者关系密切.国人对此事件 ...
- 算法 64式 19、数学算法整理
1 算法思想 2 数学系列 类别-编号 题目 遁去的一 1 特殊乘法 写个算法,对2个小于1000000000的输入,求结果. 特殊乘法举例: 123 * 45 = 1*4 + 1*5 + 2*4 + ...
- 为什么您不需要精通数学就可以学习编程
by Pau Pavón 通过保罗·帕文(PauPavón) 为什么您不需要精通数学就可以学习编程 (Why you don't need to excel at math to learn how ...
- 红书《题目与解读》第一章 数学 题解《ACM国际大学生程序设计竞赛题目与解读》
整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 红书<题目与解读>第一章 数学 题解<ACM国际大学生程序设计竞赛题目与解读> ...
- 科技互联网公司越来越重视数学了,贾扬清等大牛如是说!
关注上方"深度学习技术前沿",选择"星标公众号", 资源干货,第一时间送达! 原贴链接:https://www.zhihu.com/question/37674 ...
- 科技互联网公司真的越来越重视数学了吗?
关注上方"深度学习技术前沿",选择"星标公众号", 资源干货,第一时间送达! 知乎高质量回答 一.作者:贾扬清 深度学习话题优秀回答者,阿里巴巴集团副总裁 ht ...
- 为什么科技互联网公司越来越重视数学?贾扬清等大牛如是说
机器之心编辑部 最近,第二届「阿里巴巴全球数学竞赛」正在紧锣密鼓地开展,仅预选赛题目的公布就引来了大量围观.这种数学竞赛的举办似乎透露出一个信号:科技互联网公司越来越重视数学了.为什么会出现这种现象? ...
最新文章
- 玩转CSDN博客之自定义博客栏目,根据需要定制栏目
- POJ-2777-CountColor(线段树,位运算)
- [矩形并-扫描线-线段树]Picture
- 75-商品服务-品牌分类关联与级联更新
- Java单例模式实现(线程安全)
- Java下载安装错误案例
- ARM——开发工具—编译器
- 【软件测试】离开“浪浪山“测试人迎来的春天......
- python计算器程序_python练习 计算器模拟程序
- 泉州计算机编程培训班,泉州编程小学生培训班
- JAVA学习路线图 【黑马版】
- 通信系统原理[郭宇春]——二元数字频带传输——课后习题答案
- Ai带你玩股票项目(正式版)推出说明
- OpenCV基础入门系列基本操作——贰
- 再见,北京,你好,沈阳
- 知识图谱(一):概念与构建
- FTP 登陆的常见问题与FTP命令集锦
- Node.js笔记:SerialPort(串口)模块使用(基于10.x.x)
- 什么是网管软件?网管平台软件
- U菜1G变化8M该解决方案
热门文章
- 微信里文件小程序导不出来_懒得打开电脑传文件?这四类小程序把这事解决了-小程序视频怎么发在电脑上...
- 股票型基金和期货有什么区别?
- 热水器是长期开着好还是要等到用的时候才开?
- 我们说的目标导向不是 “唯结果论”
- 找出消费者在使用你的产品的时候,什么时刻觉得“值了”
- 为什么现在选择单身的男生和女生越来越多
- 巴菲特对合伙人提过3个要求
- 电商并没有给我们创造一个就业机会
- 软件测试完后,还有bug,责任全在于测试吗?
- go Mutex (互斥锁)和RWMutex(读写锁)