找出循环周期即可了

#include<bits/stdc++.h>
using namespace std;
int N,M,X;
int time(int x,int y,int z)
{
if(z!=0&&x==1)
return z;
if(x%2==0)
x/=2;
else
x=(x+y+1)/2;
return time(x,y,z+1);
}
int operate(int x)
{
if(x<=N/2)
return x*2;
else
return (x-N/2)*2-1;
}
int main()
{
while(scanf("%d%d%d",&N,&M,&X)==3)
{
M%=time(1,N,0);
for(int i=1;i<=X;i++)
{
if(i!=1)
printf(" ");
int ans=i;
for(int j=1;j<=M;j++)
ans=operate(ans);
printf("%d",ans);
}
printf("\n");
}
return 0;
}

NBUT 1225 NEW RDSP MODE I的更多相关文章

  1. NBUT 1225 NEW RDSP MODE I 2010辽宁省赛

    Time limit  1000 ms Memory limit  131072 kB Little A has became fascinated with the game Dota recent ...

  2. Ural 1225. Flags 斐波那契DP

    1225. Flags Time limit: 1.0 secondMemory limit: 64 MB On the Day of the Flag of Russia a shop-owner ...

  3. NBUT 1457 莫队算法 离散化

    Sona Time Limit:5000MS     Memory Limit:65535KB     64bit IO Format: Submit Status Practice NBUT 145 ...

  4. ACM: NBUT 1107 盒子游戏 - 简单博弈

     NBUT 1107  盒子游戏 Time Limit:1000MS     Memory Limit:65535KB     64bit IO Format:  Practice  Appoint ...

  5. ACM: NBUT 1105 多连块拼图 - 水题 - 模拟

    NBUT 1105  多连块拼图 Time Limit:1000MS     Memory Limit:65535KB     64bit IO Format:  Practice  Appoint ...

  6. ACM: NBUT 1646 Internet of Lights and Switches - 二进制+map+vector

    NBUT 1646 Internet of Lights and Switches Time Limit:5000MS     Memory Limit:65535KB     64bit IO Fo ...

  7. 【BZOJ】1225: [HNOI2001] 求正整数

    http://www.lydsy.com/JudgeOnline/problem.php?id=1225 题意:给一个数n,求一个最小的有n个约数的正整数.(n<=50000) #include ...

  8. 双向广搜+hash+康托展开 codevs 1225 八数码难题

    codevs 1225 八数码难题  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond   题目描述 Description Yours和zero在研究A*启 ...

  9. 递推DP URAL 1225 Flags

    题目传送门 /* 1 r; 2 b; 3 w 2不能在最前面,所以dp[1] = 2; dp[2] = 2: 13 or 31 dp[i] = dp[i-1] + dp[i-2]; 只加1或3时,总数 ...

随机推荐

  1. delphi 中怎么知道某一个月有多少天

    if (month in (1,3,5,7,8,10,12)) return 31; else if (month in(4,6,9,11)) return 30; else if (year 是闰年 ...

  2. AutoCompleteTextView使用 监听

    AutoCompleteTextView使用 An editable text view that shows completion suggestions automatically while t ...

  3. STL源码分析读书笔记--第三章--迭代器(iterator)概念与traits编程技法

    1.准备知识 typename用法 用法1:等效于模板编程中的class 用法2:用于显式地告诉编译器接下来的名称是类型名,对于这个区分,下面的参考链接中说得好,如果编译器不知道 T::bar 是类型 ...

  4. js运动 缓冲运动

    <!DOCTYPE HTML> <HTML> <meta http-equiv="Content-Type" content="text/h ...

  5. dom 优酷得弹出

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  6. 阿里云存储OSS之九大使用技巧

    http://www.biphp.com/cloud-computing/%E9%98%BF%E9%87%8C%E4%BA%91%E5%AD%98%E5%82%A8oss%E4%B9%8B%E4%B9 ...

  7. 用 Python 脚本实现对 Linux 服务器的监控

    目前 Linux 下有一些使用 Python 语言编写的 Linux 系统监控工具 比如 inotify-sync(文件系统安全监控软件).glances(资源监控工具)在实际工作中,Linux 系统 ...

  8. CountDownLatch和CyclicBarrier的区别

    [CountDownLatch.CyclicBarrier和Semaphore]http://www.cnblogs.com/dolphin0520/p/3920397.html   [CountDo ...

  9. 传参方式由url携带改为post提交

    参考:http://www.cnblogs.com/logon/p/3218834.html 我们这里使用了iframe嵌套form表单POST提交,很简单,却能满足get|post等任何复杂情况的要 ...

  10. Flex XML

    一.创建XML类 1.把字符串对象转换为XML: var xmlStr:String="<students><student><name>吕布</n ...