zoukankan      html  css  js  c++  java
  • Codeforces Round #188 (Div. 2)D

    这题太坑了,无奈了, 当n==30000时,在我的电脑上跑了3.5s,提交竟然过了。。。 

    因为这个比较均匀散开的,所以最多只会散开成150*150(准确的来说是124*124)的一个矩阵,然后暴力即可!

    30000*100*100 在cf这题还是没有超时的

     
    D. Ants
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    It has been noted that if some ants are put in the junctions of the graphene integer lattice then they will act in the following fashion: every minute at each junction (xy) containing at least four ants a group of four ants will be formed, and these four ants will scatter to the neighbouring junctions (x + 1y), (x - 1y), (xy + 1), (xy - 1) — one ant in each direction. No other ant movements will happen. Ants never interfere with each other.

    Scientists have put a colony of n ants into the junction (0, 0) and now they wish to know how many ants will there be at some given junctions, when the movement of the ants stops.

    Input

    First input line contains integers n (0 ≤ n ≤ 30000) and t (1 ≤ t ≤ 50000), where n is the number of ants in the colony and t is the number of queries. Each of the next t lines contains coordinates of a query junction: integers xiyi ( - 109 ≤ xi, yi ≤ 109). Queries may coincide.

    It is guaranteed that there will be a certain moment of time when no possible movements can happen (in other words, the process will eventually end).

    Output

    Print t integers, one per line — the number of ants at the corresponding junctions when the movement of the ants stops.

    Sample test(s)
    input
    1 3
    0 1
    0 0
    0 -1
    output
    0
    1
    0
    input
    6 5
    0 -2
    0 -1
    0 0
    0 1
    0 2
    output
    0
    1
    2
    1
    0
    Note

    In the first sample the colony consists of the one ant, so nothing happens at all.

    In the second sample the colony consists of 6 ants. At the first minute 4 ants scatter from (0, 0) to the neighbouring junctions. After that the process stops.

  • 相关阅读:
    docker基本命令
    vscode 保存提示运行"XXX"的保存参与者: 快速修复
    Vue 2.6 插槽
    代码大全-PartOne-变量命名
    Axure 8.0.1.3388 注册码 授权码 破解
    乱七八糟记一下乱七八糟的碎片化知识
    JavaScript需记的一些细节
    Python3.6问题
    python3.6- shape mismatch: objects cannot be broadcast to a single shape
    Angular+ng-zorro遇坑记
  • 原文地址:https://www.cnblogs.com/chenhuan001/p/3137438.html
Copyright © 2011-2022 走看看