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

我的C :-)

Posted by gardner at 2005-10-07 05:18:52 on Problem 2545
#include <stdio.h>
void main()
{
	__int64 p1,p2,p3,num,counter,i,min;
	__int64 display[10010]={0};
	scanf("%I64d%I64d%I64d%I64d",&p1,&p2,&p3,&num);
	if(p1>p2){
		i=p1;p1=p2;p2=i;
	}
	if(p3<p1){
		i=p3;p3=p2;p2=p1;p1=i;
	}
	else if(p3<p2){
		i=p2;p2=p3;p3=i;
	}
	display[0]=1;
	display[1]=p1;
	counter=2;
	while(counter<=num){
		for(i=counter-1;display[i]*p1>display[counter-1]&&i>=0;i--);
		min=display[i+1]*p1;
		for(i=counter-1;display[i]*p2>display[counter-1]&&i>=0;i--);
		if(display[i+1]*p2<min)min=display[i+1]*p2;
		for(i=counter-1;display[i]*p3>display[counter-1]&&i>=0;i--);
		if(display[i+1]*p3<min)min=display[i+1]*p3;
		display[counter]=min;
		counter++;
	}
	printf("%I64d\n",display[num]);
}

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