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
    **************************************
  • 相关阅读:
    MIME 类型(HttpContext.Response.ContentType)列表
    Enterprise Library 5.0 系列文章
    实战HTTP处理程序系列(转)
    Ext.Net 的Panel放入iframe
    使用LINQ Expression构建Query Object
    在.NET Workflow 3.5中使用多线程提高工作流性能
    重温DOS下的小作品:回忆过去,展望将来
    CQRS体系结构模式实践案例:Tiny Library:系统架构
    使用Apworks开发基于CQRS架构的应用程序(二):创建领域模型项目
    经典的应用系统结构、CQRS与事件溯源
  • 原文地址:https://www.cnblogs.com/Wurq/p/3750276.html
Copyright © 2011-2022 走看看