zoukankan
html css js c++ java
快速幂取模
Given a b and p, output (a^b) % p (2<=a<=100, 0<=b<=1000000000, 3<=p<=10000)
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
int
quick_power
(
int
a
,
int
b
,
int
p
)
{
int
temp
;
if
(
b
==
0
)
{
return
1
;
}
temp
=
quick_power
(
a
,
b
/
2
,
p
);
if
(
b
&
1
)
{
return
(((
temp
*
temp
)
%
p
)
*
(
a
%
p
))
%
p
;
}
else
{
return
(
temp
*
temp
)
%
p
;
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
a
,
b
,
p
;
while
(~
scanf
(
"%d%d%d"
,
&
a
,
&
b
,
&
p
))
{
printf
(
"%d "
,
quick_power
(
a
,
b
,
p
));
}
return
0
;
}
查看全文
相关阅读:
form表单有条件的提交
当月第一天、最后一天、下月第一天,时间date
网站分享
如何做浏览器网站搜索
js关闭当前页面跳转新页面
img图片居中
laravel 重定向路由带参数
线段判严格相交+思维——poj1066
线段判非严格相交+暴力——poj2653
线段判严格相交+最短路建图——poj1556
原文地址:https://www.cnblogs.com/sysu-zhengwsh/p/3674196.html
最新文章
linux dev目录
linux管道和重定向
linux目录/术语/英文
缓冲区整理
linux文件系统-基本磁盘2
文件系统——基本磁盘
url
Educational Codeforces Round 36
Educational Codeforces Round 16
Educational Codeforces Round 13
热门文章
P3374 【模板】树状数组 1
Codeforces Round #375 (Div. 2)
Educational Codeforces Round 27
Codeforces Round #452 (Div. 2)
Codeforces Round #451 (Div. 2)
Codeforces Round #448 (Div. 2)C. Square Subsets
面向抽象/接口编程以及继承
显示,隐藏某一区域
layer弹窗的跳转功能
laravel判断是否post传输
Copyright © 2011-2022 走看看