Educational Codeforces Round 84 (Rated for Div. 2)

原题链接

目录

  • 题外话
  • A
    • A题意
    • A思路
    • A代码
  • B
    • 题意
    • 思路
    • 代码
  • C
    • 题意
    • 思路
    • 代码
  • E
    • 题意
    • 思路
    • 代码

题外话

被教育了,读题不认真,明明能四题的(靠),竟然打不过jy,很烦

A

A题意

给你n,m(m是奇数的数量)问你是否可以使用m个奇数(不相同的)构成n

A思路

自己上来以为是判断奇偶就死了

其实还有点其他的东西,比如k个互不相同的奇数最小就是k*k(记录一下)

A代码

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define iinf 0x3f3f3f3f
#define linf (1ll<<60)
#define eps 1e-8
#define maxn 1000010
#define maxe 1000010
#define cl(x) memset(x,0,sizeof(x))
#define rep(i,a,b) for(i=a;i<=b;i++)
#define drep(i,a,b) for(i=a;i>=b;i--)
#define em(x) emplace(x)
#define emb(x) emplace_back(x)
#define emf(x) emplace_front(x)
#define fi first
#define se second
#define de(x) cerr<<#x<<" = "<<x<<endl
#define __i __int128
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 

ll read(ll x=0)
{
    ll c, f(1);
    for(c=getchar();!isdigit(c);c=getchar())if(c==‘-‘)f=-f;
    for(;isdigit(c);c=getchar())x=x*10+c-0x30;
    return f*x;
}
ll n , k ;
int ar[1000010];
int  br[100010];
ll res =0 ;

int main()
{
  	int n;cin >>n;
  	while (n--){
  		int a, b;cin>>a>>b;
  		int num =0 ;
  		if(a%2 == b%2 && b <= sqrt(a)){
  			cout<<"Yes"<<endl;
			  continue ;
		  }

		else  cout<<"NO"<<endl;
	  }
    return 0;
}

B

题意

题面挺长的,其实就是一个简单的模拟,问题就是让你给国王的女儿分配王子,不能分配的就optimal,不然就imporve(自己一开始以为是二分图。。有点尴尬)

思路

判断每个公主,是否有一个王子对应, 没有的话,就可以improve , 不然就是optimal

注意,只能添加一次

代码

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define iinf 0x3f3f3f3f
#define linf (1ll<<60)
#define eps 1e-8
#define maxn 1000010
#define maxe 1000010
#define cl(x) memset(x,0,sizeof(x))
#define rep(i,a,b) for(i=a;i<=b;i++)
#define drep(i,a,b) for(i=a;i>=b;i--)
#define em(x) emplace(x)
#define emb(x) emplace_back(x)
#define emf(x) emplace_front(x)
#define fi first
#define se second
#define de(x) cerr<<#x<<" = "<<x<<endl
#define __i __int128
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 

ll read(ll x=0)
{
    ll c, f(1);
    for(c=getchar();!isdigit(c);c=getchar())if(c==‘-‘)f=-f;
    for(;isdigit(c);c=getchar())x=x*10+c-0x30;
    return f*x;
}
ll n , k ;
int ar[1000010];
int  br[100010];
ll res =0 ;

int main()
{
	    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
  	int t;cin >>t;
  	while(t--){
  		int n;cin >>n;
  		map<int ,int >mp;
//  		memset(ar, 0 ,sizeof ar);
  		int flag=0 ;int pos =0;
  		for(int i=0 ;i<n;i++){
  			int f =0 ;
  			cin >>ar[i];
  			for(int j=0;j<ar[i];j++){
  				int b; cin >>b;
  				if(mp[b]==0 &&f==0 ){
  					mp[b] ++ ;
  					f =1 ;
				  }
			  }
			if(!f){
				flag =1 ;
				pos =i+1 ;
			}
		  }
		if(!flag ){
			cout<<"OPTIMAL"<<endl;
			continue ;
		}
		cout<<"IMPROVE"<<endl;
		for(int i=1;i<=n;i++)if(!mp[i]){
			cout<<pos <<" "<< i <<endl;
			break;
		}
	  }
    return 0;
}

C

题意

就是问你是否有一种方案,可以让所有的芯片至少通过一次给定的位置

思路

**注意, 最长不能够超过2mn,然后,每个位置可以放置多个芯片,* 这意味着,你可以先把所有芯片放到(1,1),然后蛇形排列,就好了

代码

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define iinf 0x3f3f3f3f
#define linf (1ll<<60)
#define eps 1e-8
#define maxn 1000010
#define maxe 1000010
#define cl(x) memset(x,0,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define drep(i,a,b) for(i=a;i>=b;i--)
#define em(x) emplace(x)
#define emb(x) emplace_back(x)
#define emf(x) emplace_front(x)
#define fi first
#define se second
#define de(x) cerr<<#x<<" = "<<x<<endl
#define __i __int128
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 

ll read(ll x=0)
{
    ll c, f(1);
    for(c=getchar();!isdigit(c);c=getchar())if(c==‘-‘)f=-f;
    for(;isdigit(c);c=getchar())x=x*10+c-0x30;
    return f*x;
}
ll n , k, m ;
string v;
int main()
{
	    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
//    int i ;
  	n =read(), m = read() ;
  	rep(i,0,m-1)v.pb(‘L‘) ;
  	rep(i,0,n-1)v.pb(‘U‘);
  	rep(i,0,n){
  		if(i%2==0)rep(j,0,m-1)v.pb(‘R‘);
  		else rep(j,0,m-1)v.pb(‘L‘);
  		v.pb(‘D‘);
	  }
	cout<<SZ(v)<<endl;
	printf("%s\n", v.c_str());
    return 0;
}

E

题意

