zoukankan      html  css  js  c++  java
  • Ural 1260 Nudnik Photographer

    Problem Description
    If two people were born one after another with one second difference and one of them is a child,
    then the other one is a child too. We get by induction that all the people are children.
    Everyone knows that the mathematical department of the Ural State University is a big family of N persons, 1, 2, 3, …, N years old respectively.
    Once the dean of the department ordered a photo if his big family. There were to be present all the students of the department arranged in one row. At first the dean wanted to arrange them by their age starting from the youngest student, but than he decided that it would look unnatural. Than he advised to arrange the students as follows:
    1. The 1 year old student is to sit at the left end of the row.
    2. The difference in ages of every two neighbors mustn’t exceed 2 years.
    The dean decided that thereby the students would seem look as they were arranged by their ages (one can hardly see the difference in ages of 25 and 27 years old people). There exist several arrangements satisfying to the requirements. Photographer didn’t want to thwart dean’s desire and made the photos of all the possible mathematical department students’ arrangements.
     
    Input
    There is the integer number N, 1 ≤ N ≤ 55.
    Output
    the number of photos made by the photographer.
     
    Sample Input
    inputoutput
    4
    4

    Hint

    If N = 4 then there are following possible arrangements: (1,2,3,4), (1,2,4,3), (1,3,2,4) and (1,3,4,2).
     

    #include <stdio.h>
    
    typedef __int64 LL;
    
    int main(){
        LL a[60];
        a[1]=1;
        a[2]=1;
        a[3]=2;
        a[4]=4;
        for(int i=5; i<=55; i++){
            a[i]=a[i-3]+a[i-1]+1;
        }
        int n;
        while( scanf("%d",&n)!=EOF ){
            printf("%I64d
    ",a[n]);
        }
        return 0;
    }
     
  • 相关阅读:
    spring mvc+ELK从头开始搭建日志平台
    java分布式系统开关功能设计(服务升降级)
    可伸缩性架构常用技术
    大众点评订单系统分库分表实践
    分布式缓存--系列1 -- Hash环/一致性Hash原理
    Netty原理剖析
    一个轻量级分布式 RPC 框架 — NettyRpc
    HDU 2583 permutation
    HDU 2573 Typing
    c语言中逗号运算符和逗号表达式
  • 原文地址:https://www.cnblogs.com/chenjianxiang/p/3628722.html
Copyright © 2011-2022 走看看