Educational Codeforces Round 84 (Div. 2)

读题读题读题+脑筋急转弯 = =。

A. Sum of Odd Integers

奇奇为奇,奇偶为偶,所以n,k奇偶性要相同。

由求和公式得k个不同奇数组成的最小数为k2,所以n≥k2

#include <bits/stdc++.h>
using namespace std;
void solve(){
int n,k;
cin>>n>>k;
if((n-k)%2==0&&n>=1LL*k*k)
cout<<"YES\n";
else
cout<<"NO\n";
}
int main()
{
int t;cin>>t;
while(t--)
solve();
return 0;
}

B. Princesses and Princes

先模拟,后贪心。

#include <bits/stdc++.h>
using namespace std;
void solve(){
int n;cin>>n;
bool prin[n+1]={0};
bool dau[n+1]={0};
vector<int> v[n+1];
for(int i=1;i<=n;i++){
int k;cin>>k;
for(int j=0;j<k;j++){
int t;cin>>t;
v[i].push_back(t);
}
}
for(int i=1;i<=n;i++){
for(int j:v[i]){
if(!prin[j]){
dau[i]=prin[j]=true;
break;
}
}
}
for(int i=1;i<=n;i++){
if(!dau[i]){
for(int j=1;j<=n;j++){
if(!prin[j]){
cout<<"IMPROVE\n";
cout<<i<<' '<<j<<"\n";
return;
}
}
}
}
cout<<"OPTIMAL\n";
}
int main()
{
int t;cin>>t;
while(t--)
solve();
return 0;
}

C. Game with Chips

先把所有点移至一角,然后遍历整个方块。

#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m;cin>>n>>m;
string ans;
ans+=string(n-1,'D');
ans+=string(m-1,'R');
for(int i=0;i<m;i++){
ans+=string(n-1,"UD"[i&1]);
if(i!=m-1) ans+="L";
}
cout<<ans.size()<<"\n";
cout<<ans<<"\n";
return 0;
}

E. Count The Blocks

中间情况:i长块在n长数中有n-i+1种位置,左右两位各有9种可能,其余n-i-2位各10种可能,i长块本身10种可能。

边界情况:i长块有2种位置,左或右有9种可能,其余n-i-1位各10种可能,i长块本身10种可能。

全长情况:i长块有1种位置,i长块本身10种可能。

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=998244353;
ll qpow(ll a,ll b){
ll ret=1;
while(b>0){
if(b&1) ret=ret*a%mod;
a=a*a%mod;
b>>=1;
}
return ret;
}
int main()
{
int n;cin>>n;
for(int i=1;i<n;i++){
ll sum=0;
sum+=2*9*10*qpow(10,n-i-1)%mod,sum%=mod;//边界情况
sum+=(n-i-1)*9*10*9*qpow(10,n-i-2)%mod,sum%=mod;//中间情况
cout<<sum<<" ";
}
cout<<"10"<<"\n";
return 0;
}

