Educational Codeforces Round 80 (Rated for Div. 2)题解

A. Deadline
x + ⌈ d x + 1 ⌉ x + \lceil \frac{d}{x + 1} \rceil x+x+1d 我们就可以想到基本不等式,即取x/2时不等式取到最大值,于是就可以得出答案。

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	int T;scanf("%d",&T);
	while(T--){
		ll d,n;scanf("%lld %lld",&n,&d);
		if(n & 1) n = (n / 2 + 1) * (n / 2 + 1);
		else n = (n / 2) * (n / 2 + 1);
		if(n >= d) puts("YES");
		else puts("NO");
	}
}

B. Yet Another Meme Problem
遇事不决先打表,很容易发现只有m为9,99,999,9999,并且n<=m时成立,于是就。。。。

#include<bits/stdc++.h>
using namespace std;
int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		ll n,m;scanf("%lld %lld",&n,&m);
		ll ans = 0,res = 1;
		for(int i = 1;;i++){
			res *= 10;
			if(res - 1 <= m) ans++;
			else break;
		}
		printf("%lld\n",ans * n);
	}
}

C. Two Arrays
给你n个数,m个位置,排成两个序列,一个不递减,一个不递增,问你一共有几中组合方式。
那我用dp[i][j] 表示i位长的串以j结尾的个数,起点为dp[0][n - 1],那前一位对后一位的贡献就是dp[i + 1][k] += dp[i][j] * (j - k + 1),结束得值为dp[m][0~n];

#include<bits/stdc++.h>
typedef unsigned long long int ull;
typedef long long int ll;
const int    maxn = 1e6 + 5;
const int    maxm = 1e5 + 10;
const int    mod  = 1e9 + 7;
const ll     INF  = 1e18 + 100;
const int    inf  = 0x3f3f3f3f;
const double pi   = acos(-1.0);
const double eps  = 1e-6;
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}return x*f;}
inline ll  readll(){ll x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}return x*f;}
ll eular(ll n){ll ans = n;for(int i = 2; i*i <= n; i++){if(n % i == 0){ans -= ans/i;while(n % i == 0) n /= i;}}if(n > 1)ans -= ans/n; return ans;}
ll qpow(ll a, ll n){ll ans = 1;while(n){if(n&1){ans = (ans * a) % mod;}a = (a * a) % mod;n >>= 1;}return ans;}
ll gcd(ll a,ll b){return b>0?gcd(b,a%b):a;}
using namespace std;
ll dp[11][1010];
int main(){
	int n,m;scanf("%d %d",&n,&m);
	dp[0][n - 1] = 1;
	for(int i = 0;i < m;i++){
		for(int j = 0;j <= n;j++){
			ll res = 1;
			for(int k = j;k >= 0;k--){
				dp[i + 1][k] += dp[i][j] * res % mod;
				dp[i + 1][k] %= mod;
				res++;
			}
		}
	}
	ll ans = 0;
	for(int i = 0;i <= n;i++) ans += dp[m][i],ans %= mod;
	printf("%lld\n",ans);
}

D. Minimax Problem
给你n行,每行m个数,让你选出任意两行,使得两行组合后得最小值最大。组合得定义给同一列取较大得那个数。
因为m只有8,考虑二分答案,check中,将每行所有得情况全部暴力计算出来,然后对于这些情况 ( ( 1 < < m ) − 1 ) 2 ((1 <<m ) - 1)^2 ((1<<m)1)2得复杂度暴力计算出来就好了,判断条件为 ( ( i ∣ j ) = = ( ( 1 < < m ) − 1 ) ) ((i | j) == ((1 << m )- 1)) ((ij)==((1<<m)1))

#include<bits/stdc++.h>
#define accept return 0
#define  mes(a, b)  memset(a, b, sizeof a)
typedef unsigned long long int ull;
typedef long long int ll;
const int    maxn = 3e5 + 5;
const int    maxm = 1e5 + 10;
const int    mod  = 1e9 + 7;
const ll     INF  = 1e18 + 100;
const int    inf  = 0x3f3f3f3f;
const double pi   = acos(-1.0);
const double eps  = 1e-6;
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}return x*f;}
inline ll  readll(){ll x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}return x*f;}
ll eular(ll n){ll ans = n;for(int i = 2; i*i <= n; i++){if(n % i == 0){ans -= ans/i;while(n % i == 0) n /= i;}}if(n > 1)ans -= ans/n; return ans;}
ll qpow(ll a, ll n){ll ans = 1;while(n){if(n&1){ans = (ans * a) % mod;}a = (a * a) % mod;n >>= 1;}return ans;}
ll gcd(ll a,ll b){return b>0?gcd(b,a%b):a;}
using namespace std;
int ans1,ans2;
int used[500];
int tot;
int n,m;
int mp[maxn][20];
bool check(int pos){
	for(int i = 0;i <= tot;i++) used[i] = 0;
	for(int i = 1;i <= n;i++){
		int tmp = 0;
		for(int j = 1;j <= m;j++){
			if(mp[i][j] >= pos) tmp = tmp << 1 | 1;
			else tmp = tmp << 1;
		}
		used[tmp] = i;
	} 
	for(int i = 0;i <= tot;i++) for(int j = 0;j <= tot;j++){
		if((i | j) == (tot) && used[i] && used[j]){
			ans1 = used[i];ans2 = used[j];
			return true;
		}
	}
	return false;
}
int main(){
	scanf("%d %d",&n,&m);
	tot = (1 << m) - 1;	 
	for(int i = 1;i <= n;i++) for(int j = 1;j <= m;j++){
		scanf("%d",&mp[i][j]);
	}
	int l = 0,r = 1e9,ans = 0;
	while(l <= r){
		int mid = l + r >> 1;
		if(check(mid)) ans = mid,l = mid + 1;
		else r = mid - 1;
	}
	printf("%d %d\n",ans1,ans2);
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
"educational codeforces round 103 (rated for div. 2)"是一个Codeforces平台上的教育性比赛,专为2级选手设计评级。以下是有关该比赛的回答。 "educational codeforces round 103 (rated for div. 2)"是一场Codeforces平台上的教育性比赛。Codeforces是一个为程序员提供竞赛和评级的在线平台。这场比赛是专为2级选手设计的,这意味着它适合那些在算法和数据结构方面已经积累了一定经验的选手参与。 与其他Codeforces比赛一样,这场比赛将由多个问题组成,选手需要根据给定的问题描述和测试用例,编写程序来解决这些问题。比赛的时限通常有两到三个小时,选手需要在规定的时间内提交他们的解答。他们的程序将在Codeforces的在线评测系统上运行,并根据程序的正确性和效率进行评分。 该比赛被称为"educational",意味着比赛的目的是教育性的,而不是针对专业的竞争性。这种教育性比赛为选手提供了一个学习和提高他们编程技能的机会。即使选手没有在比赛中获得很高的排名,他们也可以从其他选手的解决方案中学习,并通过参与讨论获得更多的知识。 参加"educational codeforces round 103 (rated for div. 2)"对于2级选手来说是很有意义的。他们可以通过解决难度适中的问题来测试和巩固他们的算法和编程技巧。另外,这种比赛对于提高解决问题能力,锻炼思维和提高团队合作能力也是非常有帮助的。 总的来说,"educational codeforces round 103 (rated for div. 2)"是一场为2级选手设计的教育性比赛,旨在提高他们的编程技能和算法能力。参与这样的比赛可以为选手提供学习和进步的机会,同时也促进了编程社区的交流与合作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值