Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

把m转化为类26进制就行了

Posted by langx at 2010-10-14 12:42:37 on Problem 2273 and last updated at 2010-10-14 12:44:40
Problem: 2273		User: langx
Memory: 164K		Time: 0MS
Language: C++		Result: Accepted
-----------------------------------------
#include <iostream>
using namespace std;

char bit26[10];
int n, m;

int main(){
	char ch;
	int i;
	while ( ~scanf("%c%d%c%d", &ch, &n, &ch, &m) && (n + m)) {
		i = 0;
		while ( m > 0) {
			--m;                        //注意这个
			bit26[i] = m % 26 + 'A';
			m /= 26;
			++i;   
		}
		--i;
		while ( i >= 0 ) {
			printf("%c",bit26[i]);
			--i;
		}
		printf("%d\n",n);
		ch = getchar();          //去掉换行符
	}
	return 0;
}


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator