zoukankan      html  css  js  c++  java
  • bnu 26584,模拟

    F. Mosquito Multiplication

    1000ms
    1000ms
    65536KB
    64-bit integer IO format: %lld      Java class name: Main
    Font Size:

    Have you ever wondered why there are so many mosquitos in wet environments? One of the reasons is that adult female mosquitos can lay as many as hundreds of eggs. Even if most of them do not (fortunately!) survive, it is said that a single pair of mosquitos can generate a population of thousands in just a couple of weeks. Let us have a closer look at these numbers. The mosquito life cycle includes four stages: egg, larva, pupa, and adult. For simplicity, we will make several assumptions that are not quite true in the nature: The egg stage lasts less than one day, and all the other stages are one week long. Each mosquito lives as a larva for the first week, the second week “hibernates” in the form of a pupa, and finally, the third week lives as an adult mosquito. At the end of its three-week life, each mosquito lays eggs and dies.

    To simplify things even further, we will assume that the transformation from one life stage into another always happens on Sunday. Each Sunday, the following things happen:

    An adult mosquito lays E eggs and dies. Within a day, one larva hatches from each egg.

    Some of the larvae hatched from egg the last Sunday were not strong enough and died or got eaten. Only every R-th larva will transform into a pupa on Sunday.

    An adult mosquito emerges from every S-th pupa, all other pupae dry.

    For example, if there are 5 pupae and every 3-rd of them survives, there will be 1 mosquito left. Out of 6 pupae, two adult mosquitos emerge.

    In the first week, there are M mosquitos, P pupae and L larvae. Calculate how many mosquitos will there be after N Sunday transformations. Of course, we are counting only living adult mosquitos, not the dry dead bodies.

    Input

    The input consists of several instances, each instance per one line. Each line contains seven integers M, P, L, E, R, S, N separated by space. M, P and L are the numbers of mosquitos, pupae, and larvae, respectively, in the first week. You may assume that 0 M,P,L 100 000, 0 E 100, 1 R, S 10, and 1 N 1000. E is the number of eggs laid by one mosquito, R and S specify the survival rates of larvae and pupae, and N is the number of weeks.

    Output

    For each input instance, output a single line containing an integer number C, giving the count of mosquitos after the N-th Sunday.

    You may assume that the number of mosquitos during each of the first N weeks will not exceed 1 000 000.

    Sample Input

    10 20 40 4 2 2 10
    144 55 8 0 1 9 4
    10 10 10 2 3 2 6
    10 20 40 86 9 9 999

    Sample Output

    10
    0
    1
    10
    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<string>
    #include<cmath>
    #include<vector>
    #include<cstdlib>
    #include<algorithm>
    
    using namespace std;
    
    #define LL long long
    #define ULL unsigned long long
    #define UINT unsigned int
    #define MAX_INT 0x7fffffff
    #define MAX_LL 0x7fffffffffffffff
    #define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
    #define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
    
    #define MAXN 1111
    LL adult[MAXN],pupa[MAXN],
        larva[MAXN];
    LL e,r,s,n;
    
    int main(){
    //  freopen("C:\Users\Administrator\Desktop\in.txt","r",stdin);
    
        while(scanf("%lld %lld %lld %lld %lld %lld %lld",&adult[0],&pupa[0],&larva[0],
                    &e,&r,&s,&n)==7){
            for(int i=1; i<=n; i++){
                larva[i]=adult[i-1]*e;
                pupa[i]=larva[i-1]/r;
                adult[i]=pupa[i-1]/s;
            }
            printf("%lld
    ",adult[n]);
        }
        return 0;
    }
    
  • 相关阅读:
    Mybatis Generator生成Mybatis Dao接口层*Mapper.xml以及对应实体类
    ssh通过pem文件登陆服务器
    maven私服nexus上传第三方jar包以及下载
    springboot不占用端口启动
    springboot2.x纯注解整合dubbo
    mysql5.7 group by语法 1055
    java读取pdf文本转换html
    java 记录对象前后修改的内容(工具类)
    在docker中运行mysql实例
    Linux编辑启动停止重启springboot jar包脚本
  • 原文地址:https://www.cnblogs.com/ramanujan/p/3412912.html
Copyright © 2011-2022 走看看