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

是个水题,注意一點

Posted by KatrineYang at 2016-09-13 00:44:28 on Problem 1302
只需要做一次mutation就输出,不是要等到stabilized。题目叙述和样例不符
#include <iostream>
#include <string>
using namespace std;

int len;
string str;


int mutate(int start){
	if(start >= len) return 0;
	if(str[start] == '0') return 0;
	if(str[start] >= 'A'){
		int num = mutate(start+1);
		str[start] = num%10 + '0';
		return num+1;
	}
	else{
		str[start]--;
		int num = 1;
		int pos = start + (str[start]+1-'0');
		if(pos >= len) pos = start+1;
		num += mutate(pos);
		return num;
	}
}


int main() {
	string fei;
	while(1){
		cin >> fei;
		if(fei == "ENDOFINPUT") break;
		cin >> len;
		cin >> str >> fei;
		mutate(0);
		cout << str << endl;
	}
	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