当前位置: 首页 > news >正文

超级链接网站模板网站建设首选建站系统

超级链接网站模板,网站建设首选建站系统,重庆南昌网站建设,网站建设哪一家好1#xff1a;置换的轮换表示 给出一个置换#xff0c;写出该置换的轮换表示。比如 (1 2 3 4 5 6 7 8 9) (3 1 6 2 9 7 8 4 5) 表示为(1 3 6 7 8 4 2)(5 9) 输入#xff1a; 置换后的序列 输出#xff1a; 不相杂的轮换乘积#xff0c;每行表示一个轮换#xff08;轮换的起… 1置换的轮换表示 给出一个置换写出该置换的轮换表示。比如 (1 2 3 4 5 6 7 8 9) (3 1 6 2 9 7 8 4 5) 表示为(1 3 6 7 8 4 2)(5 9) 输入 置换后的序列 输出 不相杂的轮换乘积每行表示一个轮换轮换的起始数字最小每个轮换的起始数字递增排序单轮换省略 例如 样例1 输入空格分隔 3 1 6 2 9 7 8 4 5 输出 1 3 6 7 8 4 2空格分隔 5 9空格分隔 样例2 输入空格分隔 4 6 7 5 1 2 3 输出 1 4 5空格分隔 2 6空格分隔 3 7 空格分隔 #include cstdio #include cstring int main() {char c[50];gets(c); int n(strlen(c)1)/2;int i,j0,k,flag1,a[25],b[25];for(i0;in;i){a[i]c[2*i]-48;b[i]0;}int l1;b[j]l;printf(%d ,b[j]);j;for(i0;jn;){if(a[i]l) //a[i]等于这一轮换的头说明轮换结束 {printf(\n); l; //找下一个轮换的头while(flag1){for(k0;kj;k){ if(lb[k]) //l不能已经在之前的轮换中 {break;}}if(kj) //l不在轮换里 {if(la[l-1]) //单轮换不输出还要接着找头不改变flag跳出while循环{b[j]l;j; if(jn) //如果单轮换是最后的数就不用再找了跳出while循环 {flag0;}} else //找到l了可以跳出while循环{flag0; b[j]l;printf(%d ,b[j]);j;il-1;} }else{l;}}flag1; //给下一次找头做准备 }else //a[i]不等于轮换的头 就继续加到轮换里{b[j]a[i];printf(%d ,b[j]);j;ia[i]-1;}}return 0; } 2轮换的复合运算 集合S中的元素个数小于10个,输入该集合的两个轮换t1和t2计算两个轮换的乘积t乘积采用左复合输出的乘积结果t也表示为轮换。输入时每行输入一个不相交轮换tii1,2,输出的乘积为不相交轮换单轮换省略不写。 样例1 输入 (注数字和括号之间都没有空格,括号“(”和)为半角英文) (123)(456) 注t1 (245) 注t2 输出 (1253)(46) 注乘积t的每个轮换的起始数字是递增排序 样例2 输入 (注数字和括号之间都没有空格,括号“(”和)为半角英文) (16)(23) (45) (36)(125) 输出 (13)(2456) 注每个轮换的起始数字是递增排序 样例3 输入 (注数字和括号之间都没有空格,括号“(”和)为半角英文) (2654) (15) 输出 (14265) 注每个轮换的起始数字是递增排序 样例4 输入 (注数字和括号之间都没有空格,括号“(”和)为半角英文) (1392)(475) (267) 输出 (13926547) 注每个轮换的起始数字是递增排序 #include iostream #include cstring using namespace std; int b[20]; void work(int a[],int n){int j,i0,k0,num1,countn-3;printf((1);int b[10]{0};while(kcount-1){if(a[i]!i1)printf(%d,a[i]);b[i]1;k;ia[i]-1;if(a[i]num){b[i]1;k;for(j0;jcount-1;j){if(b[j]0){ij;numj1;if(num!a[i])printf()(%d,num);break;}}}}printf()); }int main() {char x[20],y[20];gets(x);gets(y);int i,j,k;int num10,num20,e0,r0;int count0;int z[20]{0};for(i1;i11;i) //从1开始 {for(j0;jstrlen(y);j) //处理下面的轮换 {if(y[j]-0 i y[j1]!)) //不等于末尾数 {num1y[j1]-0;break;}if(y[j]-0i y[j1])) //等于末尾数 {int m0;for(mj;m0;m--){ if(y[m]() //找到该轮换的第一个数 {num1y[m1]-0;e1;break;}}if(e1){break;}}num1i; //未找到这个数即等于自身。 }for(k0;kstrlen(x);k){if(x[k]-0num1 x[k1]!)) //不等于末位数 {num2x[k1]-0;break;};if(x[k]-0num1 x[k1])){int m0; for(mk;m0;m--){if(x[m](){num2x[m1]-0;r1;break;}}if(r1){break;}};num2num1;}e0;r0;z[count]num2; count;}work(z,count); } /* int main(){char c[50];gets(c);char b[50];gets(b); int i,j,k,num10,num20,e0,r0,count0;int arr[50]{0};for(i1;i11;i){//start from 1for(j0;jstrlen(b);j){if(b[j]-0i b[i1]!)){//非末尾的映射num1b[j1]-0;break; } else if(b[j]-0i b[i1])){//末尾的映射int t;for(tj;t0;t--){if(b[t](){//轮换的第一个数num1b[t1]-0;e1;break; }}if(e1){break;}}num1i;//not found}for(k0;kstrlen(c);k){if(c[k]-0num1 c[k1]!)){num2c[k1]-0;break;}else if(c[k]-0num1 c[k1])){int t0;for(tk;t0;t--){if(c[t](){num2c[t1]-0;r1;break;}}if(r1){break;}}num2num1;}e0;r0;arr[count]num2;}//arr [] , countcout((1);int ret[10]{0};i0;j0;k0;int ncount-3,num1;while(kn-1){if(arr[i]!i1){coutarr[i];}ret[i]1;k;iarr[i]-1;if(arr[i]num){ret[i]1;k;for(j0;jn-1;j){if(ret[j]0){ij;numj1;if(num!arr[i]){cout)(num;break;}}}}}cout);return 0; } */ 好像给的案例最多只有两个划分区域 // int lenstrlen(c),heap[20],flag0,cnt0; // for(int i0;ilen;i){ // if(c[i](){ // flag1; // continue; // } // else if(c[i])){ // flag0; // heap[cnt]-1; // //以-1分割 // } // //利用flag判断是否进数组 // if(flag1){ // heap[cnt]c[i]-0; // } // } // // int lenbstrlen(b),heapb[20],flagb0,cntb0; // for(int i0;ilenb;i){ // if(b[i](){ // flagb1; // continue; // } // else if(b[i])){ // flagb0; // heapb[cntb]-1; // //以-1分割 // } // //利用flag判断是否进数组 // if(flagb1){ // heapb[cntb]b[i]-0; // } // } // for(int i0;icntb;i){coutheapb[i] ;} // // int max-1; // for(int i0;icnt;i){ // if(maxheap[i]){ // maxheap[i]; // } // } // for(int i0;icntb;i){ // if(maxheapb[i]){ // maxheapb[i]; // } // } // //coutmax; // // //开始映射 // int visit[max1]{0};//标记是否visited // visit[0]1; // while(1){ // // } 3脾气牛排队 Cow Sorting Description Farmer Johns N (1 ≤ N ≤ 10,000) cows are lined up to be milked in the evening. Each cow has a unique grumpiness level in the range 1...100,000. Since grumpy cows are more likely to damage FJs milking equipment, FJ would like to reorder the cows in line so they are lined up in increasing order of grumpiness. During this process, the places of any two cows (not necessarily adjacent) can be interchanged. Since grumpy cows are harder to move, it takes FJ a total of XY units of time to exchange two cows whose grumpiness levels are X and Y. Please help FJ calculate the minimal time required to reorder the cows and give the procedure of sorting. 输入 第1行N (整数N代表牛的数量) 第2行到N1行牛的脾气值 输出 第1行最小排队代价值 第2行给牛按脾气值升序排列的排队过程每行表示一对交换脾气值空格分隔 样例 输入 7 6 7 4 5 3 2 1 输出 33 6 1 4 5 3 2 7 6 2 4 5 3 1 7 1 2 4 5 3 6 7 1 2 4 3 5 6 7 1 2 3 4 5 6 7 #include cstdio int main() {int i,j0,k1,flag1,m,n,sum0;int a[20],b[20],c[20][20];scanf(%d,n); for(i0;in;i){scanf(%d,a[i]);}int t0,l1;b[j] l;j;c[t][k] l;k;for(i0;jn;){if(a[i]l || jn) //a[i]等于这一轮换的头或者b[]满了所有数都进入了轮换说明轮换结束{c[t][0] k; //c的每行第一个元素用来记录这个轮换的阶数1if(c[t][1]*(k-2) c[t][1]*2k) //如果该轮换开头的最小的数仍然很大设为big用big做k-2次对换的代价是big*(k-2)先把1和big进行一次对换用1去做k-2次兑换后再换回来代价是(1big)*21*(k-2){int big c[t][1];for(m0;mk;m){ c[t1][m] c[t][m]; //把当前轮换往下挪一步}c[t][0] 3;c[t][1] 1;c[t][2] c[t1][1]; //加入一行轮换对换 把1和开头换一次c[t1][1] 1; //把1换成该轮换的开头 sum 1big;t;for(k--;k1;k--){ sum c[t][1]c[t][k]; //代价加上对换的两个数}t; c[t][0] 3;c[t][1] big;c[t][2] 1; //再加入一行轮换对换 把1和开头换回来sum 1big;}else{for(k--;k1;k--) //每个轮换都会被拆成k-1个对换{ sum c[t][1]c[t][k]; //代价加上对换的两个数} } t;l;while(flag1){for(m0;mj;m){ if(lb[m]){break; //l不能已经在之前的轮换中 }}if(mj) //l不在轮换里 {if(la[l-1]){ b[j] l;j; //单轮换不输出还要接着找头不改变flag跳出while循环 if(jn){flag 0; //如果单轮换是最后的数就不用再找了跳出while循环 } } else{flag 0; b[j] l;j;c[t][k] l;k;i l-1;} }else{l;}}flag1; //给下一次找头做准备}else{ b[j] a[i];j; //b记录出现在所有轮换里的数 c[t][k] a[i];k; //c记录每一次轮换里的数 i a[i]-1;}} printf(%d\n,sum);jt;for(t0;tj;t) //把每个轮换c[t]拆成c[t][0]-1个对换{ for(kc[t][0]-1;k1;k--) //对换c[t][1]和c[t][k]所代表的数在a[]中的位置{int x,y; //x表示c[t][1]代表的数的位置y表示c[t][k]代表的数的位置for(x0;xn;x){if(a[x]c[t][1]){break;}}for(y0;yn;y){if(a[y]c[t][k]){break;}}int t a[y];a[y] a[x];a[x] t;for(m0;mn;m) //输出此次对换结果{printf(%d ,a[m]);} printf(\n);}} return 0; } 4洗牌机问题 Description Alice and Bob have a set of N cards labelled with numbers 1 ... N (so that no two cards have the same label) and a shuffle machine. We assume that N is an odd integer. The shuffle machine accepts the set of cards arranged in an arbitrary order and performs the following operation of double shuffle : for all positions i, 1 i N, if the card at the position i is j and the card at the position j is k, then after the completion of the operation of double shuffle, position i will hold the card k. Alice and Bob play a game. Alice first writes down all the numbers from 1 to N in some random order: a1, a2, ..., aN. Then she arranges the cards so that the position ai holds the card numbered ai1, for every 1 i N-1, while the position aN holds the card numbered a1. This way, cards are put in some order x1, x2, ..., xN, where xi is the card at the ith position. Now she sequentially performs S double shuffles using the shuffle machine described above. After that, the cards are arranged in some final order p1, p2, ..., pN which Alice reveals to Bob, together with the number S. Bobs task is to guess the order x1, x2, ..., xN in which Alice originally put the cards just before giving them to the shuffle machine. Input The first line of the input contains two integers separated by a single blank character : the odd integer N, 1 N 1000, the number of cards, and the integer S, 1 S 1000, the number of double shuffle operations. The following N lines describe the final order of cards after all the double shuffles have been performed such that for each i, 1 i N, the (i1)st line of the input file contains pi (the card at the position i after all double shuffles). Output The output should contain N lines which describe the order of cards just before they were given to the shuffle machine. For each i, 1 i N, the ith line of the output file should contain xi (the card at the position i before the double shuffles). 样例1 输入 7 4 6 3 1 2 4 7 5 输出 4 7 5 6 1 2 3 #includeiostream #includecstdio #includecstring #includealgorithm #includecmath #define N 1003 using namespace std; int n,m; int cnt[N],a[N],ans[N],l[N],use[N],b[N]; int main(){ scanf(%d%d,n,m); int maxn0;int j,i;for(i1;in;i){scanf(%d,a[i]),cnt[i]a[i];} bool flag1; int t0;while(1){t;for(i1;in;i){b[i]a[a[i]];}for(i1;in;i){if(cnt[i]!b[i]) {flagfalse;break;}}if(flag){break;}flagtrue;for(int i1;in;i){a[i]b[i];}}for(i1;in;i){a[i]b[i];}tt-m%t;for(i1;it;i){for(j1;jn;j){b[j]a[a[j]];}for(j1;jn;j){a[j]b[j];}}for(i1;in;i){printf(%d\n,a[i]);}return 0; }
http://www.w-s-a.com/news/11751/

