题解 CF630L Cracking the Code
前言
为什么没有人暴力快速幂啊,Ta不香嘛/kel
题意
设读入为 \(abcde\) ,求 \(acedb^5\mod{10^5}\) 的结果。
\(\sf {Solution}\)
显然暴力啊。
先把每一位求好然后把新数算出来。
快速幂就行了。
\(\sf {P.S.}\)
输出格式:一行,5个数字,没有间隔符。
若结果为 \(0\) 得输出00000。
\(\sf {Code}\)
#include<iostream>
using namespace std;
#define ll long long
ll n;
const int mod=100000;
ll f(ll x,ll y)
{
if(y==1)
return x;
ll q=f(x,y/2)%mod;
q=(q*q)%mod;
if(y%2==1)
return (q*x)%mod;
else return q%mod;
}//快速幂
int main()
{
ios::sync_with_stdio(false);
cin>>n;
ll m=(n/1000%10)+(n/10%10)*10+(n%10)*100+(n/100%10)*1000+(n/10000%10)*10000,q=f(m,5);//m为重新组装后的数
if(q==0)
cout<<"00000\n";//特判0
else cout<<q<<"\n";
return 0;
}
题解 CF630L Cracking the Code的更多相关文章
- Cracking the code interview
推荐一本书<Cracking the code interview> Now in the 5th edition, Cracking the Coding Interview gives ...
- 【读书笔记】Cracking the Code Interview(第五版中文版)
导语 所有的编程练习都在牛客网OJ提交,链接: https://www.nowcoder.com/ta/cracking-the-coding-interview 第八章 面试考题 8.1 数组与字符 ...
- Cracking the Code Interview 4.3 Array to Binary Tree
Given a sorted (increasing order) array, write an algorithm to create a binary tree with minimal hei ...
- LeetCode题解之Unique Morse Code Words
1.题目描述 2.题目分析 将words 中的每一个string 直接翻译成对应的Morse 码,然后将其放入 set 中,最后返回set的大小即可,此处利用的set 中元素不重复的性质. 3.代码 ...
- 【Cracking the Code Interview(5th edition)】二、链表(C++)
链表结点类型定义: class Node { public: ; Node *next = nullptr; Node(int d) { data = d; } }; 快行指针(runner)技巧: ...
- 【Cracking the Code Interview(5th edition)】一、数组与字符串(C++)
1.1 实现一个算法,确定一个字符串的所有字符是否全都不同.不允许使用额外的数据结构. 解答:这里假定字符集为ASCII码,可以与面试官沟通确认字符串使用的字符集.由于字符集是有限的,建立一个数组模拟 ...
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) A B C D 水 模拟 并查集 优先队列
A. Broken Clock time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- CSP2019 题解
CSP2019 题解 D1T1 格雷码(code) 题目传送门 https://loj.ac/problem/3208 题解 按照题意模拟就可以了. 对于第 \(i\) 位,如果 \(k \geq 2 ...
- 【BZOJ-3696】化合物 树形DP + 母函数(什么鬼)
3696: 化合物 Time Limit: 10 Sec Memory Limit: 512 MBSubmit: 165 Solved: 85[Submit][Status][Discuss] D ...
随机推荐
- Web 布局设计(一):固定侧边栏
前言 闲着无事,做一些实战练习,今天实现一个如标题所示的布局设计.通过此次布局设计,我希望掌握position属性值 fixed.absolute.relative.width和height属性值 i ...
- [NOIP2018提高组] 保卫王国 (树链剖分+动态DP)
题面 题目链接-Luogu 题目链接-Loj(要加Freopen) 题解 什么是动态DP? OneInDark:你不需要知道这么多,你只需要知道是利用了广义矩阵乘法就够了! 广义矩乘 广义矩阵乘法,简 ...
- 免杀手法-tcp套字节传递shellcode学习
免杀手法-tcp套字节传递shellcode学习
- C#使用BouncyCastle生成PKCS#12数字证书
背景 生成数字证书用于PDF文档数字签名 数字证书需要考虑环境兼容性,如linux.windows 网上资料不全或版本多样 本文章主要介绍了在C#中使用BouncyCastle生成PKCS#12个人信 ...
- KFS replicator安装(KES-KES)
源端 一.安装前置配置 1.创建安装用户 groupadd flysync useradd flysync -g flysync -G kingbase passwd flysync 2.上传安装文件 ...
- C语言001--hello world编译详解
1.编写hello.c程序,并编译运行 book@100ask:~/linux/c01$ cat hello.c -n 1 #include <stdio.h> 2 3 int main( ...
- Rust基本数据类型
基本类型 Rust 每个值都有其确切的数据类型,总的来说可以分为两类:基本类型和复合类型. 基本类型意味着它们往往是一个最小化原子类型,无法解构为其它类型(一般意义上来说),由以下组成: 数值类型: ...
- Elastic:菜鸟上手指南
文章链接:https://elasticstack.blog.csdn.net/article/details/102728604
- 7.第六篇 二进制安装 kube-apiserver
文章转载自:https://mp.weixin.qq.com/s?__biz=MzI1MDgwNzQ1MQ==&mid=2247483812&idx=1&sn=e6773e56 ...
- Linux服务器上MinIO生产部署的内核调优
#!/bin/bash cat > sysctl.conf <<EOF # maximum number of open files/file descriptors fs.file ...