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 RedField at 2006-11-18 14:44:56 on Problem 3092
In Reply To:本来玩得挺开心,被这道郁闷了, 那里不对了? Posted by:cuiaoxiang at 2006-11-18 13:41:31
> #include <iostream>
> #include <vector>
> using namespace std;
> 
> vector<pair<int, int> > a;
> 
> void run(__int64 n, int dep)
> {
> 	__int64 i;
> 	int j;
> 	for (i = 1, j = 0; i <= n; i += i, ++j);
> 	i /= 2, --j;
> 	if ((n - i) % 3) i /= 2, --j;
> 	a.push_back(make_pair(j, dep));
> 	n -= i;
> 	if (n == 0) return;
> 	j = 0;
> 	while (n % 3 == 0)
> 	{
> 		n /= 3;
> 		++j;
> 	}
> 	run(n, dep + j);
> }
> 
> int main()
> {
> 	int casenum, num, j;
> 	__int64 n;
> 	scanf("%d", &casenum);
> 	for (num = 1; num <= casenum; ++num)
> 	{
> 		a.clear();
> 		scanf("%I64d", &n);
> 		printf("%d", num);
> 		j = 0;
> 		while (n % 3 == 0)
> 		{
> 			n /= 3;
> 			++j;
> 		}
> 		run(n, j);
> 		printf(" %d", a.size());
> 		for (vector<pair<int, int> >::iterator it = a.begin(); it != a.end(); ++it)
> 			printf(" [%d %d]", it->first, it->second);
> 		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