The 2019 Asia Nanchang First Round Online Programming Contest E. Magic Master
题目链接:https://nanti.jisuanke.com/t/41352
题目意思还是好理解的,看过的人不多,感觉是被通过量吓到了。其实就是个水题,反向模拟就好了,
用队列模拟,反向模拟,它要放m张卡到后面,那我就放m张卡到前面,一开始队列只有1张卡,慢慢加到n张卡,
先加大的卡,再一直到1的卡。对了,可能会出现只有5张卡,m却是6,7,8或9,10,那么为了减少不必要的模拟,
用mod来减少,因为有些模拟会让卡和之前比较,算是原封不动。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std; typedef long long LL;
#define inf 1e9
#define rep(i,j,k) for(int i = (j); i <= (k); ++i)
#define rep__(i,j,k) for(int i = (j); i < (k); ++i)
#define per(i,j,k) for(int i = (j); i >= (k); --i)
#define per__(i,j,k) for(int i = (j); i > (k); --i) const int N = ;
int arr[N];
int mod,n,q;
queue<int> que; void work(){ int tmp;
que.push(n);//压入最大的卡
int num = ;
int end = n - ;//最后1的卡直接是取走的,所以那一轮不需要模拟了
while(num <= end){
tmp = mod % num; rep(o,,tmp){
que.push(que.front());
que.pop();
}
que.push(n-num);//压入前一张卡
++num;
}
// que.push(1);
} int main(){ int T;
scanf("%d",&T); while(T--){
scanf("%d%d",&n,&mod); rep(i,,n){
arr[i] = i;//1-n的卡
}
scanf("%d",&q); work(); per(i,n,){//取出卡
arr[i] = que.front();
que.pop();
} int o;
rep(i,,q){
scanf("%d",&o);
printf("%d\n",arr[o]);
} // rep(i,1,n) printf("%d ",arr[i]);
} getchar(); getchar();
return ;
}
The 2019 Asia Nanchang First Round Online Programming Contest E. Magic Master的更多相关文章
- The 2019 Asia Nanchang First Round Online Programming Contest
传送门 A. Enju With math problem 题意: 给出\(a_1,\cdots,a_{100}\),满足\(a_i\leq 1.5*10^8\). 现在问是否存在一个\(pos\), ...
- The 2019 Asia Nanchang First Round Online Programming Contest C(cf原题,线段树维护矩阵)
题:https://nanti.jisuanke.com/t/41350 分析:先将字符串转置过来 状态转移,因为只有5个状态,所以 i 状态到 j 状态的最小代价就枚举[i][k]->[k][ ...
- The 2019 Asia Nanchang First Round Online Programming Contest B. Fire-Fighting Hero
题目链接:https://nanti.jisuanke.com/t/41349 题意:有一个灭火英雄,和一个灭火团队,一个人与一个团队比较. 灭火英雄到其他灭火点的最短路最大值,与一个团队到其他灭火点 ...
- The 2019 Asia Nanchang First Round Online Programming Contest The Nth Item
The Nth Item 思路: 先用特征根法求出通向公式,然后通向公式中出现了\(\sqrt{17}\),这个可以用二次剩余求出来,然后可以O(\(log(n)\))求出. 但是还不够,我们先对\( ...
- H. The Nth Item(The 2019 Asia Nanchang First Round Online Programming Contest)
题意:https://nanti.jisuanke.com/t/41355 给出N1,计算公式:A=F(N)Ni=Ni-1 ^ (A*A),F为类斐波那契需要矩阵快速幂的递推式. 求第k个N. 思路: ...
- E.Magic Master(The 2019 Asia Nanchang First Round Online Programming Contest)
直接模拟orhttps://blog.csdn.net/liufengwei1/article/details/100643831
- The 2019 Asia Nanchang First Round Online Programming Contest(B,E)
B. Fire-Fighting Hero 题意:一个消防员和多个队伍比赛,比较所有地方的最短路的最大值,消防员最后的值要乘1/C,求胜利的一方的最短路的最大值是多少.一直没读懂正确题意(内疚). 思 ...
- The 2019 Asia Nanchang First Round Online Programming Contest B Fire-Fighting Hero(阅读理解)
This is an era of team success, but also an era of heroes. Throughout the ages, there have been nume ...
- The 2019 Asia Nanchang First Round Online Programming Contest C. Hello 2019(动态dp)
题意:要找到一个字符串里面存在子序列9102 而不存在8102 输出最小修改次数 思路:对于单次询问 我们可以直接区间dpOn求出最小修改次数 但是对于多次询问 我在大部分题解看到的解释一般是用线段树 ...
随机推荐
- 阿里邮箱地址,smpt
企业邮箱的POP3.SMTP.IMAP地址是什么? 企业邮箱POP.SMTP.IMAP地址列表如下: (阿里云邮箱web端通用访问地址:https://qiye.aliyun.com/),客户端推荐以 ...
- Linux学习笔记-第8天 - 看似很简单
这些东西已经看了三遍,已经能够理解了.看似很简单,希望真正在用的时候不会出差子.
- tornado之获取参数
self.write() # 返回字符串 self.redirect() # 重定向 self.render() # 返回html页面 一. 获取url中携带的参数, 如: 127.0.0.1: ...
- 【CFGym102059G】Fascination Street(思维DP)
点此看题面 大致题意: 有\(n\)个路灯,每个路灯有一定的建造费用,且建成后可照亮自身及周围距离为\(1\)的两个格子.你可以交换\(k\)次两个路灯的建造费用,求照亮所有格子的最小费用. 题意转换 ...
- NLP中一些数学知识
1.所谓概率函数就是要在整个样本空间分配概率值,概率值总和为1 2.一个完备的概率空间应该由样本空间,概率函数和事件域这三部分组成,在统计自然语言处理中,我们的目标就是为建立的模型定义一个符合上述条件 ...
- [LeetCode] 234. Palindrome Linked List 回文链表
Given a singly linked list, determine if it is a palindrome. Example 1: Input: 1->2 Output: false ...
- [LeetCode] 53. Maximum Subarray 最大子数组
Given an integer array nums, find the contiguous subarray (containing at least one number) which has ...
- [LeetCode] 33. Search in Rotated Sorted Array 在旋转有序数组中搜索
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e. ...
- [LeetCode] 30. Substring with Concatenation of All Words 串联所有单词的子串
You are given a string, s, and a list of words, words, that are all of the same length. Find all sta ...
- 《 .NET并发编程实战》阅读指南 - 第14章
先发表生成URL以印在书里面.等书籍正式出版销售后会公开内容.