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. PHP 打水印功能

    /** * @param $str 需要打水印的文字 * @param int $size 文字大小 * @param int $red 文字的颜色 rgb r * @param int $gree ...

  2. 微信扫码支付Native方式二以及支付回调

    官方API文档https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_5 1.使用jar包 1 <!--微信支付 --> 2 ...

  3. 【Linux】rsync的相关用途

    Rsync,代表"remote sync",它是本地和远程主机文件同步工具.它只同步更改的文件,以此实现最小化传输数据. 我使用Ubuntu 16.04做为例子,但是你可以把它应用 ...

  4. Sqli - Labs 靶场笔记(一)

    Less - 1: 页面: URL: http://127.0.0.1/sqli-labs-master/Less-1/ 测试: 1.回显正常,说明不是数字型注入, http://127.0.0.1/ ...

  5. rename命令和批量重命名

    本文为转载文章,转发自 https://blog.csdn.net/GGxiaobai/article/details/53507454 早期版本的rename是C语言版本,如今新的Ubuntu中采用 ...

  6. centos7下 开启/关闭/查看firewall运行状态命令

    1.开启防火墙:systemctl start firewalld.service [root@localhost bin]# systemctl start firewalld.service [r ...

  7. 2.4V升5V芯片,8uA功耗,低功耗升压电路图

    2.4V升5V,可用于USB拔插充电,也可以用于把两节镍氢电池2.4V升压到5V,的固定输出稳压电压值,同时输出电流可达1A,0.5A等 首先是先说下0.5A的这款的话,是比较低功耗的,8uA左右的输 ...

  8. ././include/linux/kconfig.h:4:32: fatal error: generated/autoconf.h: No such file or directory 解决办法

    我在编写内核驱动模块的时候报了一个非常奇怪的错误,如下图: 在目录下看了一下确实没有发现这个文件,感觉很奇怪,因为我记得之前编译模块是没有错误的,所以不可能是我代码写的有问题. 查阅了资料很多说要清除 ...

  9. k8s之PV、PVC、StorageClass详解

    导读 上一篇写了共享存储的概述以及一个简单的案例演示.这一篇就写一下PV和PVC. PV是对底层网络共享存储的抽象,将共享存储定义为一种"资源",比如Node也是容器应用可以消费的 ...

  10. Vue之优化封装请求方法

    Vue之优化封装请求方法 对于代码中的请求操作 1.接口请求可能需要重用 2.实际工作中,接口非常容易变动, 改起来很麻烦! 我们建议的做法是把所有的请求都封装成函数然后统一的>###组织到模块 ...