HDOJ 1703 PBD (规律)

PBD

Time Limit : 1000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 14   Accepted Submission(s) : 3

Font: Times New Roman | Verdana | Georgia

Font Size:

Problem Description

PrisonBreak is a popular TV programme in HDU. ACboy likes it very much, and he join a PrisonBreak discussing team called "PBD".Every Tuesday night, a lot of PBDers will contact with each other to discuss the newest plot of PrisonBreak season2. Generally speaking, every PBDer has distinct ideas about the play, so everyone want to know all the others' ideas. For example, when ACboy contract with Sam, ACboy will tell all the ideas he konws to Sam, and Sam will also tell all the ideas he konws to ACboy, and the call costs 5 yuan.
If there are N people in the "PBD" team, what is the minimum cost to let everyone knows all the others' ideas?

Input

The input contains multiple test cases.
Each test case contains a number N, means there are N people in the "PBD" team.N = 0 ends the input.(A call cost 5 yuan).

Output

for each case, output a integer represent the minimum cost to let everyone knows all the others' ideas.

Sample Input

1
2
3
4
0

Sample Output

0
5
15
20

Hint

If there are 2 people, for example, named A, B. Then A calls B, then A and B will know each other's ideas, so it only
needs one call, so the minimum cost is 1*5 = 5 yuan.

Source

2007省赛集训队练习赛(1)

思路:,

HDOJ 1703 PBD (规律)_第1张图片
按照 红 绿 蓝 紫 黑的颜色顺序连线(不止一种情况)我就是举个例子。就算之前交流过,再交流还是要付钱的,切记。5:6   6:8   7:10......这样的规律,不难找了吧。
我看大牛们找到的是  10*n-20(从4开始),下面是我的AC代码:
#include<stdio.h>
int main(){
    int n;
    while(scanf("%d",&n)&&n){
        if(n==1||n==2){
            printf("%d\n",(n-1)*5); continue;
        }
        else if(n==3) printf("15\n");
        else printf("%d\n",(n*2-4)*5);
    }
    return 0;
}


你可能感兴趣的:(规律,hdoj)