题面

给定两个数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. [Python Study Notes]计算cpu使用率

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ...

  2. [Python Study Notes]异常处理

    正则表达式 python提供了两个非常重要的功能来处理python程序在运行中出现的异常和错误.你可以使用该功能来调试python程序. 异常处理 断言(Assertions) python标准异常 ...

  3. Wpf DataGridCheckBoxColumn 问题

    使用DataGridCheckBoxColumn  binding一个布尔属性时,发现无法checkbox无法勾选, 并且HeaderTemplate中的checkbox无法获取到viewmodel的 ...

  4. composer引用本地git做为源库

    PHP使用者大多对composer是又爱又恨,爱的是composer require后,很多类库不用去下载了,恨的是网速卡成翔,虽然国内有很多道友做了镜象,但对于bower库这些都还是整体更新. 那么 ...

  5. VirtualDOM与diff(Vue实现)

    写在前面 因为对Vue.js很感兴趣,而且平时工作的技术栈也是Vue.js,这几个月花了些时间研究学习了一下Vue.js源码,并做了总结与输出.文章的原地址:https://github.com/an ...

  6. ORACLE数据库SQL优化 not in 与not exits

    各个表的数据量: sys_file_convert_queue 65989sys_att_file 73061sys_att_main 84405sys_att_rtf_data 1507 优化前,执 ...

  7. Python标准异常总结

    Python标准异常总结 AssertionError 断言语句(assert)失败 AttributeError 尝试访问未知的对象属性  EOFError 用户输入文件末尾标志EOF(Ctrl+d ...

  8. js中的isNaN()函数

    <html> <head> <script type="text/javascript" src="function.js"> ...

  9. C#将制定文件夹下的PDF文件合并成一个并输出至指定路径

    /// <summary> /// 将源路径下的PDF合并至目标路径下 /// </summary> /// <param name="SourcePath&q ...

  10. Java——正则表达式

    题目: java中提供了对正则表达式的支持. 有的时候,恰当地使用正则,可以让我们的工作事半功倍! 如下代码用来检验一个四则运算式中数据项的数目,请填写划线部分缺少的代码. 注意:只填写缺少代码,不要 ...