Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
给个最短代码,其实不需要分类。#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator