zoj 3710 Friends
#include<stdio.h>
#include<string.h>
int s[][],h;
int main(int argc, char* argv[])
{ int t,i,n,k,m,x,y,count,sum,j;
scanf("%d",&t); while(t--)
{ scanf("%d%d%d",&n,&m,&h);
memset(s,,sizeof(s));/*初始化矩阵所有的值为0*/
for(i=;i<m;i++)/*初始化矩阵为有效值*/
{
scanf("%d%d",&x,&y);
s[x][y]=;
s[y][x]=;
}
sum=;
for(i=;i<n;i++)/*第i行*/
{ for(j=i+;j<n;j++)/*第i+1行*/
{
count=;
if(s[i][j]==)
continue; for(k=;k<n;k++)/*找每一列,找到两行共同的列*/
if(s[i][k]==&&s[j][k]==)
count++; if(count>=h)/*如果有超过一个共同的好友就可以更新矩阵了*/
{
sum++;/*新关系的数量*/
s[i][j]=;
s[j][i]=;
i=-;/*重置i,重新遍历矩阵*/
break;
}
}
} printf("%d\n",sum);
} return ;
}
zoj 3710 Friends的更多相关文章
- [ACM_暴力] ZOJ 3710 [Friends 共同认识 最终认识 暴力]
Alice lives in the country where people like to make friends. The friendship is bidirectional and if ...
- F - Friends ZOJ - 3710(暴力)
题目链接:https://cn.vjudge.net/contest/280949#problem/F 题目大意:给你n个人,然后给你m个关系,每个关系输入t1, t2 .代表t1和t2是朋友关系(双 ...
- Friends (ZOJ - 3710)
Problem Alice lives in the country where people like to make friends. The friendship is bidirectiona ...
- ZOJ People Counting
第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ 3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...
- ZOJ 3686 A Simple Tree Problem
A Simple Tree Problem Time Limit: 3 Seconds Memory Limit: 65536 KB Given a rooted tree, each no ...
- ZOJ Problem Set - 1394 Polar Explorer
这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求 ...
- ZOJ Problem Set - 1392 The Hardest Problem Ever
放了一个长长的暑假,可能是这辈子最后一个这么长的暑假了吧,呵呵...今天来实验室了,先找了zoj上面简单的题目练练手直接贴代码了,不解释,就是一道简单的密文转换问题: #include <std ...
- ZOJ Problem Set - 1049 I Think I Need a Houseboat
这道题目说白了是一道平面几何的数学问题,重在理解题目的意思: 题目说,弗雷德想买地盖房养老,但是土地每年会被密西西比河淹掉一部分,而且经调查是以半圆形的方式淹没的,每年淹没50平方英里,以初始水岸线为 ...
- ZOJ Problem Set - 1006 Do the Untwist
今天在ZOJ上做了道很简单的题目是关于加密解密问题的,此题的关键点就在于求余的逆运算: 比如假设都是正整数 A=(B-C)%D 则 B - C = D*n + A 其中 A < D 移项 B = ...
随机推荐
- android中onStartActivityForResult无返回值问题
在activity间跳转传递参数,常见方法是通过onStartActivityForResult来做.不过今天使用 onStartActivityForResult的时候已经在上一个activity调 ...
- /etc/security/limits.conf 配置
<pre name="code" class="python">* soft nofile 65535 * hard nofile 65535 * ...
- centos 6.7 perl 5.22 安装DBD 需要使用老的perl版本
zjzc01:/usr/bin# mv perl.bak perlold zjzc01:/usr/bin# cd zjzc01:/root# cd DBD-Oracle-1.36 zjzc01:/ro ...
- MFC 可以设置背景色、字体、字体颜色、透明背景的 Static 静态文本控件
MFC库里没有符合这个条件的控件,于是我自己写了一个,初步测试有效. 注:可以设置透明背景,但还不能做到透明度设置(如50%透明度) 如果设置了背景色,就不保留透明背景 默认背景色是透明的 [cpp] ...
- Spring mvc 简单异常配置jsp页面
原文出处:http://howtodoinjava.com/spring/spring-mvc/spring-mvc-simplemappingexceptionresolver-example/ 这 ...
- hdu-4468-Spy-KMP+贪心
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4468 题目意思: 给你一个串r,求一个串s,使得s的前缀1+s的前缀2+s的前缀3+...+s的前缀 ...
- C#实现按Word模板导出Word(加书签bookMark)
本方法是针对word导出操作,需要制作好的模板文件 模板.doc 引入应用Microsoft.Office.Interop.Word 11.0 (office2003) 导出文件注意:有时候迅雷会在 ...
- oracle 导入txt
没有Oraclehoume的情况下,执行下环境变量文件 sqlldr userid= DM/DM control = /home/oracle/libc/load.ctl load data infi ...
- C++/C#结构体转化-传string给C++
此例是把C#结构传给C++ C++: typedef struct VidyoClientInEventGroupChat_ { /*! Message (contents) to be sent t ...
- 搭建Hadoop集群 (二)
前面的步骤请看 搭建Hadoop集群 (一) 安装Hadoop 解压安装 登录master, 下载解压hadoop 2.6.2压缩包到/home/hm/文件夹. (也可以从主机拖拽或者psftp压缩 ...