zoukankan      html  css  js  c++  java
  • SGU 188.Factory guard

    模拟

    code

    #include <iostream>
    #include <cstdio>
    #define LEN 1000
    using namespace std;
    int n, t;
    int pos[30], last[30], v[30];
    int ans[30];
    int main()
    {
        cin >> n >> t;
        for (int i = 1; i <= n; ++i) cin >> pos[i];
        for (int i = 1; i <= n; ++i) cin >> v[i];
        for (int time = 1; time <= t; ++time)
        {
            for (int i = 1; i <= n; ++i)
                last[i] = pos[i], pos[i] += v[i];
            for (int i = 1; i <= n; ++i)
                for (int j = 1; j <= n; ++j)
                    if ( v[i] > 0 && v[j] < 0 )
                    {
                        if (last[j] > last[i] && pos[i] >= pos[j])
                                              ++ans[i], ++ans[j];
                        else if (last[j] < last[i] && pos[i] - LEN >= pos[j])
                            ++ans[i], ++ans[j];
                    }
            for (int i = 1; i <= n; ++i)
            {
                while (pos[i] < 0) pos[i] += LEN;
                while (pos[i] >= LEN) pos[i] -= LEN;
            }
        }
        for (int i = 1; i <= n; ++i)
            cout << ans[i] << ' ';
        return 0;
    }
  • 相关阅读:
    php 解析xml
    php
    php 设置自动加载某个页面
    Mac
    mysql
    Git
    C#
    C# 正则表达式
    C# ASCII码排序
    (转)datagridview 自定义列三步走
  • 原文地址:https://www.cnblogs.com/keam37/p/3963306.html
Copyright © 2011-2022 走看看