首页 > 其他分享 >AtCoder Beginner Contest 296

AtCoder Beginner Contest 296

时间:2023-04-02 16:22:24浏览次数:46  
标签:AtCoder cout Beginner Contest int cin 296 abc296

AtCoder Beginner Contest 296

赛时代码

A - Alternately

// Problem: A - Alternately
// Contest: AtCoder - AtCoder Beginner Contest 296
// URL: https://atcoder.jp/contests/abc296/tasks/abc296_a
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n;
	cin >> n;
	string s;
	cin >> s;
	if(n==1)
	{
		cout << "Yes\n";
		return 0;
	}
	int flag = 0;
	for(int i = 1; i < n; i++)
	{
		if(s[i] == s[i - 1]) flag = 1;
	}
	
	if(flag) cout << "No\n";
	else cout << "Yes\n";
	
	
	return 0;
}

B - Chessboard

// Problem: B - Chessboard
// Contest: AtCoder - AtCoder Beginner Contest 296
// URL: https://atcoder.jp/contests/abc296/tasks/abc296_b
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	string s;
	int cnt = 8;
	for(int i = 0; i < 8; i++)
	{
		cin >> s;
		for(int i = 0; i < 8; i++)
		{
			if(s[i] == '*')
			{
				char k =i  + 'a';
				cout << k << cnt << "\n"; 
				return 0;
			}
		}
		cnt--;
	}
	return 0;
}

C - Gap Existence

// Problem: C - Gap Existence
// Contest: AtCoder - AtCoder Beginner Contest 296
// URL: https://atcoder.jp/contests/abc296/tasks/abc296_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;
map<int, bool> st;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, x;
	cin >> n >> x;
	// set<int> a;
	// if(!x)
	// {
		// cout << "Yes\n";
		// return 0;
	// }
	// for(int i = 0; i < n; i++) 
	// {
		// int b;
		// cin >> b;
		// a.insert(b);
	// }
	// for(auto x1 : a)
	// {
		// for(auto x2 : a)
		// {
			// if(x1 != x2)
			// {
				// if(x1 - x2 == x)
				// {
					// cout << "Yes\n";
					// return 0;
				// }
			// }
		// }
	// }
// 	
	// cout << "No\n";
	
	
	vector<int> a(n + 1);
	for(int i = 0; i < n; i++) 
	{
		cin >> a[i];
		st[a[i]] = 1;
	}
	if(x == 0) 
	{
		cout << "Yes\n";
		return 0;
	}
	
	for(int i = 0; i < n; i++)
	{
		if(st[a[i] - x] || st[x + a[i]]) 
		{
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	// sort(a.begin(), a.begin() + n);
	// int i = 0, j = n - 1;
	// for(i; i < n; i++)
	// {
		// while(a[j] - a[i] > x )
		// {
			// i++;
		// }
		// if(a[j] - a[i] == x) 
		// {
			// cout << "Yes\n";
			// return 0;
		// }
	// }
// 	
	// i = n - 1, j = 0;
	// for(i; ~i; i--)
	// {
		// while(a[j] - a[i] < x && j < n)
		// {
			// j++;
		// }
		// if(a[j] - a[i] == x) 
		// {
			// cout << "Yes\n";
			// return 0;
		// }
	// }
	// cout << "No\n";
	return 0;
}

补题代码

D - M<=ab

补充向上取整知识点

// Problem: D - M<=ab
// Contest: AtCoder - AtCoder Beginner Contest 296
// URL: https://atcoder.jp/contests/abc296/tasks/abc296_d
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

// #include<bits/stdc++.h>
// #define int long long
// using namespace std;
// const int N = 2e5 + 10, M = 1e6;
// int n, m;
// int primes[N];
// map<int, int> st;
// 
// void get_primes()
// {
	// for(int i = 2; i <= M; i++)
	// {
		// if(!st[i]) primes[++primes[0]] = i;
		// for(int j = 1; primes[j] <= M / i; j++)
		// {
			// st[primes[j] * i] = 1;
			// if(i % primes[j] == 0) break;
		// }
	// }
// }
// bool check(int x)
// {
	// if(!st[x] && x < 1e6) return false;
	// for(int i = n; i; i--)
	// {
		// if(x % i == 0 && x / i <= n)
		// {
			// return true;
		// }
	// }
	// return false;
// }
// 
// signed main()
// {
	// ios::sync_with_stdio(false);
	// cin.tie(nullptr);
	// get_primes();
	// cin >> n >> m;
	// if(n * n < m)
	// {
		// cout << "-1\n";
		// return 0;
	// }
	// for(int i = m; i <= 1e12; i++)
	// {
		// if(i > n * n) 
		// {
			// cout << "-1";
			// return 0;
		// }
		// if(check(i))
		// {
			// cout << i << "\n";
			// return 0;
		// }
	// }
	// cout << "-1\n";
	// return 0;
// }

#include<bits/stdc++.h>
#define INF 1e18
using namespace std;
typedef long long ll;
ll n, m;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	cin >> n >> m;
	
	ll res = INF;
	for(ll i = 1; i <= n; i++)
	{
		ll x = (m + i - 1) / i;
		if(x <= n) res = min(res, i * x);
		if(i > x) break;
	}
	
	if(res == INF) cout << "-1\n";
	else cout << res << "\n";
	
	return 0;
}

