编程介的小学生 2016-12-19 14:34 采纳率: 20.5%
浏览 909
已采纳

Birthday Cake

Description

Prince Remmarguts helped Uyuw successfully hold a concert in our previous story (POJ 2451), and ...that was the day of Uyuw's birthday.

Ting-a-ling, the chef was called on by Remmarguts. "You must prepare an immense birthday cake for lovely Princess Uyuw in a single day," said Remmarguts. Though Remmarguts' order is outrageous, the chef eventually rushed to buy flour, sugar, fat, and some other ingredients.

There had been chaos caused by war for quite a long time. The price of everything has been highly raised. Being the head accountant of country UDF – United Delta of Freedom, you must weight the cake carefully to make sure the chef did not perform a cheat on the ingredients.

The cake is made up of N levels. There is a 'cube' in each level, while the length of cube on k-th level (count from the topmost) is exactly k! For Remmarguts lives in an M-Dimension world unlike our, you should notice that the 'cube' here means M-Dimension cube, and the volume of a cube with length k is k ^ M.

You are to calculate the total volume of such an immense cake.
Input

You should read the number of test cases Z (Z <= 30) in the first line. Each of the following lines denotes a single test case, consisting of two integers N and M. We guarantee that 1 <= N <= 10 ^ 41 and 3 <= M <= 100.
Output

Output one line per test case, showing the total volume of that cake. We also guarantee that the volume is less than 10 ^ 250.
Sample Input

2
3 3
6 5
Sample Output

36
12201

  • 写回答

1条回答

  • threenewbee 2016-12-19 15:46
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler