首页 > ACM题库 > HDU-杭电 > hdu 3051 Peaceful Negotiation待解决[解题报告]C++
2014
02-27

hdu 3051 Peaceful Negotiation待解决[解题报告]C++

Peaceful Negotiation

问题描述 :

Long lasting wars bored country A and B, they decided to dispatch n people to have a peaceful negotiation, respectively. The peaceful negotiation will hold on a round table. But the delegate from country A may has conflict with the delegate from country B. Due to this reason, we hope the people who sit in the round table would not have conflict with the people on both sides. To simplify this problem, suppose the delegate from A exactly has one conflict people in the delegate from B, the delegate from B exactly has one conflict people in the delegate from A. Please calculate probability of the seat choice satisfied the request described above.

输入:

The input contains several test cases. The first line is a positive integer T which means there are T test cases below. The following T lines each contains a positive integer n(1<=n<=5000) which represents the conflict pairs described above.

输出:

The input contains several test cases. The first line is a positive integer T which means there are T test cases below. The following T lines each contains a positive integer n(1<=n<=5000) which represents the conflict pairs described above.

样例输入:

2
2
3 

样例输出:

0.3333333
0.2666667 


  1. #include <cstdio>
    #include <cstring>

    const int MAXSIZE=256;
    //char store[MAXSIZE];
    char str1[MAXSIZE];
    /*
    void init(char *store) {
    int i;
    store['A']=’V', store['B']=’W',store['C']=’X',store['D']=’Y',store['E']=’Z';
    for(i=’F';i<=’Z';++i) store =i-5;
    }
    */
    int main() {
    //freopen("input.txt","r",stdin);
    //init(store);
    char *p;
    while(fgets(str1,MAXSIZE,stdin) && strcmp(str1,"STARTn")==0) {
    if(p=fgets(str1,MAXSIZE,stdin)) {
    for(;*p;++p) {
    //*p=store[*p]
    if(*p<’A’ || *p>’Z') continue;
    if(*p>’E') *p=*p-5;
    else *p=*p+21;
    }
    printf("%s",str1);
    }
    fgets(str1,MAXSIZE,stdin);
    }
    return 0;
    }

  2. 其实国内大部分公司对算法都不够重视。特别是中小型公司老板根本都不懂技术,也不懂什么是算法,从而也不要求程序员懂什么算法,做程序从来不考虑性能问题,只要页面能显示出来就是好程序,这是国内的现状,很无奈。

  3. 很高兴你会喜欢这个网站。目前还没有一个开发团队,网站是我一个人在维护,都是用的开源系统,也没有太多需要开发的部分,主要是内容整理。非常感谢你的关注。