Good的集合

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_43705195/article/details/90767506

链接:https://ac.nowcoder.com/acm/contest/911/A
来源:牛客网

Good 的集合

题目描述
平面上给 n(3≤n≤1000) 个点,保证不存在 3 点共线,保证这些点两两不重合,对于一个点集 S ,如果从 S 中任意选出三个不同的点,构成的三角形重心都不是整点(横坐标,纵坐标都是整数的点,称为整点),那么这个点集是 good 的,输出最大的 good 的点集大小。(注:所有点数小于等于 2 的点集都是 good 的)。
输入描述:
第一行,一个整数 n (3≤n≤1000),表示 n 个点,之后 n 行,每行两个整数 x[i],y[i] (0≤x[i],y[i]≤106).’
输出描述:
输出一个正整数表示答案。

示例1

输入
4
0 0
0 1
1 0
1 1

输出
4

示例2

输入
3
0 0
1 2
2 1

输出
2
备注:

  • 样例 1 所有点都可以加入集合。

  • 样例 2,如果 3 个点同时加入集合,重心为 (1,1) 不合法,Good Set 中至多只能 2 个点。

因为中心要 / 3所以先直接/ 3 然后对于每种情况的个数枚举dfs搜索

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1010;
int x[maxn], y[maxn];
int num[4][4];
int ans, n;
bool check(int s){//check符不符合条件
	for (int i = 0; i<=s; i++)
	for (int j = i+1; j<=s;j++)
	for (int k = j+1; k<=s; k++){
		int v = x[i] + x[j] + x[k];
		int u = y[i] + y[j] + y[k];
		if (v % 3 == 0 && u % 3 == 0) return 0;
	}
	return 1;
}
void dfs(int s){
	ans = max(ans, s);
	if (s > n) return;
	for (int i = 0; i < 3;i++)
	for (int j = 0; j < 3; j++){
		x[s] = i, y[s] = j;
		if (num[i][j]){//枚举当前个数
			if (check(s)){
				num[i][j]--;
				dfs(s + 1);
				num[i][j]++;
			}
		}
	}
}
int main(){
	cin >> n;
	for (int i = 1; i <= n; i++){
		int x, y;
		cin >> x >> y;
		x %= 3;y %= 3;
		num[x][y]++;
	}
	dfs(0);
	cout << ans << endl;
	return 0;
}
展开阅读全文

Good Article Good sentence

11-20

Problem DescriptionnIn middle school, teachers used to encourage us to pick up pretty sentences so that we could apply those sentences in our own articles. One of my classmates ZengXiao Xian, wanted to get sentences which are different from that of others, because he thought the distinct pretty sentences might benefit him a lot to get a high score in his article.nAssume that all of the sentences came from some articles. ZengXiao Xian intended to pick from Article A. The number of his classmates is n. The i-th classmate picked from Article Bi. Now ZengXiao Xian wants to know how many different sentences she could pick from Article A which don't belong to either of her classmates?Article. To simplify the problem, ZengXiao Xian wants to know how many different strings, which is the substring of string A, but is not substring of either of string Bi. Of course, you will help him, won't you?n nnInputnThe first line contains an integer T, the number of test data. nFor each test datanThe first line contains an integer meaning the number of classmates.nThe second line is the string A;The next n lines,the ith line input string Bi.nThe length of the string A does not exceed 100,000 characters , The sum of total length of all strings Bi does not exceed 100,000, and assume all string consist only lowercase characters 'a' to 'z'.n nnOutputnFor each case, print the case number and the number of substrings that ZengXiao Xian can find.n nnSample Inputn3n2nababnabnban1naaanbbbn2naaaanaanaaan nnSample OutputnCase 1: 3nCase 2: 3nCase 3: 1n 问答

good!

11-09

