思路:

构造。

实现:

 #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. 矩阵经典题目七:Warcraft III 守望者的烦恼(矩阵加速递推)

    https://www.vijos.org/p/1067 非常easy推出递推式f[n] = f[n-1]+f[n-2]+......+f[n-k]. 构造矩阵的方法:构造一个k*k的矩阵.当中右上角 ...

  2. CSVReader

    从网上找了一个开源的东东 ,网址 https://www.csvreader.com/

  3. ABAP 检查全角半角

    check全角or半角的方法 第一种方法SJIS_DBC_TO_SBC 全角转半角 SJIS_SBC_TO_DBC 半角转换为全角 设定 import all =xtext = 文本全角-〉半角,返回 ...

  4. HDU1074 Doing Homework —— 状压DP

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1074 Doing Homework Time Limit: 2000/1000 MS (J ...

  5. YTU 2918: Shape系列-5

    2919: Shape系列-5 时间限制: 1 Sec  内存限制: 128 MB 提交: 251  解决: 199 题目描述 JC和Kitty听说小亮和小华有了Rectangle和Circle并用R ...

  6. eclipse中jsp页面乱码问题

    若上述位置均改为utf-8之后,页面展示扔为乱码,检查jsp页面是否有编码说明

  7. 并不对劲的bzoj4197:loj2131:uoj129:p2150:[NOI2015]寿司晚宴

    题目大意 有两个集合\(S_1,S_2 \subseteq [2,n] (n\leq 500)\),且对于\(\forall x\in S_1,y\in S_2 , gcd(x,y)=1\) 求\(S ...

  8. luogu 4720 【模板】扩展卢卡斯

    题目大意: 求$C_n^m \mod p$,p不一定为质数 思路: 首先可以将$p$分解为$p1^{a1}*p2^{a2}*...*pk^{ak}$,对于这些部分可以使用$CRT$合并 对于每个$p_ ...

  9. Tensorflow卷积接口总结

    tf.nn.conv2d(input, filter, strides, padding, use_cudnn_on_gpu=None, name=None) 这个接口用了这么久,每次都有点迷惑,这里 ...

  10. css实现侧边展开收起

    前言:因为突然想研究研究侧边栏滑动展开收起怎么做的,就去baidu了一下transition. 详情 内容1 内容1 内容1 内容1 内容1 右侧有实现demo.就是那个绿色的详情 先来看一下我的代码 ...