日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

BZOJ 3884 上帝与集合的正确用法 (欧拉定理)

發布時間:2025/6/17 48 豆豆
生活随笔 收集整理的這篇文章主要介紹了 BZOJ 3884 上帝与集合的正确用法 (欧拉定理) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題目大意:求2^(2^(2^(2^(2^...)))) mod p的值    

題解:https://blog.csdn.net/popoqqq/article/details/43951401

#include <iostream> #include <cstdio> #include <cstring> #define ll long longusing namespace std;void read(int &k) {int f=1;k=0;char c=getchar();while(c<'0'||c>'9')c=='-'&&(f=-1),c=getchar();while(c<='9'&&c>='0')k=k*10+c-'0',c=getchar();k*=f; }ll phi(ll n) {ll rea=n;for(int i=2;i*i<=n;i++){if(n%i==0){rea=rea-rea/i;don/=i;while(n%i==0);}}if(n>1)rea=rea-rea/n;return rea; }ll quick_mod(ll a,ll b,ll c) {ll res,t;res=1;t=a%c;while(b){if(b&1){res=res*t%c;}t=t*t%c;b>>=1;}return res; }int T; int p;int Solve(int p) {if(p==1) return 0;int temp=0;//p=2^k*q;while(~p&1) p>>=1,++temp;//p為提取出來的奇數q,temp為2的多少次方int phi_p=phi(p);int re=Solve(phi_p);//回溯計算(re+=phi_p-temp%phi_p)%=phi_p;re=quick_mod(2,re,p)%p;return p; }int main() {read(T);while(T--){read(p);cout<<Solve(p)<<endl;}return 0; }

?

轉載于:https://www.cnblogs.com/Fy1999/p/9767524.html

總結

以上是生活随笔為你收集整理的BZOJ 3884 上帝与集合的正确用法 (欧拉定理)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。