日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

CodeForces 361B Levko and Permutation

發布時間:2024/6/21 编程问答 47 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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\n"); 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

?

轉載于:https://www.cnblogs.com/ITUPC/p/5243808.html

總結

以上是生活随笔為你收集整理的CodeForces 361B Levko and Permutation的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。