相关文章:

  • 新手做啥网站好dedecms网站的源码如何安装
  • 哪些网站是用iframe免费网站域名查询
  • 自己开的网站 可以做代销吗百度查找相似图片
  • 网站建设设计作业网站备案渝
  • 中国重庆网站建设福州短视频seo获客
  • 遵义官网网站建设网站移动端开发公司
  • 宜春网站推广优化电子商务网站建设收益举例
  • 游戏网站开发实验报告装修平台哪家好
  • 外贸自己建网站小红门网站建设
  • 中国著名的做网站渗透设计规范网站
  • 公司网站备案多少钱推特最新消息今天
  • 网站关键词设置代码seo搜索优化 指数
  • 做网站卖东西送上门做暧暧xoxo网站
  • 网站网站设计公司网站维护运营好做吗
  • 照片做成视频的软件seo两个域名一个网站有影响吗
  • 制作动画的网站河南省住房城乡建设门户网站
  • 网站推广原则做网站的那个语言好
  • 潍坊网站建设怎样商品网站建设设计思路
  • 建网站公司是如何赚钱南昌营销网站公司哪家好
  • 淘宝客网站管理质量好网站建设费用
  • 网站建设教程搭建青岛中企动力做网站怎么样
  • wordpress最底部网站优化怎么弄
  • 二手市场网站建设的目的长沙ui设计公司
  • 微信公众号做留言网站wordpress详情页选择模板
  • php网站开发面向对象教程如何做分享赚钱的网站
  • 山东网站建设最便宜常州网站建站公司
  • 网站地图 seo中国建设招标网是私人网站吗
  • 高中作文网站全网营销有哪些平台
  • 网站构建建设制作平台上海搬家公司收费价目表
  • 成功案例展示网站做网站赚多少钱