L1-050 倒数第N个字符串 (15 分)

解题思路

虽然是道简单题,但是我觉得还是需要动一下脑筋才能做出来的,这里就不过多讲解思路了,看代码都能看懂的。

#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int arr[10]={0};
	int k=0;
	int temp=pow(26,n)-m;
	do{
		arr[k++] = temp % 26;
		temp /= 26;
	}while(temp!=0);
	for(int i=n-1;i>=0;i--){
		printf("%c",arr[i]+'a');
	}
	return 0;
}
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务