如今呆得实在无聊,除了上网还是上网! rn   在网上漫游过程中,我发现了一个问题, rn   有很多的各个网站都说能为你赚到很多钱,为啥呢? rn   就连读一封 E-mail 点几回广告栏都能挣到钱? rn   难以置信,天下哪有免费的午餐?(后来才弄清是广告商买单), 可呆着实在是无聊啊,反正闲着也是闲着, 我就找了一个不要身份证,不要会员费, 只要有个地址,电话号码就能挣到钱的网站, rn rn 申请成了会员……(反正挣不到钱也不会吃亏,哼!)(再加上有前人的先列在先怕啥:)) rn 也如前人一样: rn   等了一个月,两个月…… rn   什么汇款单?连个影子都没有! rn   不过一想,无所谓了,反正也没吃亏! rn   就当是鬼迷心窍一回吧! 哈哈! rn   可一直到了3个月…… rn   突然,汇款单到了!不看不知道,一看吓一跳! rn   5百多美金?折合人民币不就是4千多了吗? rn   半信半疑,到了银行,交了几十元的手续费,换回了4千多! rn   真像做梦一样……买了一些一直想买的东东。 rn   兴奋之余,又开始了我的宣传,宣传越多,挣的越多吗? rn   果然,不到一个月,又飞来了一张单子! rn   1千多美金…… 真是难以置信! rn   又过了一个月上涨到了2千4百多美金。 rn   如今,不用上班也有钱花了,真是乐哉乐哉! rn   你不信?那没办法!只可惜这白花花的银子喽。 rn   不过,古人云:“宁可信其有,不可信其无”啊! rn   反正也不吃亏,就当疯一回试试看嘛! rn   相信我,没错的! rn   加入方法很简单的哦: rn http://www.MintMail.com/?m=1481801rn   进入上面网站(如若点击不成,复制、粘贴到地址栏) rn   打开网页,点击右上方 click here 活动图标, rn   或点击蓝色 FREE Sign-up page 字样也可! rn   然后,跟着提示,一步一步输入信息就ok了。 rn   值得高兴的是它能识别中文信息,而能100%加入! rn 下面是我为了方便大家的加入详细说明了加入过程中的细节rn 注意:首先在Country* (国家) :中选择china然后才能输入中文rn   First name*: 名字(例:海林) rn   Last Name*: 姓 (例:李 ) rn   Company Name: 可不填 rn   Street Address*: 家庭住址:(一定要详细填写,不然收不到汇款单喽!) rn   例:上海市 **地方 rn   City*: 城市名 (例: 上海市) rn   State*: 可不填 rn   Zip*: 邮编 ( 填 000-000 ) rn   Country*: 国家( 选 china ) rn   Phone*: 电话号码 ( 国家代码 86 + 去掉区位号前0 的电话号码) rn   例:010-1451254 → 86-10-1451254) rn   Fax: 可不填 rn   E-mail*: 电子信箱(所有的交流都通过信箱传递,所以务必填写正确) rn   Confirm E-mail*: 再次输入信箱地址 ***** rn   Year of birth*: 出生年例:1970、1980 rn   Gender*: 性别 Male(男), Femaie (女) rn   Password*: 密码 (6位以上), rn   Confirm Password: 确认密码 (必须与上相同) rn   how do you want to receive commissions that you earn? rn   以什么形式接收礼品? rn   gift certificates(double$$) 奖品 *cash 现金 rn   如要奖品能收到双倍价格的东西, rn   但都是一些英文版的书籍、磁带、光盘 等, rn   对于中国人来说,还是选择现金比较合算些,请选择 cash rn   do you want to be notified when your referrals sing up? rn   加入会员成功时通知你吗?选 yes rn   MintMail.com 请选择自己的爱好或兴趣 (最多可选10种) rn   Submit 点击它 屏幕上就会出现 thank you 的字样 rn   同时你的ID(用户名 数字)和密码也会出现在屏幕上 rn   记住它,加入完毕,一切ok了!恭喜发财 ! rn   然后,5分钟之内你会收到一封欢迎信!. rn   宣传方法: rn   http://www.MintMail.com/?m=1481801rn   先介绍给你的亲朋好友们, rn   然后,到各个网站的留言板中,把上面的内容全部复制、粘贴进去! rn   只要有人点。你就可以挣钱了!好多啊! rn 反正不管怎么样都不会有什么损失的,去试试又何妨吗!:) 论坛

Good Bye My Friend,Good Bye CSDN

09-04

