zoukankan      html  css  js  c++  java
  • CodeForces 361B Levko and Permutation

    题意:有n个数,这些数的范围是[1,n],并且每个数都是不相同的。你需要构造一个排列,使得这个排列上的数与它所在位置的序号的最大公约数满足 > 1,并且这些数的个数恰好满足k个,输出这样的一个排列。

    思路:只需要后k个数与下标一样,前n-k个数逆序输出就复合题意。

     1 #include<cstdio>
     2 #include<cstring>
     3 #include<algorithm>
     4 #include<iostream>
     5 #include<cstdlib>
     6 #include<string>
     7 #include<cmath>
     8 #include<vector>
     9 using namespace std;
    10 const int maxn=1e5+7;
    11 const double eps=1e-8;
    12 const double pi=acos(-1);
    13 #define ll long long
    14 #define clc(a,b) memset(a,b,sizeof(a))
    15 
    16 int main()
    17 {
    18     int n,m;
    19     scanf("%d%d",&n,&m);
    20     if(n==m)
    21     {
    22         printf("-1
    ");
    23     }
    24     else
    25     {
    26         printf("%d ",n-m);
    27         for(int i=1;i<n-m;i++)
    28             printf("%d ",i);
    29         for(int i=n-m+1;i<=n;i++)
    30             printf("%d ",i);
    31     }
    32     return 0;
    33 }
    View Code
  • 相关阅读:
    mysql错误Error(1133): Can’t find any matching row in the use
    xtrbackup备份mysql
    配置Mysql审计
    Mysql:sql语句
    mysql基准测试与sysbench工具
    tomcat排错以及优化
    nginx反向代理
    Nginx
    服务器归分第一篇
    Android安装BusyBox(三星N7108)
  • 原文地址:https://www.cnblogs.com/ITUPC/p/5243808.html
Copyright © 2011-2022 走看看