51nod 1004 n^n的末位数字【快速幂】
一个数N(1 <= N <= 10^9)
输出N^N的末位数字
13
3 【代码】:
#include <bits/stdc++.h> using namespace std;
#define LL long long
LL n; int main()
{
while(~scanf("%lld",&n))
{
LL ans=,tmp=n;//改变位数,所以要临时变量
while(n)
{
if(n&)
{
ans=ans*tmp%;
}
tmp=tmp*tmp%;//改变位数的地方用临时变量
n>>=;
}
printf("%lld\n",ans);
}
return ;
}
51nod 1004 n^n的末位数字【快速幂】的更多相关文章
- 51Nod 1004 n^n的末位数字(日常复习快速幂,莫名的有毒,卡mod值)
1004 n^n的末位数字 题目来源: Author Ignatius.L (Hdu 1061) 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题 给出一个整数N,输出 ...
- 51Nod 1004 n^n的末位数字
思路:首先将0~9的平方的尾数放在一个数组a里面,方便后面直接调用,因为不论多大的数做什么运算,得到的结果的最后一位数只和运算前所有数的最后一位数有关系.新建变量d,z一个是底数,一个是幂次.循环判断 ...
- 1001 数组中和等于K的数对 1002 数塔取数问题 1003 阶乘后面0的数量 1004 n^n的末位数字 1009 数字1的数量
1001 数组中和等于K的数对 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题 给出一个整数K和一个无序数组A,A的元素为N个互不相同的整数,找出数组A中所有和等于K ...
- 1004 n^n的末位数字
题目来源: Author Ignatius.L (Hdu 1061) 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题 给出一个整数N,输出N^N(N的N次方)的十 ...
- 51 Nod N^N的末位数字
1004 n^n的末位数字 题目来源: Author Ignatius.L (Hdu 1061) 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题 收藏 关注 给 ...
- 51nod1004 n^n的末位数字
题目来源: Author Ignatius.L (Hdu 1061) 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题 收藏 关注 给出一个整数N,输出N^N(N的 ...
- nod_1004 n^n的末位数字(二分快速幂)
题意: 给出一个整数N,输出N^N(N的N次方)的十进制表示的末位数字. Input 一个数N(1 <= N <= 10^9) OutPut 输出N^N的末位数字 思路: EASY,,,, ...
- 51Nod 1046 A^B Mod C(日常复习快速幂)
1046 A^B Mod C 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 给出3个正整数A B C,求A^B Mod C. 例如,3 5 8,3^5 Mod 8 = ...
- 51Nod 1004 n^n末尾数字 | 快速幂
#include "bits/stdc++.h" using namespace std; #define LL long long #define INF 0x3f3f3f3f3 ...
随机推荐
- Object Pascal中文手册 经典教程
Object Pascal 参考手册 (Ver 0.1)ezdelphi@hotmail.com OverviewOverview(概述)Using object pascal(使用 object p ...
- USACO Section2.2 Subset Sums 解题报告 【icedream61】
subset解题报告------------------------------------------------------------------------------------------ ...
- php导出数据为CSV文件DEMO
代码示例: private function _download_send_headers($filename) { // disable caching $now = gmdate("D, ...
- MySQL高可用之MHA安装
Preface MasterHA is a tool which can be used in MySQL HA architecture.I'm gonna implement it ...
- jenkins 连接服务器并运行脚本
1.登录,在系统管理——节点管理——新增节点——配置从节点,添加远程工作目录,选择启动方式:通过JAVA WEB启动代理,添加JDK 2.在列表点节点,点launch下载插件,放到D:\JENKINS ...
- Unity-SendMessage
每一个对象都有SendMessage,BroadcastMessage,SendMessageUpwards 三个发送消息的方法! 1.功能: 执行某个对象中的某个方法! 2.实现原理 反射 ...
- ASP.NET Core 认证与授权[1]:初识认证 (笔记)
原文链接: https://www.cnblogs.com/RainingNight/p/introduce-basic-authentication-in-asp-net-core.html 在A ...
- sshd_config_for_centos
# $OpenBSD: sshd_config,v // :: djm Exp $ # This is the sshd server system-wide configuration file. ...
- A. Vasya and Book
题目原址 http://codeforces.com/contest/1082/problem/A 题目内容 一共n页书,现在位于第x位,想要看第y页,每次只能翻d页,注意总能翻到第1页和第n页. V ...
- leetcode_day02
任务二:删除排序数组中的重复项 原文链接:https://leetcode-cn.com/problems/remove-duplicates-from-sorted-array/ 最开始的解决思路: ...