博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
loj #162. 快速幂 2 (数论)
阅读量:3899 次
发布时间:2019-05-23

本文共 418 字,大约阅读时间需要 1 分钟。

【题解】

令 S=p^{\frac{1}{2}}+1 ,则 x^a=x^{amodS}*x^{\left \lfloor \frac{a}{S} \right \rfloor*S}

【代码】

#include 
using namespace std;typedef long long ll;const ll mod=998244352;const int S=31596;ll a[32000],b[32000];int main(){ ll x; int n; scanf("%lld%d",&x,&n); a[0]=1,b[0]=1; for(int i=1;i<=S;i++) a[i]=a[i-1]*x%mod; for(int i=1;i<=S;i++) b[i]=b[i-1]*a[S]%mod; for(int i=1;i<=n;i++){ ll aa; scanf("%lld",&aa); printf("%lld ",a[aa%S]*b[aa/S]%mod); }}

 

转载地址:http://ihfen.baihongyu.com/

你可能感兴趣的文章
glibc 指导委员会解散声明
查看>>
Linux创始者托瓦兹谈及IoT --「安全在其次」
查看>>
传感器数据分析(Sensor Data Analytics)是什么?
查看>>
智能硬件开发如何选择低功耗MCU?
查看>>
阿里感悟(十)如何写好简历
查看>>
阿里感悟(十一)如何准备面试
查看>>
软件架构入门
查看>>
80 多个 Linux 系统管理员必备的监控工具
查看>>
OOD的原则
查看>>
Tool to trace local function calls in Linux
查看>>
Linux 下查询 DNS 服务器信息
查看>>
ulimit 里的 file size 的 block 单位是多少?
查看>>
linux下查看端口对应的进程
查看>>
将 gdb 用作函数跟踪器 (Function Tracer)
查看>>
原 GCC一些有用的技巧
查看>>
yum 变量追加的方法
查看>>
2倍速的下一代Bluetooth,「Bluetooth 5」发布
查看>>
Top 10 “Yum” installables to be productive as a developer on Red Hat Enterprise Linux
查看>>
[小技巧] Vim 如果去除 “existing swap file” 警告
查看>>
如何在linux下检测内存泄漏
查看>>