zoj 3710 Friends】的更多相关文章

Alice lives in the country where people like to make friends. The friendship is bidirectional and if any two person have no less than k friends in common, they will become friends in several days. Currently, there are totally n people in the country,…
#include<stdio.h> #include<string.h> ][],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*/ ;i<…
题目链接:https://cn.vjudge.net/contest/280949#problem/F 题目大意:给你n个人,然后给你m个关系,每个关系输入t1, t2 .代表t1和t2是朋友关系(双向关系).然后输入一个k,代表两个人是亲密的朋友关系的话,就至少有k个共同的朋友,然后问你题目中这样的朋友有多少对? 具体思路:注意一个地方,朋友关系具有传递性,打个比方 t1和t2 变成了亲密的朋友,然后t0 本来和t1是朋友关系,但是和t2不是朋友关系,t1和t2成为朋友之后,t0也就和t2称为…
Problem Alice lives in the country where people like to make friends. The friendship is bidirectional and if any two person have no less than k friends in common, they will become friends in several days. Currently, there are totally n people in the…
第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ  3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=3944 In a BG (dinner gathering) for ZJU ICPC team, the coaches wanted to count the number of people present at the BG. They did that by having the waitre…
A Simple Tree Problem Time Limit: 3 Seconds      Memory Limit: 65536 KB Given a rooted tree, each node has a boolean (0 or 1) labeled on it. Initially, all the labels are 0. We define this kind of operation: given a subtree, negate all its labels. An…
这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求输入的格式: START X Y Z END 这算做一个data set,这样反复,直到遇到ENDINPUT.我们可以先吸纳一个字符串判断其是否为ENDINPUT,若不是进入,获得XYZ后,吸纳END,再进行输出结果 2.注意题目是一个圆周,所以始终用锐角进行计算,即z=360-z; 3.知识点的误…
放了一个长长的暑假,可能是这辈子最后一个这么长的暑假了吧,呵呵...今天来实验室了,先找了zoj上面简单的题目练练手直接贴代码了,不解释,就是一道简单的密文转换问题: #include <stdio.h> #include <string.h> int main() { char cText[1000]; char start[10]; char end[5]; while(scanf("%s",start)!=EOF&&strcmp(start…
这道题目说白了是一道平面几何的数学问题,重在理解题目的意思: 题目说,弗雷德想买地盖房养老,但是土地每年会被密西西比河淹掉一部分,而且经调查是以半圆形的方式淹没的,每年淹没50平方英里,以初始水岸线为x轴,平分半圆为y轴,建立如下图的坐标系 问题:给出坐标点(y>0),让你判断在那一年这个坐标点会被淹没. 解决方案:我们可以转换成的数学模型是来比较坐标点到原点的距离与半圆半径的大小即可知道该点是否被淹没,公式如下: 1.由于每年半圆面积增长50平方英里,可得半径递推公式R2=sqrt(100/p…
今天在ZOJ上做了道很简单的题目是关于加密解密问题的,此题的关键点就在于求余的逆运算: 比如假设都是正整数 A=(B-C)%D 则 B - C = D*n + A 其中 A < D 移项 B = A+C + D*n 当B<D时,两边对D取摸,  B = B%D = ( A+C + D*n )%D = (A+C)%D 由此可得此题答案,见代码 #include <cstdio> #include <cstring> int main() { ]; ],ctext[]; w…