首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
AORIE
2026年3月25日 10:27
幂次方 题解:快速幂
P1017
回复 0
|
赞 4
|
浏览 65
#include <stdio.h> long long ksm(long long x,long long n,long long num){ long long r =1; while(n){ if(n%2==1){ r = (r*x)%num; } x=(x*x)%num; n=n/2; } return r; } int main(){ long long x,n; scanf("%lld%lld",&x,&n); printf("%lld",ksm(x,n,233333));...
Tyu0871
2026年3月21日 09:02
幂次方 题解:按照题意
P1017
回复 0
|
赞 9
|
浏览 202
我太菜了我太菜了我太菜了我太菜了我太菜了我太菜了我太菜了 我太菜了我太菜了我太菜了我太菜了我太菜了我太菜了我太菜了 #include<bits/stdc++.h> using namespace std; //long long mypow(long long n,long long x){ 这个写法会TLE,超时说是 // if(n<=0) return 1; // if(n==1) return x; // if(n%2==0) return mypow(n/2,x)*mypow(n/2,x) % 233333; // ...
磊磊公爵
2026年3月18日 11:42
幂次方 题解:得用快速幂
P1017
回复 0
|
赞 2
|
浏览 138
//#pragma GCC optimize(3) #include<bits/stdc++.h> #define rep(i,a,n) for(ll i=a;i<=n;i++) #define per(i,a,n) for(ll i=a;i>=n;i--) #define TLE ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); #define pii pair<int,int> #define fi first #define se second...
ZeroQi_404
2026年3月15日 21:02
幂次方 题解:
P1017
回复 0
|
赞 14
|
浏览 157
#include <iostream> using namespace std; long long mod = 233333; long long power(long long x,long long n){ long long ans = 1; while(n){ if(n%2) ans = ans * x % mod; x = x*x %mod; n /=2; } return ans; } int main(){ long long x,n; cin >> x >>...
userCao
2026年3月13日 22:03
幂次方 题解:C语言快速幂
P1017
回复 0
|
赞 11
|
浏览 245
#include<stdio.h> #define mod 233333//定义模数大小 typedef long long ll;//重命名long long为ll ll ksm(ll x,ll y,ll p)//快速幂公式,(a*b)%m=(a%b*b%b)%b,可类比加减法 { int res=1;//初始化结果 x=x%p;//先处理底数,防止太大,结果是一样的 while(y!=0)//指数可以看为二进制,为2^n加在一块的,二进制位相加 ...
Jinx_K
2026年3月11日 10:59
幂次方 题解:
P1017
回复 0
|
赞 1
|
浏览 147
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll pow_x(ll a,ll b,ll c) { ll add=1; while(b!=0) { if(b&1) add=(a*add)%c; a=(a*a)%c; b>>=1; } return add; } int main() { ll X,N; cin>>X>>N; cout<<pow_x(X,N...
uly
2026年3月5日 15:05
幂次方 题解:
P1017
回复 0
|
赞 14
|
浏览 243
#include <bits/stdc++.h> using namespace std; long long method(long long x,long long n,int mod) { long long ans=1; while (n > 0) { if (n&1) { ans =ans * x % mod; } x = x*x%mod; n=n>>1; } return ans; ...
牧濑
2026年2月24日 14:06
幂次方 题解:二进制快速幂原理
P1017
回复 0
|
赞 15
|
浏览 352
#include <iostream> using namespace std; //如n=30,对应二进制为111110,权重为16+8+4+2+1+0 long long fastPow(long long x,int n,int mod){ long long res=1; x=x%mod; while(n>0){ //当前权位为1时才乘,为0不乘,比如n=24,11000,只乘16和8 if(n%2==1)res=res*x%mod;//奇数==最后位是1 x=x*x%mod;//第一次x变成x²,用...
yauqq
2026年2月6日 11:05
幂次方 题解:
P1017
回复 0
|
赞 16
|
浏览 424
#include<bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD = 233333; ll power(ll x, ll n) { ll res = 1; while (n) { if (n % 2 == 1) res = res * x % MOD; x = x * x % MOD; n /= 2; } return res; } int main() {...
mlx
2026年1月30日 10:41
幂次方 题解:
P1017
回复 0
|
赞 5
|
浏览 248
#include<iostream> using namespace std; typedef long long ll; const int mod=233333; ll mi(ll a,ll b) { ll ans=1; while(b) { if(b&1) ans=ans*a%mod; b>>=1; a=a*a%mod; } return ans; } int main() { ll a,b; cin>>a>>b; cout<&...
1
2
3
4
题目
幂次方
题解数量
36
发布题解
在线答疑
热门题解
1
1017 幂次方 快速幂模板
2
幂次方 题解:数据类型统一longlong
3
幂次方 题解:运用二分快速幂思想和同余模定理即可。
4
幂次方 题解:
5
幂次方 题解:
6
幂次方 题解:
7
幂次方 题解:二进制快速幂原理
8
幂次方 题解:
9
幂次方 题解:
10
幂次方 题解:C语言快速幂