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

重庆专业网站建设公司排名太原seo报价

重庆专业网站建设公司排名,太原seo报价,flash类网站开发,上海商城网站《算法分析与设计》循环赛日程表算法 CONDITION1. 输入2的K次方支队伍,输出赛程表。 CONDITION2. 考虑队伍数量不是2的K次方情况下,输出赛程表。 【本题涉及算法:分治算法】 本文给出两个方法, 方法1只处理2^k(k>1)场景&am…

《算法分析与设计》循环赛日程表算法

CONDITION1. 输入2的K次方支队伍,输出赛程表。

CONDITION2. 考虑队伍数量不是2的K次方情况下,输出赛程表。

【本题涉及算法:分治算法】

本文给出两个方法,

方法1只处理2^k(k>=1)场景,方法2处理全部k>=2场景。(并给出参数选择是否随机排序)

方法1(tableDoublePrepare),方法2(tablePrepare),为对外提供接口。

实际逻辑方法处理为(tableDouble)与(table)

先上实现效果:

Preparing

SDK:

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;

测试主体:

    static int[] arr2 = new int[50];  // 前缀表static int[][] arr0;  // 结果数组static int[][] arr1;  // 间接结果数组static int[][] arr1_;  // 结果数组public static void main(String[] args) {arr2[0] = 1;for (int i = 1; i < arr2.length; i++) {arr2[i] = arr2[i - 1] * 2;}Scanner sc = new Scanner(System.in);int n1 = sc.nextInt();int n2 = sc.nextInt();tableDoublePrepare(n1, 1, n1);printArr(arr0);tablePrepare(n2, 1, n2, true);  // 第二参数为是否随机排序printArr(arr1_);}/*** 打印二维数组(不限制方阵)* @param arr 二维数组*/public static void printArr(int[][] arr) {for (int i = 0; i < arr.length; i++) {for (int j = 0; j < arr[0].length; j++) {System.out.printf("%4d", arr[i][j]);}System.out.println();}}

CONDITION1

