LightOJ1282】的更多相关文章

[LightOJ1282]Leading and Trailing(数论) 题面 Vjudge 给定两个数n,k 求n^k的前三位和最后三位 题解 这题..真的就是搞笑的 第二问,直接输出快速幂\(mod \ 1000\)的值,要补前导零 第一问...就是搞笑的 依旧是快速幂 但是用double来算 每次中间值只要大于1000 直接除得小于1000就行了 不会就看代码把.. 这题就是搞笑的... #include<iostream> #include<cstdio> #includ…
题目链接:https://vjudge.net/problem/LightOJ-1282 1282 - Leading and Trailing    PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB You are given two integers: n and k, your task is to find the most significant three digits, and le…
题目链接:https://cn.vjudge.net/problem/LightOJ-1282 题意 给出两个正整数n(2 ≤ n < 231), k(1 ≤ k ≤ 1e7) 计算n^k的前三位,末三位 思路 首先末三位很好算,这里就只需模算数+快速幂 然后考虑前三位的算法,这里主要问题是数据溢出(pow(n, k)计算不可行) 那么考虑把n换成浮点数,同时除掉10^m,再去pow(n, k) 我们可以通过$ 1\leq (\frac{n}{10^m})^k \leq 1000 $大概估计范围…
http://lightoj.com/volume_showproblem.php?problem=1282 题目大意: 求n的k次方的前三位和后三位数然后输出 后三位是用快速幂做的,我刚开始还是不会快速幂,后来慢慢理解了. 前三位求得比较厉害 我们可以吧n^k = a.bc * 10.0^m; k*log10(n)  = log10(a.bc) + m; m为k * lg(n)的整数部分,lg(a.bc)为k * lg(n)的小数部分; x = log10(a.bc) = k*log10(n)…
题面 给定两个数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的数算就好了…
题目大意: 给出 n 和 k,请你求出 n^k 次方的前三位和后三位. 解题思路: 后三位用快速幂,不加赘述. 求前三位的方法: AC代码: #include <iostream> #include <cstdio> #include <cmath> using namespace std; typedef long long ll; int Fase_Power(ll a,int m){ ; a%=; while(m){ ) ret=ret*a%; m>>…
链接: https://vjudge.net/problem/LightOJ-1282 题意: You are given two integers: n and k, your task is to find the most significant three digits, and least significant three digits of nk. 思路: 后三位快速幂取余,考虑前三位. \(n^k\)可以表示为\(a*10^m\)即使用科学计数法. 对两边取对数得到\(k*log…