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 uuuouou at 2015-01-06 16:42:44 on Problem 2897
#include <cstdio>

const int MAX = 100;

int main()
{
	int test, t, i, arr[MAX], co, pro;
	for(scanf("%d", &test); test--; ){
		scanf("%d%d", &t, arr);
		if(t == 1){
			printf("%d\n", arr[0]);
			continue;
		}
		if(arr[0] == 1){
			puts("0");
			continue;
		}

		co = 0;
		for(i = 1; i < MAX; ++i){
			pro = arr[i-1] * t + co;
			arr[i] = pro % 10;
			co = pro / 10;
			if(arr[i] != 0 && arr[i]*t + co == arr[0]) break;
		}
		if(i == MAX) puts("0");
		else{
			for(; i >= 0; --i) printf("%d", arr[i]);
			puts("");
		}
	}
	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