E - Transition Game(待补)

F - Simultaneous Swap (待补)

G - Polygon and Points (待补)

Ex不考虑

标签:AtCoder,cout,Beginner,Contest,int,cin,296,abc296
From: https://www.cnblogs.com/hblgzsx/p/17280690.html

相关文章

  • AtCoder Beginner Contest 153
    AtCoderBeginnerContest153https://atcoder.jp/contests/abc153这套比较简单。E-CrestedIbisvsMonster完全背包#include<bits/stdc++.h>#definelllonglongusingnamespacestd;constintN=1e3+5,M=1e4+5;lln,m,a[N],b[N],f[M*2],mx;int......
  • AtCoder Beginner Contest 296
    DM<=ab枚举。复杂度\(O(\sqrt{m})\)。C++Code#include"bits/stdc++.h"usingnamespacestd;usingi64=longlong;intmain(){ios::sync_with_stdio(false);cin.tie(nullptr);i64n,m;cin>>n>>m;if(m&......
  • AtCoder Beginner Contest 296 ABCD
    https://atcoder.jp/contests/abc296A-Alternately#include<bits/stdc++.h>usingnamespacestd;typedeflonglongLL;typedefpair<LL,LL>PII;constLLMAXN=1e18,MINN=-MAXN,INF=0x3f3f3f3f;constLLN=2e6+10,M=3023;constLLmod=100000007;cons......
  • AtCoder Beginner Contest 152
    AtCoderBeginnerContest152https://atcoder.jp/contests/abc152F我看了半天,编码方式那里还算是感觉比较玄乎,这题确实妙。D-Handstand2只需记录两端数字即可,不要想太复杂。#include<bits/stdc++.h>#definelllonglongusingnamespacestd;lln,sum,a[10][10];......
  • AtCoder Beginner Contest 295
    题解报告基本的一些理解和问题都在注释中A:ProbablyEnglish//水题#include<cstdio>#include<iostream>#include<algorithm>#include<cstring>#include<string>#include<unordered_map>usingnamespacestd;constintmaxn=1e3+10;strings[......
  • AtCoder Beginner Contest 246
    AtCoderBeginnerContest246A(思维)A这个题大意是告诉你一个矩形的三个点,求第四个点,并且已知每条边都是平行于\(x\)轴或者是\(y\)轴的,那么我们可以确定,\(x\)坐标只有两......
  • AtCoder Beginner Contest 295
    A-ProbablyEnglish#include<bits/stdc++.h>usingnamespacestd;intread(){intx=0,f=1,ch=getchar();while((ch<'0'||ch>'9')&&ch......
  • Coinc1dens's lessons for cryptography beginner
    Coinc1dens'slessonsforcryptographybeginner10分题懒得写,赛后浅写一下(有些还真写不出来)太屑了古典懒得写,相信都写的出来1.childexgcdi即为m在模p情况下的乘法逆......
  • AtCoder Beginner Contest 145
    AtCoderBeginnerContest145https://atcoder.jp/contests/abc145D-Knight乍一看以为是dp,但是数据范围不允许。仔细一看发现,两种操作的次数是固定的,可以枚举出来每......
  • AtCoder Beginner Contest 148
    AtCoderBeginnerContest148https://atcoder.jp/contests/abc148这场比较简单D-BrickBreak二分orLIS#include<bits/stdc++.h>#definelllonglongusingn......