模拟赛

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;
#define N 100000 + 10
#define LL long long
const int mod = 365 * 24 * 3600;

struct que
{
    LL a, b;
};

bool cmp(que t1, que t2)
{
    if(t1.a == 0) return true;
    if(t1.b == 0) return false;
    return t1.a * t2.b < t2.a * t1.b;
}

int n;
que t[N];

int main()
{
    while(~scanf("%d", &n) && n)
    {
        for(int i = 0; i < n; i++)
            scanf("%I64d%I64d", &t[i].a, &t[i].b);
        sort(t, t + n, cmp);
        LL ans = 0;
        for(int i = 0; i < n; i++)
            ans = (ans + t[i].a + ans * t[i].b) % mod;
        printf("%I64d\n", ans);
    }
    return 0;
}



#include <map>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;
#define N 25

int n, s1, s2, t1, t2, k;
char dir1, dir2;

void doit(char& ch, int& x, int& y, int s)
{
    char tmp = ch;
    if(ch == 'W')
    {
        if(y - s >= 1)
            y -= s;
        else
        {
            y = s - y + 2;
            ch = 'E';
        }
    }

    else if(ch == 'E')
    {
        if(y + s <= n)
            y += s;
        else
        {
            y = 2 * n - s - y;
            ch = 'W';
        }
    }

    else if(ch == 'N')
    {
        if(x - s >= 1)
            x -= s;
        else
        {
            x = s - x + 2;
            ch = 'S';
        }
    }

    else
    {
        if(x + s <= n)
            x += s;
        else
        {
            x = 2 * n - s - x;
            ch = 'N';
        }
    }
}

map<char, char> mm;
void solve()
{
    mm['N'] = 'W', mm['E'] = 'N', mm['S'] = 'E', mm['W'] = 'S';
    int time = 0, x1 = 1, y1 = 1, x2 = n, y2 = n;
    while(time < k)
    {
        doit(dir1, x1, y1, s1);
        doit(dir2, x2, y2, s2);
        time++;
        if(x1 == x2 && y1 == y2) swap(dir1, dir2);
        else
        {
            if(time % t1 == 0)
                dir1 = mm[dir1];
            if(time % t2 == 0)
                dir2 = mm[dir2];
        }
    }
    printf("%d %d\n%d %d\n", x1, y1, x2, y2);
}

int main()
{
    while(~scanf("%d", &n) && n)
    {
        scanf(" %c%d%d", &dir1, &s1, &t1);
        scanf(" %c%d%d", &dir2, &s2, &t2);
        scanf("%d", &k);
        solve();
    }
    return 0;
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值