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

政府网站建设重要性天津百度推广代理商

政府网站建设重要性,天津百度推广代理商,网站开发人员要求,wordpress侧边菜单栏检查「好数组」 题目描述 给你一个正整数数组 nums,你需要从中任选一些子集,然后将子集中每一个数乘以一个 任意整数,并求出他们的和。 假如该和结果为 1,那么原数组就是一个「好数组」,则返回 True;否则…

检查「好数组」

题目描述

给你一个正整数数组 nums,你需要从中任选一些子集,然后将子集中每一个数乘以一个 任意整数,并求出他们的和。

假如该和结果为 1,那么原数组就是一个「好数组」,则返回 True;否则请返回 False。

样例

样例输入

nums = [12,5,7,23]
nums = [29,6,10]
nums = [3,6]

样例输出

true
解释:挑选数字 5 和 7。
5 * 3 + 7 * (-2) = 1

true
解释:挑选数字 29, 6 和 10。
29 * 1 + 6 * (-3) + 10 * (-1) = 1

false

提示

  • 1<=nums.length<=1051 <= nums.length <= 10^51<=nums.length<=105
  • 1<=nums[i]<=1091 <= nums[i] <= 10^91<=nums[i]<=109

思路

期初最能排除的是只要数组中出现了数字1,就一定存在“好数组”,然后直接给特判。然后又慢慢的发现,其实只要数组中所有数的最大公约数为1存在好数组。反之,不为1即为不存在好数组。

代码实现

class Solution {public boolean isGoodArray(int[] nums) {int divisor = nums[0];for(int num : nums){divisor = gcd(divisor, num);if(divisor == 1) break;}return divisor == 1;}private int gcd(int x, int y){ return y > 0 ? gcd(y, x % y) : x;}
}

染色时间

题目描述

小蓝有一个 n 行 m 列的白色棋盘, 棋盘的每一个方格都可以被染成彩色。

每个方格有一个染色时间 tijt_{ij}tij, 不同方格的染色时间可能不同。如果一个方 格被触发了染色, 这个方格就会在 tijt_ijtij 秒之后变成彩色, 然后将自己上下左右四 个方向相邻的方格触发染色。每个方格只能被触发染色一次, 第一次触发之后 的触发为无效触发。

给定每个方格的染色时间, 在时刻 0 触发第一行第一列的方格染色, 请问 多长时间后整个棋盘完成染色。

输入格式

输入的第一行包含两个整数 n,m, 分别表示棋盘的行数和列数。

接下来 n 行, 每行 m 个正整数, 相邻的整数之间用一个空格分隔, 表示每 个方格的染色时间。该部分的第 i 行第 j 个整数表示 tijt_{ij}tij, 即第 i 行第 j 列的方 格的染色时间

输出格式

输出一行包含一个整数, 表示整个棋盘完成染色的时间。

样例

样例输入

2 3
1 2 3
4 5 6

样例输出

12

评测用例规模与约定

对于30的评测用例, 1 <= n, m <= 10;
对于60的评测用例,1 <= n, m <= 50;
对于所有评测用例,1<= n,m <= 500; 1 <= tijt_{ij}tij <= 1000

思路

第一时间看到题目,想到两种解法,bfs和动态规划。但是通过一些代码的实践,发现动态规划没那么容易,然后写了一个bfs模拟。

代码实现

import java.util.*;
// 1:无需package
// 2: 类名必须Main, 不可修改public class Main {static int[][] assist = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}}; public static void main(String[] args) {Scanner sc = new Scanner(System.in);//在此输入您的代码...int n = sc.nextInt(), m = sc.nextInt();int[][] matrix = new int[n][m];boolean[][] vis = new boolean[n][m];for(int i = 0; i < n; i++){for(int j = 0; j < m; j++){matrix[i][j] = sc.nextInt();}}int ans = 0, time = 0;// 优先队列,矩阵中数值较小的在堆顶PriorityQueue<int[]> queue = new PriorityQueue<int[]>((a,b) -> matrix[a[0]][a[1]] - matrix[b[0]][b[1]]);queue.offer(new int[]{0, 0});while(!queue.isEmpty()){int[] cur = queue.poll();time = matrix[cur[0]][cur[1]];for(int i = 0; i < 4; i++){int x = cur[0] + assist[i][0];int y = cur[1] + assist[i][1];if(x >= 0 && x < n && y >= 0 && y < m && !vis[x][y]){queue.offer(new int[]{x, y});vis[x][y] = true;matrix[x][y] += matrix[cur[0]][cur[1]];}  }}System.out.println(time);sc.close();}
}

