FJNU 1159 Fat Brother’s new way(胖哥的新姿势)

FJNU 1159 Fat Brother’s new way(胖哥的新姿势)

Time Limit: 1000MS   Memory Limit: 257792K

【Description】

【题目描述】

I bet, except Fat Brothers, all of you don’t like strange way to show integers , he is really like this way to showing integers:

1 -> ‘A’

2 -> ‘B’

…….

26 -> ‘Z’

27 -> ‘AA’

28 -> ‘AB’

…….

Unfortunately, Fat Brother’s mathematics is poor, so he needs your help, he will give you some integers, and you must transform it with Fat Brother’s way.

我琢磨着,除了胖哥,没人想用如此奇葩的方式表示整数,可他总喜欢这么来写整数:

1 -> ‘A’

2 -> ‘B’

…….

26 -> ‘Z’

27 -> ‘AA’

28 -> ‘AB’

…….

不幸的是,胖哥的数学并不好,因此他需要你的帮助,他会给你一些整数,你必须把他们转化成胖哥的表示方式。

【Input】

【输入】

Input starts with an integer T(T <= 10000), denoting the number of test case.

For each test case, an integers n(1 <= n <= 2147483647) is given.

输入以一个整数T(T <= 10000)打头,表示测试用例的数量。

对于每个测试用例,都有一个整数n(1 <= n <= 2147483647)。

【Output】

【输出】

For each case, output the corresponding string with upper-case letters.

对于每个用例,输出以大写字母组成的字符串。

【Sample Input - 输入样例】

【Sample Output - 输出样例】

3

17311

2068

37

YOU

CAN

AK

【题解】

  大概意思就是10进制转26进制,不过需要注意输入数据并不是从0开始的。

  对了,G++里没有strrev这个函数

【代码 C++】

 1 #include<cstdio>
 2 int main(){
 3     char opt[20];
 4     int t, a, i;
 5     scanf("%d", &t);
 6     while (t--){
 7         scanf("%d", &a);
 8         for (i = -1; a--; a /= 26) opt[++i] = 'A' + a % 26;
 9         while (~i) putchar(opt[i--]);
10         puts("");
11     }
12     return 0;
13 }
原文地址:https://www.cnblogs.com/Simon-X/p/5402040.html