LightOJ1282 Leading and Trailing
题面
给定两个数n,k 求n^k的前三位和最后三位
Input
Input starts with an integer T (≤ 1000), denoting the number of test cases.
Each case starts with a line containing two integers: n (2 ≤ n < 2^31) and k (1 ≤ k ≤ 10^7).
Solution
后面一问是搞笑的
前面一问?
也是搞笑的,用double除成小于1的数算就好了
滑稽题
# include <bits/stdc++.h>
# define RG register
# define IL inline
# define Fill(a, b) memset(a, b, sizeof(a))
using namespace std;
typedef long long ll;
IL ll Read(){
char c = '%'; ll x = 0, z = 1;
for(; c > '9' || c < '0'; c = getchar()) if(c == '-') z = -1;
for(; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0';
return x * z;
}
ll n, k, ansr, ansl;
IL ll Powr(RG ll x, RG ll y, RG ll MOD){
RG ll cnt = 1;
for(; y; y >>= 1, x = x * x % MOD) if(y & 1) cnt = cnt * x % MOD;
return cnt;
}
IL double Powl(RG double x, RG ll y){
while(x >= 1) x /= 10; RG double cnt = 1.0;
for(; y; y >>= 1){
if(y & 1){
cnt = cnt * x;
while(cnt < 0.1) cnt *= 10;
}
x = x * x;
while(x < 0.1) x *= 10;
}
while(cnt < 100) cnt *= 10;
return cnt;
}
int main(RG int argc, RG char *argv[]){
for(RG int T = Read(), i = 1; i <= T; ++i){
n = Read(); k = Read();
ansl = Powl(n, k); ansr = Powr(n, k, 1000);
printf("Case %d: %lld ", i, ansl);
printf("%lld%lld%lld\n", ansr / 100, (ansr % 100) / 10, ansr % 10);
}
return 0;
}
LightOJ1282 Leading and Trailing的更多相关文章
- LightOJ1282 Leading and Trailing —— 指数转对数
题目链接:https://vjudge.net/problem/LightOJ-1282 1282 - Leading and Trailing PDF (English) Statistics ...
- LightOJ-1282 Leading and Trailing 模算数 快速幂 对数的用法
题目链接:https://cn.vjudge.net/problem/LightOJ-1282 题意 给出两个正整数n(2 ≤ n < 231), k(1 ≤ k ≤ 1e7) 计算n^k的前三 ...
- 【LightOJ1282】Leading and Trailing(数论)
[LightOJ1282]Leading and Trailing(数论) 题面 Vjudge 给定两个数n,k 求n^k的前三位和最后三位 题解 这题..真的就是搞笑的 第二问,直接输出快速幂\(m ...
- LightOJ 1282 Leading and Trailing (快数幂 + 数学)
http://lightoj.com/volume_showproblem.php?problem=1282 Leading and Trailing Time Limit:2000MS Me ...
- Leading and Trailing (数论)
Leading and Trailing https://vjudge.net/contest/288520#problem/E You are given two integers: n and k ...
- Leading and Trailing(数论/n^k的前三位)题解
Leading and Trailing You are given two integers: n and k, your task is to find the most significant ...
- UVA-11029 Leading and Trailing
Apart from the novice programmers, all others know that you can’t exactly represent numbers raised t ...
- E - Leading and Trailing 求n^k得前三位数字以及后三位数字,保证一定至少存在六位。
/** 题目:E - Leading and Trailing 链接:https://vjudge.net/contest/154246#problem/E 题意:求n^k得前三位数字以及后三位数字, ...
- UVA 11029 || Lightoj 1282 Leading and Trailing 数学
Leading and Trailing You are given two integers: n and k, your task is to find the most significant ...
随机推荐
- cnblogs的使用
cnblogs的使用 选择使用cnblogs而不是csdn,答案是很明显的.csdn每次创建博客之后会有一段时间的审核期,这大大的影响了用户体验.此外,cnblogs的用户群以及使用模式有着很大的诱惑 ...
- Linux 安装配置 FTP 服务 (vsftpd)
1. 安装 vsftpd yum install vsftpd -y 2. 创建用户 record adduser -s /bin/nologin -d /var/RecordFile/ record ...
- 洛谷P4014 分配问题【最小/大费用流】题解+AC代码
洛谷P4014 分配问题[最小/大费用流]题解+AC代码 题目描述 有 n 件工作要分配给 n 个人做.第 i 个人做第 j 件工作产生的效益为c ij. 试设计一个将 n 件工作分配给 n 个人做的 ...
- llinux基本指令
1.关机重启1)关机shutdown -h now (立刻关机)shutdown -h 5 (5分钟后关机)2)重启shutdown -r now (立刻重启)shutdown -r 5 (5分钟后重 ...
- ElasticSearch 5.0.0 集群安装部署文档
1. 搭建环境 3台物理机 操作系统 centos7 es1 192.168.31.141 4g内存 2核 es2 192.168.31.142 4g内存 2核 es3 ...
- 业余草分享 Spring Boot 2.0 正式发布的新特性
就在昨天Spring Boot2.0.0.RELEASE正式发布,今天早上在发布Spring Boot2.0的时候还出现一个小插曲,将Spring Boot2.0同步到Maven仓库的时候出现了错误, ...
- scrapy的学习总结(1)
1.xpath和css的节点的共同结合使用是一个挺好的使用过程,还有就是配合正则表达式的使用,这个也是很重要的.解决任何一个问题都会有不同方法.学会思考的解决问题. 2.item的数据抽取,pipel ...
- 借鉴mini2440的usb-wifi工具集在Beagleboard上移植无线网卡
配置minicom: sudo yum install minicom sudo minicom -s 选择Serial port setup,此时所示光标在"Change which se ...
- 3.3.1 Cache一致性的基本概念
PCI设备对可Cache的存储器空间进行DMA读写的操作的过程较为复杂,有关Cache一致性的话题可以独立成书.而不同的处理器系统使用的Cache Memory的层次结构和访问机制有较大的差异,这部分 ...
- GOF23种设计模式精解
创建型 1. Factory Method(工厂方法) 2. Abstract Factory(抽象工厂) 3. Builder(建造者) 4. Prototype(原型) 5. Singleton( ...