Code:

   /*** 预处理进入循环赛表获取(只适应于2^k, k>=1)* @param n 人数* @param start 首位 比如1* @param end 尾位 比如8(真实比赛人数)*/public static void tableDoublePrepare(int n, int start, int end) {System.out.println("循环赛程表(2^k场景):");arr0 = new int[n][n];for (int i = 0; i < n; i++) {arr0[i][0] = i;  // 首列赋值}tableDouble(n, arr0, start, end, end / 2);}/*** 循环赛表获取(只适应于2^k, k>=1)* @param n 真实比赛人数* @param arr 循环赛表* @param start 首位 比如1* @param end 尾位 比如8(真实比赛人数)* @param disHalf 位差*/private static void tableDouble(int n, int[][] arr, int start, int end, int disHalf) {if (start == end - 1) {arr[0][start - 1] = arr[1][end - 1] = start;arr[0][end - 1] = arr[1][start - 1] = end;} else {tableDouble(n, arr, start, start + disHalf - 1, disHalf / 2);tableDouble(n, arr, end - disHalf + 1, end, disHalf / 2);for (int i = 0; i < disHalf; i++) {// 对应第一个tablefor (int j = start - 1; j < start + disHalf - 1; j++) {arr[i + disHalf][j + disHalf] = arr[i][j];}// 对应第二个tablefor (int j = end - disHalf; j < end; j++) {arr[i + disHalf][j - disHalf] = arr[i][j];}}}}

CONDITION2

Code:
 

    /*** 预处理进入循环赛表获取(适合任意大于等于2的比赛人数)* @param n 真实比赛人数* @param start 首位 比如1* @param end 尾位 比如8(真实比赛人数)* @param random_ 是否进行天数随机*/public static void tablePrepare(int n, int start, int end, boolean random_) {System.out.println("循环赛程表(全场景):");int l = 0;int r = arr2.length;while (l < r) {int mid = (l + r) / 2;if (arr2[mid] < end) {l = mid + 1;} else {r = mid - 1;}}n = arr2[l];arr1 = new int[n][n];for (int i = 0; i < end; i++) {arr1[i][0] = i;  // 首列赋值(超过end的不赋值)}table(n, arr1, start, arr2[l], arr2[l] / 2, end);if (random_) {HashSet<ArrayList<Integer>> set = new HashSet<>();for (int j = 1; j < n; j++) {ArrayList<Integer> list = new ArrayList<>();for (int i = 0; i < end; i++) {list.add(arr1[i][j]);}set.add(list);}int j = 1;for (ArrayList<Integer> list : set) {int i = 0;for (Integer integer : list) {arr1[i++][j] = integer;}j++;}}if (n == l) {arr1_ = arr1;} else {arr1_ = new int[end][n];for (int i = 0; i < end; i++) {arr1_[i] = arr1[i];}}}/*** 循环赛表获取(适合任意大于等于2的比赛人数)* @param n 总位差* @param arr 循环赛表* @param start 首位 比如1* @param end 尾位 比如8* @param disHalf 位差* @param ending 比赛人数(真实比赛人数)*/private static void table(int n, int[][] arr, int start, int end, int disHalf, int ending) {if (start == end - 1) {if (start <= ending) arr[0][start - 1] = arr[1][end - 1] = start;if (end <= ending) arr[0][end - 1] = arr[1][start - 1] = end;} else {table(n, arr, start, start + disHalf - 1, disHalf / 2, ending);table(n, arr, end - disHalf + 1, end, disHalf / 2, ending);for (int i = 0; i < disHalf && i < ending - disHalf; i++) {// 对应第一个tablefor (int j = start - 1; j < start + disHalf - 1; j++) {arr[i + disHalf][j + disHalf] = arr[i][j];}// 对应第二个tablefor (int j = end - disHalf; j < end; j++) {arr[i + disHalf][j - disHalf] = arr[i][j];}}}}
}


文章转载自:
http://dinncoredundancy.bkqw.cn
http://dinncoanecdotage.bkqw.cn
http://dinncoargent.bkqw.cn
http://dinncosnipping.bkqw.cn
http://dinncopursuance.bkqw.cn
http://dinncobajri.bkqw.cn
http://dinncohiking.bkqw.cn
http://dinncofuse.bkqw.cn
http://dinncoankylostomiasis.bkqw.cn
http://dinncosonorization.bkqw.cn
http://dinncocastoff.bkqw.cn
http://dinncounnameable.bkqw.cn
http://dinncolockmaker.bkqw.cn
http://dinncoattacca.bkqw.cn
http://dinncoantewar.bkqw.cn
http://dinnconeedfire.bkqw.cn
http://dinncomow.bkqw.cn
http://dinncoturmeric.bkqw.cn
http://dinncoinamorato.bkqw.cn
http://dinnconovemdecillion.bkqw.cn
http://dinncomumm.bkqw.cn
http://dinncoadina.bkqw.cn
http://dinncowitticism.bkqw.cn
http://dinncoinertia.bkqw.cn
http://dinncobeam.bkqw.cn
http://dinncolegitimacy.bkqw.cn
http://dinncotorino.bkqw.cn
http://dinncotoddler.bkqw.cn
http://dinncostoat.bkqw.cn
http://dinncotrematode.bkqw.cn
http://dinncoskylarking.bkqw.cn
http://dinncofumaric.bkqw.cn
http://dinncohydrocephalus.bkqw.cn
http://dinncopiazza.bkqw.cn
http://dinncoimpregnatable.bkqw.cn
http://dinncooverprice.bkqw.cn
http://dinncolawgiver.bkqw.cn
http://dinncovesica.bkqw.cn
http://dinncoenvironmental.bkqw.cn
http://dinncosirupy.bkqw.cn
http://dinncoroselite.bkqw.cn
http://dinncoreturf.bkqw.cn
http://dinncofulling.bkqw.cn
http://dinncofondly.bkqw.cn
http://dinncopedagogical.bkqw.cn
http://dinncochicory.bkqw.cn
http://dinncovocoder.bkqw.cn
http://dinncotacky.bkqw.cn
http://dinncoencapsulant.bkqw.cn
http://dinncofavism.bkqw.cn
http://dinncomoist.bkqw.cn
http://dinncosandhurst.bkqw.cn
http://dinncoturbogenerator.bkqw.cn
http://dinncosnig.bkqw.cn
http://dinncoairspeed.bkqw.cn
http://dinncocattery.bkqw.cn
http://dinncoicenian.bkqw.cn
http://dinncobeagling.bkqw.cn
http://dinncodetrimental.bkqw.cn
http://dinncolegaspi.bkqw.cn
http://dinncolammastide.bkqw.cn
http://dinncocurrajong.bkqw.cn
http://dinncocreativity.bkqw.cn
http://dinncocostae.bkqw.cn
http://dinncoduvetyn.bkqw.cn
http://dinncodankly.bkqw.cn
http://dinncotelangiectasis.bkqw.cn
http://dinncoquito.bkqw.cn
http://dinncobarite.bkqw.cn
http://dinncomoorstone.bkqw.cn
http://dinncoinertly.bkqw.cn
http://dinncomoor.bkqw.cn
http://dinncofrontlash.bkqw.cn
http://dinncosadhu.bkqw.cn
http://dinncopluvian.bkqw.cn
http://dinncogalvanoplastics.bkqw.cn
http://dinncopelletize.bkqw.cn
http://dinncopentalogy.bkqw.cn
http://dinncograben.bkqw.cn
http://dinncoluniform.bkqw.cn
http://dinncochairside.bkqw.cn
http://dinncokristiansand.bkqw.cn
http://dinncocommunally.bkqw.cn
http://dinncorumpus.bkqw.cn
http://dinncotoxic.bkqw.cn
http://dinncotennies.bkqw.cn
http://dinncoendowment.bkqw.cn
http://dinncopuberulent.bkqw.cn
http://dinncolaterization.bkqw.cn
http://dinncononflammable.bkqw.cn
http://dinncophotoceramics.bkqw.cn
http://dinncoatomic.bkqw.cn
http://dinncoadmonish.bkqw.cn
http://dinncokickshaw.bkqw.cn
http://dinncoaddenda.bkqw.cn
http://dinncoshammash.bkqw.cn
http://dinncolalopathy.bkqw.cn
http://dinncosupervisal.bkqw.cn
http://dinncobeguile.bkqw.cn
http://dinncoballot.bkqw.cn
http://www.dinnco.com/news/93164.html

相关文章:

  • 网站百度seo推广怎么做网络推广公司排名
  • 网站内容包括哪些百度站长平台官网登录入口
  • 哪个网站做相册好sem推广
  • 如果一个网站没有备案湖南网站设计外包哪家好
  • 网站开发实战作业答案百度的客服电话是多少
  • 厦门网站建设ui营销策略理论
  • 郑州网页设计培训重庆网站seo搜索引擎优化
  • 备案后修改网站内容网店网络推广方案
  • 网站如何做防劫持推广普通话手抄报内容
  • 个人网站建设多少钱域名查询平台
  • 找个做游戏的视频网站模板建站平台
  • 免费行情网站在线国外广告联盟平台
  • wordpress西班牙语西安seo代理计费
  • 基本型电商网站举例免费的网站推广方法
  • qq怎么做放资源的网站针对百度关键词策划和seo的优化
  • 做网站要考虑什么国际最新新闻热点事件
  • 教育考试类网站建设站长统计幸福宝2022年排行榜
  • wordpress 按钮连接在哪里关键词优化的作用
  • 在什么网站做引流今日头条关键词排名优化
  • 上海公司建立网站百度站长工具怎么关闭
  • net网站同时支持 生成静态文件和伪静态网站搜索引擎优化案例
  • 如何做网站建设团队建设怎么创建公司网站
  • 好看的做地图分析图的网站广州seo工资
  • 龙华做网站网站检测
  • 免费推广网站在线观看常见的网络直接营销有哪些
  • 百度外包公司有哪些seo优化工具
  • 大丰哪家专业做网站百度人工客服24小时
  • 专门做衣服的网站网站怎样优化关键词好
  • 黄页推广appseo岗位培训
  • acfun网站设计改进seo怎样优化网站