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 Mauritius at 2014-01-08 21:31:31 on Problem 2586
#include <stdio.h>
int main()
{
	const int mode[5] = {2, 4, 6, 9, 12};
	int s, d, k;
	while(scanf("%d%d", &s, &d)!=EOF)
	{
		k = 1;
		while(s*(5-k) - d*k > 0) k++;
		k = s*(12-mode[k-1]) - d*mode[k-1];
		if(k<0) printf("Deficit\n");
		else printf("%d\n", k);
	}
	return 0;
}
while循环计算出k:这里k表示每连续5个月需要的最少的亏损月数量。
k只能为1-5,mode数组给出不同k值下总共需要亏损月的数量。

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