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 langx at 2010-10-14 01:11:29 on Problem 2183 and last updated at 2010-10-14 01:11:56
Problem: 2183		User: langx
Memory: 164K		Time: 0MS
Language: C++		Result: Accepted
---------------------------
#include <iostream>
using namespace std;

const unsigned MAX_SIZE = 50;

bool loop;
int n, m4, shrunk[MAX_SIZE];

int main(){
	int i, k;
	scanf("%d", &n);
	loop = true;
	for ( i = 0; ; ++i ) {
		n /= 10;
		m4 = n % 10000;
		n = m4 * m4;
		if(n > 999999)
			n %= 1000000;
		shrunk[i] = n;
		for ( k = 0; k < i; ++k ) {
			if(shrunk[k] == n ){
				loop = false;
				break;
			}
		}
		if(!loop)break;
	}
	printf("%d %d %d\n",shrunk[i], i - k, i + 1);
	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