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
;
}
查看全文
相关阅读:
ie10 css3 transition 过渡
asp.net之一步一个脚印
MyEclipse安装aptana插件的问题(link方式)转
MyEclipse的Aptana插件中配置ZenCoding成功
PS CS6 安装错误:FATAL: Payload '{3F0238754A5246059DB6A88D4A813E8D} Camera Profiles Installer 6.0.98.0' information not found in Media_db.
PC客户端的开发插件Eclipse RCP
Silverlight获取焦点
广而告知
wpf窗体定位
surface开发教程[ScatterView控件] 二.
原文地址:https://www.cnblogs.com/sysu-zhengwsh/p/3674196.html
最新文章
XtrGrid 禁用特定单元格
ROW_NUMBER() OVER函数的基本用法用法
反射调用 pictureedit 菜单功能
关于SQL SERVER 2008从suspect状态恢复DB
横着有多长,竖起来就有多高
一行中只能选择一个列的值
如何启用 Windows Installer 日志记录
C#QRCode二维码生成的使用笔记
sqlserver2008 express使用命令行模式设置混合登模式
NET 2.0 OCR文字识别技术(Tesseract 引擎)
热门文章
C# CultureInfo列表
Lucene.net 开发记录
揭秘全球最大网站Facebook背后的那些软件
在Asp.net 4.0 中动态注册HttpModule
C#正则表达式整理备忘
一些必不可少的Sublime Text 2插件
ASP.net 视频上传转换flv并且抓取第一帧生成图片源码
HTTP could not register URL http://+:8000/testservice/. Your...
解决"There is already an open DataReader associated with this Command which must be closed first." exception in EF 中
ie10 3D变换
Copyright © 2011-2022 走看看