ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Daliy Algorithm (数学,小知识)-- day 67

2020-04-28 12:53:30  阅读:312  来源: 互联网

标签:const Algorithm int ll cin edge 67 Daliy include


Nothing to fear

those times when you get up early and you work hard; those times when you stay up late and you work hard; those times when don’t feel like working — you’re too tired, you don’t want to push yourself — but you do it anyway. That is actually the dream. That’s the dream. It’s not the destination, it’s the journey. And if you guys can understand that, what you’ll see happen is that you won’t accomplish your dreams, your dreams won’t come true, something greater will. mamba out


那些你早出晚归付出的刻苦努力,你不想训练,当你觉的太累了但还是要咬牙坚持的时候,那就是在追逐梦想,不要在意终点有什么,要享受路途的过程,或许你不能成就梦想,但一定会有更伟大的事情随之而来。 mamba out~

2020.4.27


拉姆塞定理

拉姆塞定理
拉姆塞理论可以用通常的语言来表述。
在一个集会上,两个人或者彼此认识,或者彼此不认识,
拉姆塞得出结果是说,当集会人数大于或等于6时,
则必定有3个人,他们或者彼此认识或者彼此都不认识。

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <cassert>
#include <string>
#include <cmath>
#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lowbit(x) (x & -x)
using namespace std;
typedef long long ll;
const int N = 1005;
const int MAX = 0x7ffffff;
int t;
int edge[N][N];
void slove()
{
	int n , m;
	cin >>n >> m;
	int a , b;
	// 根据拉塞姆定理 当 n >= 6时一定有一方三条边可以构成三角形
	if(n >= 6)
	{
		for(int i = 0; i< m ;i ++)cin >> a >> b;
		printf("yes\n");
		return;
	}
	memset(edge , 0 , sizeof edge);

	for(int i = 1;i <= m ;i ++)
	{
		cin >> a >> b;
		edge[a][b] = edge[b][a] = 1;
	}

	int flag = 0;

	for(int i = 1;i <= n ;i ++)
	{
		for(int j = i + 1;j <= n && !flag ;j ++)
		{
			for (int k = j + 1; k <= n && !flag; k++)
                    if (edge[i][j] == edge[j][k] && edge[j][k] == edge[k][i])
                        flag = 1;
		}
	}
	if (flag) printf("yes\n");
    else printf("no\n");
}
int main()
{
	SIS;
	cin >> t;
	while(t--)
	{
		slove();
	}
}

牛妹的游戏

这个题需要先打表观察出来符合的组合数的规律在进行计算
数学观察题 这种题要多做才能有感觉啊!

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <cassert>
#include <string>
#include <cmath>
#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lowbit(x) (x & -x)
using namespace std;
typedef long long ll;
const int MAX = 0x7ffffff;
const int mod = 998244353;
int t;
const int N = 5005;
ll a[N][N];

// 初始化组合数
void initComb()
{
	for(int i = 0;i <= N ;i ++)
	{
		a[i][0] = 1;
	}
	for(int i = 1;i < N ;i ++)
	{
		for(int j = 1;j < N ;j ++)
		{
			a[i][j] = (a[i-1][j] + a[i-1][j-1]) % mod;
		}
	}
}
void slove()
{
	int x , y , time;
	cin >> x >> y >> time;
	if(time < x || time - x < y)
	{
		cout << 0 << endl;
	}else cout << a[time][x] % mod * a[time-x][y] % mod << endl;
	return ;
}
int main()
{
	SIS;
	initComb();
	cin >> t;
	while(t--)
	{
		slove();
	}
}

标签:const,Algorithm,int,ll,cin,edge,67,Daliy,include
来源: https://www.cnblogs.com/wlw-x/p/12793403.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有