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

why wa?过了的兄弟帮忙看看,程序不长,谢谢

Posted by bakey at 2005-08-15 23:37:32 on Problem 2545
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
const __int64 MAX = 10e18;
const int maxn = 100000+2;
int p1,p2,p3;
__int64 h[maxn];

int cmp(const void *a,const void *b)
{
	__int64 p1 = *(__int64*)a;
	__int64 p2 = *(__int64*)b;
	if (p1 > p2)
		return 1;
	if (p1 == p2)
		return 0;
	return -1;
}

int main()
{
	int i,j,k,tar,count;
	__int64 temp;

	while (scanf("%d%d%d%d",&p1,&p2,&p3,&tar) != -1)
	{
		count = 0;
		for (i = 0; i <= 64; i ++)
		{
			for (j = 0; j <= 64;j ++)
			{
				for (k = 0; k <= 64; k ++)
				{
					temp = (__int64)pow(p1,i)*(__int64)pow(p2,j)*(__int64)pow(p3,k);
					if (temp < MAX && temp > 0) 
						h[count++] = temp;
				}
			}
		}
		qsort(h,count,sizeof(h[0]),cmp);
		printf("%I64d\n",h[tar]);
	}
	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