zoukankan      html  css  js  c++  java
  • NEFU 696 Dart game 背包dp

    Dart game

    Time Limit 1000ms

    Memory Limit 65536K

    description

       Darts originated in Australia. Australia's aborigines initially for hunting and hit the enemy's weapon. 
       A game of darts in which the players attempt to score points by throwing the darts at a target.
    Figure:DART BOARD
       Darts movement rules of the game is very simple, the target is 1-20 points and the central circle is 50 small zoning, edge is 25 division, the rough circle line of fan-shaped covered area is 1-20 points and three times the corresponding division. This game is generally played by two people but can be played by teams. Each player starts with N points. The goal for each player is to reach zero by subtracting the amount they score from the amount they had left,but final throwing must be double division. And the first to reduce his/her score to zero wins.
       So the task is : 
       Given a dart scores N that a player starts with, you are required to calculate how many different ways to reach zero. One is different way to another means at least one dart hits different division.Ways which have different orders and same divisions are the same way. For example,if N=4,there are 4 different ways reach to zero:the first is double 2,the second is 2 and double 1, the third is twice of double 1,the fourth is twice of 1 and double 1 .
       The answer may be very large,you have to module it by 2011. 
    							

    input

    The input contains several test cases.
       Each test case contains an integer N ( 0 < N ≤ 1001 ) in a line.
       N=0 means end of input and need not to process.
    							

    output

    For each test case, output how many different ways to reach zero.
    							

    sample_input

    5
    4
    3
    2
    1
    0
    							

    sample_output

    6
    4
    1
    1
    0
    							
    -----------------------------------

    至少含有一种double的取法数=总的取法-不含有double的取法。

    多水的题啊!!!!数据有误!!!有误!!啊!发火

    ---------------------------------

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    
    using namespace std;
    
    int a[111]= {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,25,     //21
                3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,   //41
                2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,50};//62
    int f[1111];
    int g[1111];
    int n;
    
    int main()
    {
        memset(f,0,sizeof(f));
        memset(g,0,sizeof(g));
    
        f[0]=1;
        for (int i=0; i<62; i++)
        {
            for (int j=0; j<=1001-a[i]; j++)
            {
                if (f[j])
                {
                    f[j+a[i]]=(f[j+a[i]]+f[j])%2011;
                }
            }
        }
        //for (int i=0;i<100;i++) printf("%d ",f[i]);
        g[0]=1;
        for (int i=0; i<41; i++)
        {
            for (int j=0; j<=1001-a[i]; j++)
            {
                if (g[j])
                {
                    g[j+a[i]]=(g[j+a[i]]+g[j])%2011;
                }
            }
        }
    
        while (~scanf("%d",&n))
        {
            if (n==0) break;
            printf("%d\n",(f[n]-g[n]+2011)%2011);
        }
        return 0;
    }





  • 相关阅读:
    ASP.NET验证控件的使用 拓荒者
    读书笔记:MFC单文档应用程序结构分析 拓荒者
    MFC单文档(SDI)全屏程序的实现 拓荒者
    jQuery的animate函数
    设备尺寸杂谈:响应性Web设计中的尺寸问题
    Yeoman学习与实践笔记
    IE对文档的解析模式及兼容性问题
    推荐给开发和设计人员的iPad应用
    几个移动应用统计平台
    颜色、网页颜色与网页安全色
  • 原文地址:https://www.cnblogs.com/cyendra/p/3226387.html
Copyright © 2011-2022 走看看