Time Limit: 2000MS   Memory Limit: 32768KB   64bit IO Format: %lld & %llu

Submit Status

Description

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.

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 < 231) and k (1 ≤ k ≤ 107).

Output

For each case, print the case number and the three leading digits (most significant) and three trailing digits (least significant). You can assume that the input is given such that nk contains at least six digits.

Sample Input

5

123456 1

123456 2

2 31

2 32

29 8751919

Sample Output

Case 1: 123 456

Case 2: 152 936

Case 3: 214 648

Case 4: 429 296

Case 5: 665 669

Source

Problem Setter: Shamim Hafiz
Special Thanks: Jane Alam Jan (Solution, Dataset)
/**
题意:求a的b次幂,结果的高三位和低三位是什么
做法:快速幂
**/
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<cmath>
#include<algorithm>
#define mod 1000
using namespace std;
int quickpow(int n, int k)
{
int res = ;
int base = n%mod;
while(k)
{
if(k&)
res *= base;
base *= base;
res %= mod;
base %= mod;
k >>= ;
}
return res;
}
int solve(int a,int b)
{
double s = b*log10((double)a) - (int)(b*log10((double)a));
s = pow(10.0,s);
return s*;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif // ONLINE_JUDGE
int Case = ;
int T;
scanf("%d",&T);
while(T--)
{
int a,b;
scanf("%d %d",&a,&b);
int res = quickpow(a,b);
int cet =pow(, +fmod(b *(double)log10((double)a), ));
printf("Case %d: %d %03d\n",Case,cet,res);
Case++;
}
return ;
}

最新文章

  1. oracle统计用户下面所有的表,并显示每个表的行数
  2. Objective-C 快速入门--基础(三)
  3. 利用nodeJS实现的网络小爬虫
  4. python注释
  5. 基于 unity ngui 上的滚动加载__UiVirtual
  6. Python 结巴分词模块
  7. 【转】javascript日期操作详解(脚本之家整理)
  8. jvm之内存分配与回收策略
  9. C#获取文件和文件夹大小
  10. 3. 编写Java应用程序,定义Animal类,此类中有动物的属性:名称 name,腿的数量legs,统计动物的数量 count;方法:设置动物腿数量的方法 void setLegs(),获得腿数量的方法 getLegs(),设置动物名称的方法 setKind(),获得动物名称的方法 getKind(),获得动物数量的方法 getCount()。定义Fish类,是Animal类的子类,统计鱼的数量
  11. keepalive配置文件详解
  12. Ubuntu虚拟机可以上网,可以ping网络,但是无法update和install,报连接不上服务器的错误解决方案:
  13. javascript 判断质数
  14. jboss的使用和安装
  15. php 带省略号的分页
  16. socket服务器编程的一般思路
  17. 谈谈 C++ 中的右值引用
  18. Python 字典 items() 方法
  19. 关于UI测试
  20. [BZOJ2127]happiness-[网络流-最小割]

热门文章

  1. Leetcode中单链表题总结
  2. mysql jdbc 连接url
  3. Stars POJ - 2352
  4. CCPC-Winter Camp div2 day1
  5. Android提示框与通知的使用
  6. linux包安装,解压,压缩,包管理,环境变量
  7. flask 自定义url转换器
  8. python实现备份gitlab版本库并更改文件名
  9. 省队集训 Day7 选点游戏
  10. bzoj 2957: 楼房重建 ——线段树