NEW RDSP MODE I (找规律)
来源:互联网 发布:javascript es6 编辑:程序博客网 时间:2024/05/04 01:31
NEW RDSP MODE I
Time limit 1000 ms Memory limit 131072 kB
Little A has became fascinated with the game Dota recently, but he is not a good player. In all the modes, the rdsp Mode is popular on online, in this mode, little A always loses games if he gets strange heroes, because, the heroes are distributed randomly.
Little A wants to win the game, so he cracks the code of the rdsp mode with his talent on programming. The following description is about the rdsp mode:
There are N heroes in the game, and they all have a unique number between 1 and N. At the beginning of game, all heroes will be sorted by the number in ascending order. So, all heroes form a sequence One.
These heroes will be operated by the following stages M times:
1.Get out the heroes in odd position of sequence One to form a new sequence Two;
2.Let the remaining heroes in even position to form a new sequence Three;
3.Add the sequence Two to the back of sequence Three to form a new sequence One.
After M times' operation, the X heroes in the front of new sequence One will be chosen to be Little A's heroes. The problem for you is to tell little A the numbers of his heroes.
Each case contains three integers N (1<=N<1,000,000), M (1<=M<100,000,000), X(1<=X<=20).
Proceed to the end of file.
5 1 25 2 2
2 44 3
In case two: N=5,M=2,X=2,the initial sequence One is 1,2,3,4,5.After the first operation, the sequence Oneis 2,4,1,3,5. After the second operation, the sequence One is 4,3,2,1,5.So,output 4 3.
题解:给你三个数字,N,M,X。求1至N个数字经过M次变幻之后前X个数字……
变幻:奇数位置的数放在偶数位置的数的后面……
思路:抓住一个点,模拟后面各次变幻的位置,很容易就找到规律的……
#include<cstdio>#include<iostream>#include<algorithm>#include<string.h>#include<stdlib.h>#include<time.h>#include<string>#include<math.h>#include<map>#include<queue>#include<stack>#define INF 0x3f3f3f3f#define ll __int64#define For(i,a,b) for(int i=a;i<b;i++)#define sf(a) scanf("%d",&a)#define sfs(a) scanf("%s",a)#define sff(a,b) scanf("%d%d",&a,&b)#define sfff(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)#define pf(a) printf("%d\n",a)#define mem(a,b) memset(a,b,sizeof(a))using namespace std;ll fun(ll x,ll y){ ll r=1,base=2; while(x) { if(x&1)r=(r*base)%y; base=(base*base)%y; x/=2; } return r;}int main(){ ll a,b,c; while(~scanf("%I64d%I64d%I64d",&a,&b,&c)) { if(a%2==0)a++; ll temp=fun(b,a); printf("%I64d",temp); ll num=temp; For(i,2,c+1) { num+=temp; num%=a; printf(" %I64d",num); } printf("\n"); }}
- NEW RDSP MODE I (找规律)
- NBUT 1225 NEW RDSP MODE I(找规律)(快速幂)
- NBUT1225 NEW RDSP MODE I(快速幂,规律)
- 1060: NEW RDSP MODE I
- NEW RDSP MODE I (模拟,循环节)
- wustoj 1093 NEW RDSP MODE I
- NBUT 1225 NEW RDSP MODE I
- NBUT 1225 NEW RDSP MODE I
- 模拟 nbut1225 NEW RDSP MODE I
- NBUT 1225 NEW RDSP MODE I
- 【省赛个人选拔赛九补题】NBUT [1225] NEW RDSP MODE I (思路题)
- NEU 1010: NEW RDSP MODE I 数论 每次将交换把偶数位的拖到前面,奇数位的拖到最后面
- NEU 1010: NEW RDSP MODE I 数论 每次将交换把偶数位的拖到前面,奇数位的拖到最后面
- 1031-找规律I
- HDOJ1021(找规律)
- POJ1740(找规律)
- hdu (找规律)
- hdu4915(找规律)
- 如何确认连接好了mysql数据库
- 7个Linux手机平台比较 (1):进程间通信的异同
- 复习HTML知识
- Android 用手动组拼的方式生成xml
- 数据库最佳实践:DBA小马如何走上升值加薪之路?
- NEW RDSP MODE I (找规律)
- 蓝桥杯java第八届第四题--魔方状态
- 【Appium】Could not detect Mac OS X Version from sw_vers output: '10.12
- 双机调试和windbg的命令
- 二叉树深度优先遍历和广度优先遍历【C++】
- ofbiz方法一 条件查询createConditionList
- Android实现开机自启动某个程序
- ListCycle2
- android.content.ActivityNotFoundException: Unable to find explicit activity class