题面

给定两个数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的更多相关文章

  1. LightOJ1282 Leading and Trailing —— 指数转对数

    题目链接:https://vjudge.net/problem/LightOJ-1282 1282 - Leading and Trailing    PDF (English) Statistics ...

  2. LightOJ-1282 Leading and Trailing 模算数 快速幂 对数的用法

    题目链接:https://cn.vjudge.net/problem/LightOJ-1282 题意 给出两个正整数n(2 ≤ n < 231), k(1 ≤ k ≤ 1e7) 计算n^k的前三 ...

  3. 【LightOJ1282】Leading and Trailing(数论)

    [LightOJ1282]Leading and Trailing(数论) 题面 Vjudge 给定两个数n,k 求n^k的前三位和最后三位 题解 这题..真的就是搞笑的 第二问,直接输出快速幂\(m ...

  4. LightOJ 1282 Leading and Trailing (快数幂 + 数学)

    http://lightoj.com/volume_showproblem.php?problem=1282 Leading and Trailing Time Limit:2000MS     Me ...

  5. Leading and Trailing (数论)

    Leading and Trailing https://vjudge.net/contest/288520#problem/E You are given two integers: n and k ...

  6. Leading and Trailing(数论/n^k的前三位)题解

    Leading and Trailing You are given two integers: n and k, your task is to find the most significant ...

  7. UVA-11029 Leading and Trailing

    Apart from the novice programmers, all others know that you can’t exactly represent numbers raised t ...

  8. E - Leading and Trailing 求n^k得前三位数字以及后三位数字,保证一定至少存在六位。

    /** 题目:E - Leading and Trailing 链接:https://vjudge.net/contest/154246#problem/E 题意:求n^k得前三位数字以及后三位数字, ...

  9. 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 ...

随机推荐

  1. 讲解mybaits的标签语法

    前言:mybatis作为一个持久层的java框架,高度封装了jdbc原始代码,它拥有比Hiberante更便捷.更直接的sql语法和sql灵活配置的特性,比如简单的一个自动映射对象就大大减少了我们的代 ...

  2. esxi 改变虚拟机磁盘格式为精简存储

    最近在部署虚拟机,导入几个之前保存的ovf模板,发现存储已经被耗费的差不多了.检查了下磁盘存储格式 存储类型是 后置备延迟置零 占用空间 简单了解下 三种存储类型 1.厚置备延迟置零: 默认的创建格式 ...

  3. Linux常见目录及其作用

    在Linux操作系统中,所有文件和目录都被组织成一个以根节点开始的倒置的树状结构.如下图 系统一般以 / 来表示根目录.在根目录之下的可以是目录也可以是文件,而每一个目录中又可以包含子目录文件.如此反 ...

  4. mongodb的TTL索引介绍(超时索引)

    TTL索引是mongodb新支持的用于延时自动删除记录的一种索引.它仅包含一个字段,该字段值需要是Date()类型,并且不支持复合索引.可以指定某条记录在延时固定时间后自动删除.数据自动超时删除主要用 ...

  5. Maven常用命令及在Eclipse中的应用

    1.常用命令 mvn archetype:generate--构建项目 mvn clean--项目清理 mvn test--项目单元测试的编译 mvn compile--项目源代码的编译 mvn pa ...

  6. PHP实现水印效果(文字、图片)

    第一种 <?php /** * 功能:给一张图片加上水印效果 * $i 要加水印效果的图片 * $t 水印文字 * $size 文字大小 * $pos 水印的位置 * $color 文字的颜色 ...

  7. 沉淀,再出发——安装windows10和ubuntu kylin15.04双系统心得体会

    安装windows10和ubuntu kylin15.04双系统心得体会 一.安装次序      很简单,两种安装次序,"先安装windows后安装linux:先安装linux后安装wind ...

  8. uva 1151最小生成树

    先求一次最小生成树,可以排除n*(n*1)/2-(n-1)条边,每次利用二进制法枚举套餐的选择,套餐中的点直接处理,如果两个套餐有公共点直接合并,他们一定连通,然后枚举第一步最小生成树得到的n-1条边 ...

  9. [Code] 中缀式转后缀式

    [Code] 中缀式转后缀式 概要 对于一个可带括号的中缀四则运算表达式, 例如30 + 4 / 2 或 30 / ( 4 + 2 ), 下面代码将分别转换为对应的后缀表达形式 30 4 2 / + ...

  10. SSE推送数据

    SSE(Server-Sent Event,服务端推送事件)是一种允许服务端向客户端推送新数据的HTML5技术.与由客户端每隔几秒从服务端轮询拉取新数据相比,这是一种更优的解决方案. WebSocke ...