Good Bye My Friend,Good Bye CSDNrn到CSDN也有一些年头了,但是,我不是经常来,断断续续的,经常是来了几个月,然后,几个月不见人影,抱歉,我的生活只能这样,希望大家原谅。rn在CSDN的日子是我很快乐的日子,也认识了很多朋友,更重要的是,学到了很多的知识,懂得了很多。各位也看得我起,让我担任了一个小版主,抱歉得是:我不称职,很少来,来,也是匆匆的。rn然而,今天,我是想和CSDN告别,离开CSDN,我将要告别我的梦想,而CSDN是我梦想起飞的地方,我从这里再倒退吧!rn说说我自己:rn我是一个中专生,而且,是一个和计算机相隔很远的专业,公安管理专业,也许有人说,当公安很好啊,可惜的是:因为身体的原因,以及政策的变化,我永远也不可能走向那个地方了,虽然,做一个网络刑警是我梦想之一rn98年,我拥有了自己的电脑,从此,开始了学习,直到2001年我毕业,时间过去很多,学到的却少,2001年初,我来到了CSDN,当时还很简陋,用的是asp写的系统,但是人很不错,我还记得“真我风采”和“无影石”的口水丈,playyuer的帮助,很平静的学习技术的站点,直到后来,bardo的出现,和dbcontrols的交锋,我开始对论坛失去了关注,去了水源,直到后来,日子就这么过去。rn再2002年,我认识了我的女友,就叫她G好了,一个很好的女孩子,虽然,我当时觉得我们在一起的可能不大,然而,我仍然执着,通过网络,我们相爱了,但是,世界不是听从你摆布的,它才是左右你的人,今年,她找到了一个不错的工作,在浙江,而我,第二次冲刺公务员失败,就失败在成功的门槛上,我想出去,想追逐我的梦想,然而,我被自己的使命压迫着,我是长子、长孙,我要支撑整个家族第三代的希望,而,对于父辈,我有个固定的本地的工作,才是希望的开端,我,不得不继续考试,直到,在进入教育系统,成为一名所谓的人类灵魂的工程师,可惜,我认为,我自己的灵魂就不知道在那里,我仅仅是为了家族而存在。我爱我的家,我爱我的家人,我只有屈服,也许没有屈服,因为,他们没有逼迫。是我主动弯腰的。既然,我在从事这个工作,就不可能去浙江了,而且,就很多的方面而言,和我,她只有苦,感情好,但是,人,不能不吃饭,我去,只有让她生活痛苦,与其她痛苦,不如我放弃,让她找到一个更好的伴侣,过更好的生活,我,原本就是为了家族而存在,也无所谓了,笑着说bye bye吧,我也许,会找一个谁都认为很般配的女人做妻子,过一个别人都认为幸福的生活。rnCSDN是我最初接触的论坛,也是给我帮助最大的论坛,既然,我已经不会再去从事编程相关的职业,那么也就无所谓再来这里了,向CSDN的朋友告别,希望后面来的朋友能够大胆的走出去,为自己而活!!!rnGood Bye, CSDNrnGood Bye, My DreamrnGood Bye, My Loverrnrn以后,CSDN就不会有Shawls,Good Byernrn9/3/2003 6:44:20 PMrnrnrn抱歉,说话很乱rn我还有不少可用分,如果要的,给我留言rn 论坛

Good Rectangle

08-25

We need k square pieces cut from a rectangular piece of paper with length a and width b. Here we assume a is greater than b. Obviously, the biggest side length of a square we can get is b, so the length a of the rectangular piece must be greater than k × b. And after k squares got, the rest part of original rectangle should be a rectangular piece with length b and width c = a - b × k. Here we assume b is not less than c, or we will waste too much. To reuse the rest part, we want the rest rectangle is similar to the original rectangle, but it is impossible (can you prove?).nnTo measure how similar is the rest rectangle to the original rectangle, we define best(b) = min abs( b ÷ ( x - k × b ) - x ÷ b ) | for x ≥ k × b. We call b is a good width if best(b) is less than best(d) for any positive d less than b. And if a rectangle with a good width b and a length a which makes abs(b ÷ (a - k × b) - a ÷ b) minimal, it is a good rectangle. We can get the result easily for each good width, a good rectangle can be got. And we sort the good rectangles by its width from small to large. Now given k, can you calculate area of the nth good rectangle? (all variables above is integer)nnInputnnThere are no more than test cases. Each test case has only one line, containing two integers k and n (0 < k < 1000001, 0 < n < 1000001).nnOutputnnOutput one line for each case, each case need only a number contained one integer S, which indicates the area of the nth good rectangle. S may be very large, so print S MOD 9875321.nnSample Inputnn1 10n2 1nSample Outputnn12816n3 问答

Feel Good

09-14

Bill is developing a new mathematical theory for human emotions. His recent investigations are dedicated to studying how good or bad days influent people's memories about some period of life.nnA new idea Bill has recently developed assigns a non-negative integer value to each day of human life.nnBill calls this value the emotional value of the day. The greater the emotional value is, the better the daywas. Bill suggests that the value of some period of human life is proportional to the sum of the emotional values of the days in the given period, multiplied by the smallest emotional value of the day in it. This schema reflects that good on average period can be greatly spoiled by one very bad day.nnNow Bill is planning to investigate his own life and find the period of his life that had the greatest value. Help him to do so.nnInputnnThere are several test cases in the input file. The first line of each case contains n - the number of days of Bill's life he is planning to investigate(1 ≤ n ≤ 100 000). The rest of the file contains n integer numbers a1, a2, ... an ranging from 0 to 106 - the emotional values of the days. Numbers are separated by spaces and/or line breaks. Proceed to the end of file.nnOutputnnFor each test case, print the greatest value of some period of Bill's life in the first line. And on the second line print two numbers l and r such that the period from l-th to r-th day of Bill's life(inclusive) has the greatest possible value. If there are multiple periods with the greatest possible value,then print any one of them.nnSample Inputnn6n3 1 6 4 5 2nSample Outputnn60n3 5 问答

没有更多推荐了,返回首页