SP10050 POWTOW - Power Tower City

    • 3通过
    • 20提交
  • 题目来源 SPOJ 10050
  • 评测方式 RemoteJudge
  • 标签
  • 难度 省选/NOI-
  • 时空限制 123ms / 1536MB

题解

  • 提示:收藏到任务计划后,可在首页查看。
  • 体验新版界面

    最新讨论 显示

    推荐的相关题目 显示

    题意翻译

    题目描述

    给你$c$组询问,每组询问给你两个整数$a,b$,你需要求:

    $a^{a^{a^{...}}}(b$个$a)$

    的值。
    如$a=2,b=4$时,结果为:
    $2^{2^{2^2}}=2^{2^4}=2^{16}=65536$
    特别地,当$b=0$时,定义这个式子的值为$1$。

    如果答案超过$9$位数,则先输出“...”,然后输出它的后$9$位数。
    对于每个询问,单独输出一行。

    说明

    样例解释

    样例有锅,没有显示出来。
    样例输出应为:

    1
    ...719156736
    ...884765625
    

    数据范围

    $0\le c\le 1000$
    $0\le a,b \le 2^{31}-1$

    题目描述

    You are living in a city build entirely of power towers such as 3^3^3 and 10^10^10^10. To enter a building you must type the last 9 digits of the number represented by the tower, written in decimal form, on a keypad next to the main entrance. You are not sharp enough at mental maths, but you can write a handy program to bring along in your pocket.

    A power tower is defined as repeated exponentiation. We write this using Knuth's up-arrow notation as: e↑↑a = e^e^...^e (a terms). Remember that ^ (exponentiation) is right assosiative. For example: 2↑↑4 = 2^2^2^2 = 2^(2^(2^2)) = 2^2^4 = 2^16 = 65536, and 3↑↑1 = 3. The value of a tower of heigh 0 is 1.

    输入输出格式

    输入格式:

    The first line contains integer C in [0..1000], the number of test cases.

    Then follows C lines, each with integers e,a in [0..2147483647]. (non-negative 32-bit ints).

    输出格式:

    For each testcase output e↑↑a, or if the output has more than 9 digits, output "..." and then the last 9 digits.

    输入输出样例

    输入样例#1: 复制
    3
    0 0
    2 5
    993306745 75707320
    输出样例#1: 复制
    
    
    提示
    标程仅供做题后或实在无思路时参考。
    请自觉、自律地使用该功能并请对自己的学习负责。
    如果发现恶意抄袭标程,将按照I类违反进行处理。