/*
前三位
len=log10n^k(乘积的长度)
len=klog10n
n^k=x*10^(len-1)
x=n^k/10^(len-1)
log10x = k*log10n - (len-1)
x=pow(10,k*log10n - (len-1)) 后三位
快速幂解决
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,k,x;
ll power(ll a,ll n){
ll res=;
while(n){
if(n%)res=res*a%;
a=a*a%;
n>>=;
}
return res%;
}
int main(){
int T;
cin>>T;
for(int tt=;tt<=T;tt++){
cin>>n>>k;
ll len=k*log10((double)n);
double x=pow((double),(double)k*log10((double)n)-(len-));
while(x<)x*=;
printf("Case %d: %d ",tt,(int)x);
n%=;
ll y=power(n,k);//后三位用快速幂
if(y==)printf("000\n");
else if(y<)printf("00%d\n",y);
else if(y<)printf("0%d\n",y);
else printf("%d\n",y);
}
}

lightoj 1282 取对数的操作的更多相关文章

  1. LightOJ - 1282 - Leading and Trailing(数学技巧,快速幂取余)

    链接: https://vjudge.net/problem/LightOJ-1282 题意: You are given two integers: n and k, your task is to ...

  2. lightoj 1282 && uva 11029

    Leading and Trailing lightoj 链接:http://lightoj.com/volume_showproblem.php?problem=1282 uva 链接:http:/ ...

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

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

  4. Leading and Trailing LightOJ - 1282 题解

    LightOJ - 1282 Leading and Trailing 题解 纵有疾风起 题目大意 题意:给你一个数n,让你求这个数的k次方的前三位和最后三位. \(2<=n<2^{31} ...

  5. 【每日一题】 UVA - 11809 Floating-Point Numbers 阅读题+取对数处理爆double

    https://cn.vjudge.net/problem/UVA-11809 题意:很长orz 题解:算一下输入范围,发现用double是读不进来的,在这里wa了半天,(double 1e300  ...

  6. hdu 1568 (log取对数 / Fib数通项公式)

    hdu 1568 (log取对数 / Fib数通项公式) 2007年到来了.经过2006年一年的修炼,数学神童zouyu终于把0到100000000的Fibonacci数列 (f[0]=0,f[1]= ...

  7. 【取对数】【哈希】Petrozavodsk Winter Training Camp 2018 Day 1: Jagiellonian U Contest, Tuesday, January 30, 2018 Problem J. Bobby Tables

    题意:给你一个大整数X的素因子分解形式,每个因子不超过m.问你能否找到两个数n,k,k<=n<=m,使得C(n,k)=X. 不妨取对数,把乘法转换成加法.枚举n,然后去找最大的k(< ...

  8. poj2661 Factstone Benchmark(大数不等式同取对数)

    这道题列出不等式后明显是会溢出的大数,但是没有必要写高精度,直接两边取对数(这是很简明实用的处理技巧)得: log2(n!)=log2(n)+log2(n-1)+...+log2(1)<=log ...

  9. HDU3666 THE MATRIX PROBLEM (差分约束+取对数去系数)(对退出情况存疑)

    You have been given a matrix C N*M, each element E of C N*M is positive and no more than 1000, The p ...

随机推荐

  1. Hibernate注解与JPA

    Hibernate注解与JPA - charming的专栏 - CSDN博客http://blog.csdn.net/zxc123e/article/details/51499652 之前记录的一些东 ...

  2. IDEA-使用技巧

    IDEA--个性化配置 - 心飞扬的博客 - CSDN博客--里面很好,http://blog.csdn.net/afzaici/article/details/71524643 IntelliJ I ...

  3. code forces 805B (水)

    #include<stdio.h>#include<iostream>#include<algorithm>#include<string.h>#inc ...

  4. [TensorFlow笔记乱锅炖] tf.multinomial(logits, num_samples)使用方法

    tf.multinomial(logits, num_samples) 第一个参数logits可以是一个数组,每个元素的值可以简单地理解为对应index的选择概率,注意这里的概率没有规定加起来的和为1 ...

  5. Vivado Turtorial 01 —— 使用vivado中debug功能(类似ISE中ChipScope)

    1.基于BASYS3板子,有如下代码: module top( input clk, input rst, output test_clk ); parameter DIV_CNT = 2; reg ...

  6. MK64FN1M0xxx12_flash.ld链接文件解析

    1.前言 本文主要对MK64FN1M0xxx12_flash.ld文件进行分析,以此来加深对链接文件的理解 2.文件详解 /* ** ################################# ...

  7. salt使用技巧

    实时截获任务输出   __salt__['event.send']("module_send_event", {'message': message, 'jid': jid},   ...

  8. centos6.8配置php-fpm(php已在apache中以模块形式运行,nginx中同时以fastcgi运行)

    location ~ \.php(.*)$ { root /mnt/www/wenyin; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; ...

  9. 009_关闭linux的THP

    背景:公司某个大型业务系统反馈最近数据库服务器总是宕机(此处描述不准确,后面解释),最后,客户.运维人员都觉得实在是忍无可忍了,项目经理打电话找到我问是否能帮忙诊断一下,刚好第二天要去现场沟通另外一个 ...

  10. javascript日期格式yyyyMMddHHmmss

    1. function GetDateTimeToString() { var date_ = new Date(); var year = date_.getFullYear(); ; var da ...