思路:

构造。

实现:

 #include <bits/stdc++.h>
using namespace std;
int res[];
int main()
{
int n, a, b;
while (cin >> n >> a >> b)
{
int maxn = max(a, b), minn = min(a, b);
bool flg = false;
int i = ;
for (; i <= n; i += maxn)
{
if ((n - i) % minn == ) { flg = true; break; }
}
if (!flg) { cout << - << endl; continue; }
int x = i / maxn, y = (n - i) / minn;
int cnt = , last = ;
for (int i = ; i < x; i++)
{
int start = cnt;
for (int j = + i * maxn; j <= maxn + i * maxn; j++)
{
res[cnt++] = j;
}
int tmp = res[start];
int j = start;
for (; j < cnt - ; j++)
{
res[j] = res[j + ];
}
res[j] = tmp;
}
int fuck = cnt;
for (int i = ; i < y; i++)
{
int start = cnt;
for (int j = fuck + + i * minn; j <= fuck + minn + i * minn; j++)
{
res[cnt++] = j;
}
int tmp = res[start];
int j = start;
for (; j < cnt - ; j++)
{
res[j] = res[j + ];
}
res[j] = tmp;
}
for (int i = ; i < cnt; i++) cout << res[i] << " ";
cout << endl;
}
return ;
}

CF932C Permutation Cycle的更多相关文章

  1. Codeforces 932.C Permutation Cycle

    C. Permutation Cycle time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  2. C. Permutation Cycle

    For a permutation P[1... N] of integers from 1 to N, function f is defined as follows: Let g(i) be t ...

  3. 【ICM Technex 2018 and Codeforces Round #463 (Div. 1 + Div. 2, combined) C】 Permutation Cycle

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] p[i] = p[p[i]]一直进行下去 在1..n的排列下肯定会回到原位置的. 即最后会形成若干个环. g[i]显然等于那个环的大 ...

  4. Codeforces 932 C.Permutation Cycle-数学 (ICM Technex 2018 and Codeforces Round #463 (Div. 1 + Div. 2, combined))

    C. Permutation Cycle   time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  5. Codeforces Round #463

    A - Palindromic Supersequence /* 题目大意:给出一个串,构造一个包含该串的回文串 */ #include <cstdio> #include <alg ...

  6. ICM Technex 2018 and Codeforces Round #463 (Div. 1 + Div. 2, combined)

    靠这把上了蓝 A. Palindromic Supersequence time limit per test 2 seconds memory limit per test 256 megabyte ...

  7. 置换及Pólya定理

    听大佬们说了这么久Pólya定理,终于有时间把这个定理学习一下了. 置换(permutation)简单来说就是一个(全)排列,比如 \(1,2,3,4\) 的一个置换为 \(3,1,2,4\).一般地 ...

  8. (转)排列算法 Permutation Generation

    转自:http://www.cnblogs.com/dragonpig/archive/2010/01/21/1653680.html http://www.notesandreviews.com/p ...

  9. Codeforces Round #309 (Div. 1) B. Kyoya and Permutation 构造

    B. Kyoya and Permutation Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/ ...

随机推荐

  1. Android开发pool解析xml

    xml在开发中的作用不可小觑,很多时候我们都要用到这种文件,所以学习它的解析方式很是必要. 我们都知道java中xml的解析有:dom,SAX,但是Android下我们使用pool解析,是更为方便,而 ...

  2. IntelliJ IDEA jrebel6 安装,破解

    一.Setting中在线安装JRebel插件,install 二.拷贝下载的jrebel.rar解压后 把里面内容覆盖IDEA插件安装目录中此插件目录之下 下载:http://pan.baidu.co ...

  3. 设计模式-(9)中介者模式(swift)

    在对象去耦合的模式中,有两种模式:中介者模式,观察者模式 一,概念 用一个中介对象来封装一系列的对象交互.中介者使各对象不需要显式地相互引用,从而使其耦合松散,而且可以独立地改变它们之间的交互. 这个 ...

  4. HDU1151 Air Raid —— 最小路径覆盖

    题目链接:https://vjudge.net/problem/HDU-1151 Air Raid Time Limit: 2000/1000 MS (Java/Others)    Memory L ...

  5. YTU 1007: Redraiment猜想

    1007: Redraiment猜想 时间限制: 1000 Sec  内存限制: 10 MB 提交: 83  解决: 23 题目描述 redraiment在家极度无聊,于是找了张纸开始统计素数的个数. ...

  6. 【monkey】

    在Android文件系统中的存放路径是:/system/framework/monkey.jarMonkey.jar 程序是由一个名为“monkey”的Shell脚本来启动执行,shell脚本在And ...

  7. 四.OC基础--1.文档安装和方法重载,2.self和super&static,3.继承和派生,4.实例变量修饰符 ,5.私有变量&私有方法,6.description方法

    四.OC基础--1.文档安装和方法重载, 1. 在线安装 xcode-> 系统偏好设置->DownLoads->Doucument->下载 2. 离线安装 百度xcode文档 ...

  8. Ruby: 获取IE的一些信息(其实应用AutoIt脚本本身,获取这些信息更加简单)

    require'win32/registry' hkey_local_machine=Win32::Registry::HKEY_LOCAL_MACHINE defgetKeyValue(hive, ...

  9. Java-Runoob-高级教程-实例-字符串:13. Java 实例 - 字符串格式化

    ylbtech-Java-Runoob-高级教程-实例-字符串:13. Java 实例 - 字符串格式化 1.返回顶部 1. Java 实例 - 字符串格式化  Java 实例 以下实例演示了通过 f ...

  10. EA使用记录

    1.Del键只能删除桌面上的图形,不能删除项目树中的图形:要同时从项目树中删除需要ctrl + del: 2.要找到桌面上的图形对应的项目树中的图 alt + g: 3.要设置默认的LINK样式,在菜 ...