思路:

构造。

实现:

 #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. python 【第三篇】函数基础

    深浅拷贝 set是一个无序且不重复的元素集合访问速度快天生解决重复问题 #!/usr/bin/env python3 # -*- coding:utf-8 -*- #深浅拷贝 import copy ...

  2. POJ 1125 Stockbroker Grapevine (Floyd最短路)

    Floyd算法计算每对顶点之间的最短路径的问题 题目中隐含了一个条件是一个人能够同一时候将谣言传递给多个人 题目终于的要求是时间最短.那么就要遍历一遍求出每一个点作为源点时,最长的最短路径长是多少,再 ...

  3. 授权QQ登录的qq端前端页面变迁

    ac_type = 'qq' if ac_type == 'qq': myid, mypwd = qq_key xp = '/html/body/div/div/div[2]/div/div/div/ ...

  4. MVC中从Controller像View层传值

    MVC中的Controller不能直接的訪问View层中的控件,那么是怎样的将Controller中值传到View中,经常使用的有4种 ViewData: 是获取或设置视图的字典对象,它里面存放的是键 ...

  5. (1)JDBC基础-java链接mysql数据库

    怎么操作数据库: 1,通过客户端(比如mac的终端,或者sql pro等专业工具)登陆数据库服务器(mysql -u root -p) 2,编写sql语句 3,发生sql语句到数据库服务器执行. JD ...

  6. 3.5Linux设备驱动--块设备(一)之概念和框架☆☆

    基本概念   块设备(blockdevice) --- 是一种具有一定结构的随机存取设备,对这种设备的读写是按块进行的,他使用缓冲区来存放暂时的数据,待条件成熟后,从缓存一次性写入设备或者从设备一次性 ...

  7. Local Databases with SQLiteOpenHelper

    Overview For maximum control over local data, developers can use SQLite directly by leveraging SQLit ...

  8. redhat修复hostname主机名

    1.修改文件vi /etc/sysconfig/network下的hostname,如: NETWORKING=yes HOSTNAME=master 2.修改文件:vi /etc/hosts 127 ...

  9. 01_创建一个新的activity&activity配置清单文件

    今天开始学四大组件.今天是学Activity,然后是广播接收者,然后是服务,然后是内容提供者.四大组件,咱们一天一个.Activity就是跟用户交互的界面,大部分的应用都不会只有这么一个界面.创建多个 ...

  10. 虚拟机安装hadoop

    1.用VMware建立两台虚拟机(Centos6.5)系统,并设立主机名为node1与node2 2.设置虚拟机网络两台都是设置为如图: 3.修改两台虚拟机的/etc/hosts的文件为 (其中192 ...