Educational Codeforces Round 84 (Div. 2)的更多相关文章

  1. Educational Codeforces Round 84 (Rated for Div. 2)

    A. Sum of Odd Integers(思维) 思路 这一题看完ans之后觉得是真简单,不过有一些地方还是要理解的. 这一题输出YES,有两个条件 kk%2 == n%2k,这个条件的意思是 k ...

  2. Educational Codeforces Round 58 Div. 2 自闭记

    明明多个几秒就能场上AK了.自闭. A:签到. #include<iostream> #include<cstdio> #include<cmath> #inclu ...

  3. Educational Codeforces Round 47 (Div 2) (A~G)

    目录 Codeforces 1009 A.Game Shopping B.Minimum Ternary String C.Annoying Present D.Relatively Prime Gr ...

  4. Educational Codeforces Round 46 (Div 2) (A~G)

    目录 Codeforces 1000 A.Codehorses T-shirts B.Light It Up C.Covered Points Count(差分) D.Yet Another Prob ...

  5. Educational Codeforces Round 45 (Div 2) (A~G)

    目录 Codeforces 990 A.Commentary Boxes B.Micro-World C.Bracket Sequences Concatenation Problem D.Graph ...

  6. Educational Codeforces Round 85 (Div. 2)

    题目链接:https://codeforces.com/contest/1334 A. Level Statistics 题意 一个关卡有玩家的尝试次数和通关次数,按时间顺序给出一个玩家 $n$ 个时 ...

  7. Educational Codeforces Round 86 (Div. 2)

    比赛链接:https://codeforces.com/contest/1342 A - Road To Zero 题意 有两个非负整数 x, y 以及两种操作: 支付 a 点代价使其中一个数加一或减 ...

  8. Educational Codeforces Round 119 (Div. 2), (C) BA-String硬着头皮做, 能做出来的

    题目链接 Problem - C - Codeforces 题目 Example input 3 2 4 3 a* 4 1 3 a**a 6 3 20 **a*** output abb abba b ...

  9. Educational Codeforces Round 108 (Div. 2), C map套vector存储

    地址  Problem - C - Codeforces 题目 题意 一个学校有n个人参加比赛,他们分别属于ui队,每个人的能力值为si 当每个队需要1~n个人的时候,这个学校能参加的人的能力值和最大 ...

随机推荐

  1. 【C++】《C++ Primer 》第十四章

    第十四章 重载运算与类型转换 一.基本概念 重载运算符是具有特殊名字的函数:由关键字operator和其后要定义的运算符号共同组成.也包含返回类型.参数列表以及函数体. 当一个重载的运算符是成员函数时 ...

  2. 浅谈JVM垃圾回收

    JVM内存区域 要想搞懂啊垃圾回收机制,首先就要知道垃圾回收主要回收的是哪些数据,这些数据主要在哪一块区域. Java8和Java8之前的相同点有很多. 都有虚拟机栈,本地方法栈,程序计数器,这三个是 ...

  3. maven 的安装与配置详细步骤

    1. 直接搜索maven 2. 进入后点击download界面,这时出现的是当前最新版本, 当然还有以前的版本可供下载 3. 下载解压到你指定的目录后,需要配置一下环境变量. a. 右键此电脑点击属性 ...

  4. 基于 MapReduce 的单词计数(Word Count)的实现

    完整代码: // 导入必要的包 import java.io.IOException; import java.util.StringTokenizer; import org.apache.hado ...

  5. python学习笔记 | PyCharm创建文件时自动添加头文件

    File Settings Editor File and Code Templates Python Script 然后在右边的框中写入信息就可以啦: # -*- coding: utf-8 -*- ...

  6. 【EXPDP】Oracle expdp中并行问题

    $ expdp hr/hr tables=test1 dumpfile=test2.dmp directory=pump parallel=4 Export: Release 11.2.0.4.0 - ...

  7. Github Python计算器开源项目 二次开发--增加函数图形

    先上原项目链接:https://github.com/xhf79/Calculator_pyqt python+Qt 开发的计算器 原项目界面和功能如图所示: 科学计算的内容基本都有,但按照项目的提示 ...

  8. Goby资产扫描工具安装及报错处理

    官网: https://cn.gobies.org/index.html 产品介绍: 帮企业梳理资产暴露攻击面,新一代网络安全技术,通过为目标建立完整的资产数据库,实现快速的安全应急. 已有功能: 扫 ...

  9. 配置 containerd 镜像仓库完全攻略

    作者简介 王海龙,Rancher中国社区技术经理,负责Rancher中国技术社区的维护和运营.拥有6年的云计算领域经验,经历了OpenStack到Kubernetes的技术变革,无论底层操作系统Lin ...

  10. C++ unordered_map/unordered_set 自定义键类型

    1. unordered_map 和 unordered_set template < class Key, // unordered_map::key_type class T, // uno ...