让你在【1,\(10^n\)-1】里面找出所有n个连续相同的数字块的数量(要从n到1的块都输出)

思路

其实就是一个规律题,推一推公式,如果不会的,就上oeis上面蒙蒙数据,看看能否成立啥的那就先打表,发现其实就是\(ar[i]= ar[i-1]*10+81*10^{i-1}\)

主要要取余一下,其他的就没什么了

代码

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define iinf 0x3f3f3f3f
#define linf (1ll<<60)
#define eps 1e-8
#define maxn 1000010
#define maxe 1000010
#define cl(x) memset(x,0,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define drep(i,a,b) for(i=a;i>=b;i--)
#define em(x) emplace(x)
#define emb(x) emplace_back(x)
#define emf(x) emplace_front(x)
#define fi first
#define se second
#define de(x) cerr<<#x<<" = "<<x<<endl
#define __i __int128
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 

ll read(ll x=0)
{
    ll c, f(1);
    for(c=getchar();!isdigit(c);c=getchar())if(c==‘-‘)f=-f;
    for(;isdigit(c);c=getchar())x=x*10+c-0x30;
    return f*x;
}
ll n , k, m ;
ll ar[500010];
int main()
{
	    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
//    int i ;
  	n =read();
  	ar[1]=10;
  	ar[2]=180;
  	ll cnt =810 ;
  	for(int i=3;i<=n;i++){
  		ar[i] = ar[i-1]*10%998244353+cnt;
  		ar[i]%=998244353;
  		cnt *=10;
  		cnt%=998244353;
	  }
	for(int i=n;i>=1;i--)cout<<ar[i]<<" "; cout<<endl;
    return 0;
}

原文地址:https://www.cnblogs.com/gaohaoy/p/12563438.html

时间: 2024-10-07 17:09:53

Educational Codeforces Round 84 (Rated for Div. 2)的相关文章

C - Game with Chips.Educational Codeforces Round 84 (Rated for Div. 2)

http://codeforces.com/contest/1327/problem/C 题意 给你一个图和一堆点,然后问你这一堆点和一堆目标点怎么才能到达这些目标点至少一次. 做法 其实题目已经给你提示了,上面说移动次数不大于2nm. 其实在2nm内就能把图上所有位置遍历一遍. 简单来说就是不管你脑洞开的有多大,没有用.该暴力还是得暴力. 先把最右上角的点移动到左下角,再按照s型移动到原始位置 就能保证所有点都经历过这个图上别的所有点了. 代码 #include <iostream> usi

Educational Codeforces Round 84 (Rated for Div. 2) C. Game with Chips(思维题)

Petya has a rectangular Board of size n×mn×m . Initially, kk chips are placed on the board, ii -th chip is located in the cell at the intersection of sxisxi -th row and syisyi -th column. In one action, Petya can move all the chips to the left, right

Educational Codeforces Round 84 (Rated for Div. 2), problem: (A) Sum of Odd Integers

A. 被卡了好久,样例的第一感觉n%k==0则YES 后来写式子,交了发n>=k*k 虽然写的时候也注意到了n-k必须是偶数(k个奇数和的奇偶性与k相同,故n与k奇偶性相同) 最后才想到,可以构造 前k-1个数为1~k-1 剩下的即为第k个数 #include<bits/stdc++.h> #define ll long long using namespace std; //const int N=1e4+5; int main(){ int T; ios::sync_with_std

Educational Codeforces Round 84 (Rated for Div. 2) A-E题解

A. Sum of Odd Integers 首先可以算出从1开始到第k个奇数之和.如果和大于n,则不可能存在k个奇数加和等于n,否则用n减去前k个奇数的和,这个差值若是偶数,直接加到最大的奇数上,就可以满足题意要求,否则输出no. 1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 int main(){ 5 int t; 6 cin>>t; 7 while(t--){ 8 ll n

Educational Codeforces Round 84 (Rated for Div. 2)E(组合数学)

1 #define HAVE_STRUCT_TIMESPEC 2 #include<bits/stdc++.h> 3 using namespace std; 4 const int mod = 998244353; 5 long long p[200007]; 6 int main(){ 7 ios::sync_with_stdio(false); 8 cin.tie(NULL); 9 cout.tie(NULL); 10 int n; 11 cin>>n; 12 p[0]=1;

Educational Codeforces Round 69 (Rated for Div. 2) B - Pillars

Educational Codeforces Round 69 (Rated for Div. 2) B - Pillars There are n pillars aligned in a row and numbered from 1 to n. Initially each pillar contains exactly one disk. The i-th pillar contains a disk having radius ai. You can move these disks

Educational Codeforces Round 71 (Rated for Div. 2) D - Number Of Permutations

原文链接:https://www.cnblogs.com/xwl3109377858/p/11405773.html Educational Codeforces Round 71 (Rated for Div. 2) D - Number Of Permutations You are given a sequence of n pairs of integers: (a1,b1),(a2,b2),…,(an,bn). This sequence is called bad if it is

Educational Codeforces Round 36 (Rated for Div. 2)

Educational Codeforces Round 36 (Rated for Div. 2) F. Imbalance Value of a Tree You are given a tree T consisting of n vertices. A number is written on each vertex; the number written on vertex i is ai. Let's denote the function I(x,?y) as the differ

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

Educational Codeforces Round 36 (Rated for Div. 2) 题目的质量很不错(不看题解做不出来,笑 Codeforces 920C 题意 给定一个\(1\)到\(n\)组成的数组,只可以交换某些相邻的位置,问是否可以将数组调整为升序的 解题思路 首先如果每个数都能通过交换到它应该到的位置,那么就可以调整为升序的. 但实际上交换是对称的,如果应该在的位置在当前位置前方的数都交换完成,那么整体就是排好序的,因为不可能所有不在相应位置的数都在相应位置的后方.