zoukankan      html  css  js  c++  java
  • Pet

    Pet

    Time Limit : 4000/2000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other)
    Total Submission(s) : 28   Accepted Submission(s) : 9
    Problem Description
    One day, Lin Ji wake up in the morning and found that his pethamster escaped. He searched in the room but didn’t find the hamster. He tried to use some cheese to trap the hamster. He put the cheese trap in his room and waited for three days. Nothing but cockroaches was caught. He got the map of the school and foundthat there is no cyclic path and every location in the school can be reached from his room. The trap’s manual mention that the pet will always come back if it still in somewhere nearer than distance D. Your task is to help Lin Ji to find out how many possible locations the hamster may found given the map of the school. Assume that the hamster is still hiding in somewhere in the school and distance between each adjacent locations is always one distance unit.
     
    Input
    The input contains multiple test cases. Thefirst line is a positive integer T (0<t<=10), div="" <="" n="" 0.="" location="" at="" always="" room="" ji’s="" lin="" map.="" adjacent="" y="" that="" meaning="" space,="" y(0<="x,y<N)," x="" map,="" descripts="" n-1lines="" following="" trap.="" distance="" affective="" d="" school="" in="" locations="" is="" space.="" single="" a="" by="" separated="" d(0<d<n),="" and="" (0<n<="100000)" integer="" positive="" two="" has="" line="" first="" cases,="" each="" for="" cases.="" test="" of="" number="" the="">
     
    Output
    For each test case, outputin a single line the number of possible locations in the school the hamster may be found.
     
    Sample Input
    1 10 2 0 1 0 2 0 3 1 4 1 5 2 6 3 7 4 8 6 9
     
    Sample Output
    2
     
    Source
    2013 ACM/ICPC Asia Regional Online —— Warmup
     
     1 #include <stdio.h>
     2 #include <string.h>
     3 
     4 int main()
     5 {
     6     int T,i,j,head,last,sign,times,high,num[100005];
     7     scanf("%d",&T);
     8     while(T--)
     9     {
    10         memset(num,0,sizeof(num));
    11         scanf("%d%d",&times,&high);
    12         for(i=1;i<times;i++)
    13         {
    14             scanf("%d%d",&head,&last);
    15             num[last]=num[head]+1;
    16         }
    17         for(i=0,sign=0;i<=last;i++)
    18         {
    19             if(num[i]>high)
    20                 sign++;
    21         }
    22         printf("%d
    ",sign);
    23     }
    24 
    25     return 0;
    26 }
    View Code
    转载请备注:
    **************************************
    * 作者: Wurq
    * 博客: https://www.cnblogs.com/Wurq/
    * Gitee: https://gitee.com/wurq
    **************************************
  • 相关阅读:
    smarty对网页性能的影响--开启opcache
    1stopt8.0 代码示例
    1stopt、matlab和python用morris、sobol方法实现参数敏感性分析
    MATLAB 实现sobol参数敏感性分析
    matlab中自带的sobol的函数提供的sobol序列
    matlab和fortran混合编程
    mathematic语法基础
    fortran常用语句--读写带注释文档、动态数组等语法
    fortran语言调用fortran写的dll
    C语言函数指针与 c#委托和事件对比
  • 原文地址:https://www.cnblogs.com/Wurq/p/3750276.html
Copyright © 2011-2022 走看看