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

Re:同样的程序在浙大那边ac了,这里却wa

Posted by jasonchen at 2005-02-26 18:13:44 on Problem 2247
In Reply To:同样的程序在浙大那边ac了,这里却wa Posted by:jasonchen at 2005-02-26 18:12:57
#include	<iostream>
#include	<cmath>
#include	<algorithm>
#define	MAX	10000

using namespace std;

void swap(int *x, int *y);

int
main(void)
{
	int		table[MAX];
	double  tmp;
	int		i, j, k, l;
	int		s;
	int		n;
	int		fir, sec;
	char	suf[3];

	s = 0;
	for (i = 0; i <= 30; ++i)
		for (j = 0; j <= 19; ++j)
			for (k = 0; k <= 13; ++k)
				for (l = 0; l <= 11; ++l)
				{
					tmp = pow((double)2, (double)i) * pow((double)3, (double)j) * pow((double)5, (double)k) * pow((double)7, (double)l);
					if (tmp <= 2000000000)
						table[s++] = tmp;
				}


	
	sort(table, table + s);
	
	cin >> n;
	while (n != 0)
	{
		fir = n % 10;
		sec = (n / 10) % 10;

		strcpy(suf, "th");
		if (sec != 1)
		{
			if (fir == 1 )
				strcpy(suf, "st");
			else if (fir == 2)
				strcpy(suf, "nd");
			else if (fir == 3)
				strcpy(suf, "rd");
		}
		cout << "The " << n << suf << " humble number is " << table[n - 1] << "." << endl;
		cin >> n;
	}

	return 0;
}

void
swap(int *x, int *y)
{
	int	tmp;

	tmp = *x;
	*x = *y;
	*y = tmp;
}

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