首页 > 其他 > 详细

模拟与高精度 P1563 玩具谜题

时间:2020-05-06 10:02:57      阅读:47      评论:0      收藏:0      [点我收藏+]

题目

https://www.luogu.com.cn/problem/P1563

代码

#include<iostream>
#include<string>
#include<cstring>
#include<cstdio>
using namespace std;
struct node
{
    int towards;
    string name;
}list[100005];
int n, m;
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        cin >> list[i].towards >> list[i].name;
    }
    int num = 0;
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        if (a == 0)
        {
            if (list[num].towards == 0)num = ((num - b) % n + n) % n;
            else num = ((num + b) % n + n) % n;
        }
        else
        {
            if (list[num].towards == 0)num = ((num + b) % n + n) % n;
            else num = ((num - b) % n + n) % n;
        }
    }
    cout << list[num].name << endl;
}

 

模拟与高精度 P1563 玩具谜题

原文:https://www.cnblogs.com/Jason66661010/p/12834501.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!