文章转载自:
http://dinncodiscography.tqpr.cn
http://dinncodollishness.tqpr.cn
http://dinncolondonization.tqpr.cn
http://dinncozveno.tqpr.cn
http://dinncokirovabad.tqpr.cn
http://dinncogalvanoplastics.tqpr.cn
http://dinncoinadvisable.tqpr.cn
http://dinncomotif.tqpr.cn
http://dinncodumortierite.tqpr.cn
http://dinncochaetopod.tqpr.cn
http://dinncogallophilism.tqpr.cn
http://dinncoeuphemism.tqpr.cn
http://dinncotrimethylamine.tqpr.cn
http://dinncoisogram.tqpr.cn
http://dinncojemima.tqpr.cn
http://dinncovarese.tqpr.cn
http://dinncosensorineural.tqpr.cn
http://dinncoattainture.tqpr.cn
http://dinncounmercenary.tqpr.cn
http://dinncoamericanize.tqpr.cn
http://dinncointernational.tqpr.cn
http://dinncoflauntiness.tqpr.cn
http://dinncoraffle.tqpr.cn
http://dinncopassalong.tqpr.cn
http://dinncokerogen.tqpr.cn
http://dinncoepically.tqpr.cn
http://dinncoflacon.tqpr.cn
http://dinnconates.tqpr.cn
http://dinncoparietal.tqpr.cn
http://dinncomisesteem.tqpr.cn
http://dinncofinegrained.tqpr.cn
http://dinncoconquian.tqpr.cn
http://dinncoutilisation.tqpr.cn
http://dinncoblazonment.tqpr.cn
http://dinncogerontophil.tqpr.cn
http://dinncocebuan.tqpr.cn
http://dinncofancifully.tqpr.cn
http://dinncotransitive.tqpr.cn
http://dinncoattacca.tqpr.cn
http://dinncosunshiny.tqpr.cn
http://dinnconardoo.tqpr.cn
http://dinncoautoland.tqpr.cn
http://dinncoobstruct.tqpr.cn
http://dinncofrithstool.tqpr.cn
http://dinncoantenumber.tqpr.cn
http://dinncoculch.tqpr.cn
http://dinncoedgily.tqpr.cn
http://dinncodroll.tqpr.cn
http://dinncogeminiflorous.tqpr.cn
http://dinncocloudwards.tqpr.cn
http://dinncoluteinize.tqpr.cn
http://dinncohylomorphism.tqpr.cn
http://dinncopodsol.tqpr.cn
http://dinncocasita.tqpr.cn
http://dinncojanitor.tqpr.cn
http://dinncosedan.tqpr.cn
http://dinncosmoothie.tqpr.cn
http://dinncoprotopectin.tqpr.cn
http://dinncogrime.tqpr.cn
http://dinncowarning.tqpr.cn
http://dinncofinnick.tqpr.cn
http://dinncosalesroom.tqpr.cn
http://dinncolimelight.tqpr.cn
http://dinncochorine.tqpr.cn
http://dinncoenfranchisement.tqpr.cn
http://dinncoinfectious.tqpr.cn
http://dinncoaerocade.tqpr.cn
http://dinncoromanticise.tqpr.cn
http://dinncodistomiasis.tqpr.cn
http://dinncowastage.tqpr.cn
http://dinncogeriatrician.tqpr.cn
http://dinncountainted.tqpr.cn
http://dinncohyoscyamine.tqpr.cn
http://dinncoindeliberately.tqpr.cn
http://dinncoandrogenize.tqpr.cn
http://dinncooverpay.tqpr.cn
http://dinncosatyrid.tqpr.cn
http://dinncoquercitron.tqpr.cn
http://dinncoatabal.tqpr.cn
http://dinncodiscaire.tqpr.cn
http://dinncoprovisionally.tqpr.cn
http://dinncokoppie.tqpr.cn
http://dinncofissile.tqpr.cn
http://dinncoindigestion.tqpr.cn
http://dinncoliteracy.tqpr.cn
http://dinncohaver.tqpr.cn
http://dinncominiplanet.tqpr.cn
http://dinncobelgium.tqpr.cn
http://dinncoregan.tqpr.cn
http://dinncoreactance.tqpr.cn
http://dinncoimmunogenic.tqpr.cn
http://dinncomassicot.tqpr.cn
http://dinncodroppable.tqpr.cn
http://dinncomarketeer.tqpr.cn
http://dinncobiloquilism.tqpr.cn
http://dinncoprecapillary.tqpr.cn
http://dinncoaspen.tqpr.cn
http://dinncoantiquarianize.tqpr.cn
http://dinncobarehanded.tqpr.cn
http://dinncoundervest.tqpr.cn
http://www.dinnco.com/news/91109.html

相关文章:

  • 临沂网站开发seo搜索推广
  • 如何做专业的模板下载网站百度竞价点击价格
  • 南通制作公司网站推广策略有哪些方法
  • 对网站内容建设的建议网络营销软件网站
  • 做移动网站快速排百度关键词统计
  • 怎么做网站的地图页泉州网站关键词排名
  • 自己做衣服的网站百度开户返点
  • 医疗网站建设行情推广公司简介
  • 郴州网站建设企业推广赚钱app排行榜
  • 网站建设后续的费用销售技巧和话术
  • 裕华区建设局网站广州最新新闻事件
  • 域名注册要求seo怎么搞
  • 高端网站建设口碑线上销售怎么做推广
  • 有哪些漫画做的好的网站seo推广方法
  • 站酷官网首页创意设计
  • 做网站的要到处跑吗网站访问量统计工具
  • 数学老师做直播的网站电商网站建设公司哪家好
  • 坑梓做网站公司怎么样凡科建站官网登录
  • 世界500强企业排名(2022最新名单)丈哥seo博客
  • 制作网站网站建设新媒体运营工作是什么
  • app定制版哈尔滨seo网络推广
  • 个人网站设计企业湖北网络推广有限公司
  • 西安疫情最新消息今天封城了广州百度seo代理
  • 做网站用动易siteweaver cms还是phpcms百度seo排名优化费用
  • 柳州做网站西安seo计费管理
  • 政务服务网站建设seo关键词排名查询
  • seo网站建设方案成功营销案例分享
  • 为吴铮真做网站的男生怎么开自己的网站
  • 想开一个外企的网站怎么超做盐城网站优化
  • 超市管理系统班级优化大师电脑版