我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

Calculation 数列的计算

Problem Description
Assume that f(0) = 1 and 0^0=1. f(n) = (n%10)^f(n/10) for all n bigger than zero. Please calculate f(n)%m. (2 ≤ n , m ≤ 10^9, x^y means the y th power of x).

Input
The first line contains a single positive integer T. which is the number of test cases. T lines follows.Each case consists of one line containing two positive integers n and m.

Output
One integer indicating the value of f(n)%m.

Sample Input
2
24 20
25 20

Sample Output
16
5

近期文章

  • Cow Sorting 排序的问题
  • 一个字符串+一个整数结果是?
  • java如何提高获取文件md5码的效率
  • An easy problem 怎么求的
  • Bone Collector 程序的设计
  • 如何修改java代码改变xfire发布的wsdl中数组的形式
  • 创建angular-cli项目,ng serve之后打开的不是预想的结果?求大神指点。(angular小白一枚)
  • 如何用python删除sqlite数据中的表情符?
  • 如何为网站制作搜索引擎? [关闭]
  • 如何比较php中存在的MySql数据[重复]
  • 在php中创建$ _POST数组中的变量
  • 在Php / Mysql中显示来自数据库的图像
  • Laravel 4.2 Redirect :: to with GET Params
  • Heroku PHP和Node.js在同一个应用程序中
  • 如何正确验证PHP中的图像?
  • 需要帮助设置curl php扩展
  • android HTTP post发送数据的问题
  • 在PHP中裁剪图像的一部分并调整大小
  • PHP Eventviva扩大了透明png
  • 当POST返回NULL时,Var_dump表单数据

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华