首页 > ACM题库 > HDU-杭电 > HDU 2786-HOJ-International Collegiate Programming Contest[解题报告]C++
2014
02-14

HDU 2786-HOJ-International Collegiate Programming Contest[解题报告]C++

International Collegiate Programming Contest

问题描述 :

Do you have any idea how much work must be done to make a competition like this to happen? Reserve rooms, install computers, buy some food, print certificates – these are only some of the important tasks. Can you imagine how many sleepless nights have been spent since the first CTU competition in 1995? And this was only for people like you to enjoy the ICPC. Wow!

Beside others, the problem set must be carefully prepared. This includes not only the problem statements but also solutions and test data. It is really a large amount of work. Would you help us, please? Your task is to create a test input data for the Problem B (banking).

输入:

The input to your program will be some valid and correct output for Problem B.

输出:

The input to your program will be some valid and correct output for Problem B.

样例输入:

withdraw 20.00: ok
deposit 35.00: ok
withdraw 200.00: insufficient funds
transfer 100.50: ok
transfer 50.00: interbank
create: already exists
create: ok
transfer 100.00: same account
transfer 100.00: insufficient funds
withdraw 100.00: no such account
deposit 0.11: no such account
transfer 10000.00: no such account
end

deposit 6.92: ok
withdraw 9.68: ok
withdraw 6.64: ok
end

goodbye

样例输出:

3
1234/5 100.00
4321/6 150.20
5432/5 1600.00
withdraw 1234/5 20.00
deposit 1234/5 35.00
withdraw 1234/5 200.00
transfer 5432/5 1234/5 100.50
transfer 5432/5 4321/6 50.00
create 1234/5
create 1236/5
transfer 1236/5 1236/5 100.00
transfer 1236/5 1234/5 100.00
withdraw 0000/0 100.00
deposit 0000/0 0.11
transfer 1234/5 0000/0 10000.00
end

1
9999/9 9.40
deposit 9999/9 6.92
withdraw 9999/9 9.68
withdraw 9999/9 6.64
end

0

http://acm.hit.edu.cn/hoj/problem/view?id=2786

公里转化为英里

公里数用最少个斐波那契数表示

即42表示为34+8 而不是34+5+2+1

#include <stdio.h>

void calc_fib(int f[]);

int main()
{
    int i, f[32];
    int t, x, y;
    bool flag[32];

    calc_fib(f);
    scanf("%d", &t);
    while(t--)
    {
        for (i = 1; i < 22; i++)
            flag[i] = 0;
        y = 0;
        scanf("%d", &x);
        for (i = 21; i > 0; i--)
        {
            if (x >= f[i])
            {
                x -= f[i];
                flag[i] = 1;
            }
            if (x == 0)
                break;
        }
        for (i = 2; i < 22; i++)
        {
            y += flag[i] * f[i-1];
        }
        printf("%d\n", y);
    }

    return 0;
}

void calc_fib(int f[])
{
    int i;

    f[1] = 1, f[2] = 2;
    for (i = 3; i < 22; i++)
    {
        f[i] = f[i-1] + f[i-2];
    }
}

 

解题参考:http://blog.csdn.net/epk_lee/article/details/8232320


  1. 网站做得很好看,内容也多,全。前段时间在博客园里看到有人说:网页的好坏看字体。觉得微软雅黑的字体很好看,然后现在这个网站也用的这个字体!nice!

  2. 3,求得所有的为的总和sum—->所有数的总和
    printf( "Not Possible" );—->printf("impossible");
    对吗?