[抄题]: There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a direct friend of C, then A is an indirect friend of C. And we defined…
题目: https://leetcode.com/problems/friend-circles/ There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a direct friend of C, then…
android 微信朋友分享,朋友圈分享 包名必须写成  com.weixin WXEntryActivity package com.weixin.wxapi; import android.app.Activity; import android.os.Bundle; import com.tencent.mm.sdk.openapi.BaseReq; import com.tencent.mm.sdk.openapi.BaseResp; import com.tencent.mm.sdk.…
时间限制:4000ms 单点时限:4000ms 内存限制:256MB 描述 你知道KMP吗?它是用于判断一个字符串是否是另一个字符串的子串的算法.今天我们想去扩展它. 在信息理论中,在两个相同长度的字符串之间的海明码距离是:两个字符串相同位置对应的字符不同的位置数目.换种说法,它表示将一个字符串转化为另一个字符串所需要改变字符的最小数目. 下面这些字符串之间的海明码距离: "karolin"和"kathrin"是3. "karolin"和&quo…
There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a direct friend of C, then A is an indirect friend of C. And we defined a fri…
班上有 N 名学生.其中有些人是朋友,有些则不是.他们的友谊具有是传递性.如果已知 A 是 B 的朋友,B 是 C 的朋友,那么我们可以认为 A 也是 C 的朋友.所谓的朋友圈,是指所有朋友的集合.给定一个 N * N 的矩阵 M,表示班级中学生之间的朋友关系.如果M[i][j] = 1,表示已知第 i 个和 j 个学生互为朋友关系,否则为不知道.你必须输出所有学生中的已知的朋友圈总数.示例 1:输入: [[1,1,0], [1,1,0], [0,0,1]]输出: 2 说明:已知学生0和学生1互…
/* 思路就是遍历所有人,对于每一个人,寻找他的好友,找到好友后再找这个好友的好友 ,这样深度优先遍历下去,设置一个flag记录是否已经遍历了这个人. 其实dfs真正有用的是flag这个变量,因为如果m个人最多m个朋友圈,设置后flag后,相同的朋友圈会 检测到flag就会不算数. */ public int findCircleNum(int[][] M) { int m = M.length; if (m==0) return 0; int res = 0; boolean[] flag =…
There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a direct friend of C, then A is an indirect friend of C. And we defined a fri…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.com/problems/friend-circles/#/description 题目描述 There are N students in a class. Some of them are friends, while some are not. Their friendship is trans…
题目链接:http://lightoj.com/volume_showproblem.php?problem=1366 题意:一个H*W的矩形,现在要放入两个外切的圆,问能放多少对这样的圆,其中圆心和半径都是整数: 枚举相对的圆心坐标,根据圆心的距离,再枚举一个圆的半径: #include<stdio.h> #include<iostream> #include<string.h> #include<algorithm> #include<cmath&…