Educational Codeforces Round 81 (Rated for Div. 2)
A
0~9需要多少笔画,自取7和1,判奇偶
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define it register int
#define lowbit(x) (x)&(-x)
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
const int maxn=1e5+;
int n,m;
int t;
int main(){
scanf("%d",&t);
while(t--){
scanf("%d",&n);
if(n&){
n-=;
printf("");
int ci=n/;
for(it i=;i<ci;i++){
printf("");
}
printf("\n");
}
else{
int ci=n/;
for(it i=;i<ci;i++){
printf("");
}
printf("\n");
}
}
return ;
}
B
被hack了,早上仔细一想,发现判m==0的时候少考虑了几个条件,直接a[i]==m就过了,所以就必被hack了
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define it register int
#define lowbit(x) (x)&(-x)
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
const int maxn=1e5+;
int n,m;
int t,a[maxn];
char s[maxn];
int main(){
scanf("%d",&t);
while(t--){
scanf("%d%d",&n,&m);
scanf("%s",s);
int l=strlen(s);
a[]=;
int ji=;
for(it i=;i<l;i++){
if(s[i]==''){
a[i+]=a[i]+;
}
else{
a[i+]=a[i]-;
}
if(a[i+]&){
ji++;
}
}
if(a[l]< && m>){
int sum=;
for(it i=;i<=l;i++){
if((m-a[i])%a[l]== && m<=a[i]){
sum++;
}
}
printf("%d\n",sum);
}
else if(a[l]> && m<){
int sum=;
for(it i=;i<=l;i++){
if((m-a[i])%a[l]== && m>=a[i]){
sum++;
}
}
printf("%d\n",sum);
}
else if(a[l]==){
int sum=;
for(it i=;i<=l;i++){
if(a[i]==m){
sum++;
}
}
if(!sum){
printf("%d\n",sum);
}
else{
printf("-1\n");
}
}
else if(m==){
int sum=;
for(it i=;i<=l;i++){
if(a[i]== || (a[l]< && <a[i] || a[l]> && >a[i])&& a[i]%a[l]==){
sum++;
}
}
printf("%d\n",sum);
} else{
int sum=;
for(it i=;i<=l;i++){
if((m-a[i])%a[l]== && m> &&m>=a[i]){
sum++;
}
if((m-a[i])%a[l]== && m< &&m<=a[i]){
sum++;
}
}
printf("%d\n",sum);
}
}
return ;
}
昨天比的时候B题感觉不太好,但过了就没细想,果然出现问题了
C
就是找字母位置,是否比他大,或者有无
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define it register int
#define lowbit(x) (x)&(-x)
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
const int maxn=1e5+;
int n,m;
int t;
char s[maxn],ss[maxn];
int a[][maxn];
int main(){
scanf("%d",&t);
while(t--){
scanf("%s",s);scanf("%s",ss);
int l=strlen(s),l1=strlen(ss);
for(it i=;i<;i++){
a[i][]=;
}
for(it i=;i<l;i++){
int c=s[i]-'a';
a[c][++a[c][]]=i;
}
int pos=-,f=,bu=;
for(it i=;i<l1;i++){
int c=ss[i]-'a';
if(a[c][]==){f=;break;}
int pps=upper_bound(a[c]+,a[c]++a[c][],pos)-a[c];//cout<<pps<<endl;
if(a[c][pps]>pos && a[c][]>=pps){
pos=a[c][pps];
}
else{
bu++;pos=a[c][];
}
//cout<<a[c][pps]<<" "<<pos<<endl;
}
if(f){
printf("%d\n",bu);
}
else{
printf("-1\n");
}
}
return ;
}
D
忘记要容斥,最后发现答案输出有负数存在,所以待补
https://www.cnblogs.com/luoyugongxi/p/12243962.html
upd:没想倒是原题……这次没想到被hack完还能上几分,这B题真搞。
有空,有能力补EF
https://codeforces.com/contest/1295
Educational Codeforces Round 81 (Rated for Div. 2)的更多相关文章
- [Educational Codeforces Round 81 (Rated for Div. 2)]E. Permutation Separation(线段树,思维,前缀和)
[Educational Codeforces Round 81 (Rated for Div. 2)]E. Permutation Separation(线段树,思维,前缀和) E. Permuta ...
- Educational Codeforces Round 81 (Rated for Div. 2) B. Infinite Prefixes
题目链接:http://codeforces.com/contest/1295/problem/B 题目:给定由0,1组成的字符串s,长度为n,定义t = sssssss.....一个无限长的字符串. ...
- Educational Codeforces Round 81 (Rated for Div. 2) C. Obtain The String
题目链接:http://codeforces.com/contest/1295/problem/C 题目:给定字符串s,t. 给定一个空串z,需要按照规则把z构造成 string z == stri ...
- Educational Codeforces Round 81 (Rated for Div. 2) A-E简要题解
链接:https://codeforces.com/contest/1295 A. Display The Number 贪心思路,尽可能放置更多位,如果n为奇数,消耗3去放置一个7,剩下的放1 AC ...
- Educational Codeforces Round 81 (Rated for Div. 2) 题解
过了n天补的题解:D AB就不用说了 C. Obtain The String 思路挺简单的,就是贪心,但是直接贪心的复杂度是O(|s|*|t|),会超时,所以需要用到序列自动机 虽然名字很高端但是就 ...
- Educational Codeforces Round 81 (Rated for Div. 2)E(线段树)
预处理把左集划分为大小为1~i-1时,把全部元素都移动到右集的代价,记作sum[i]. 然后枚举终态时左集的大小,更新把元素i 留在/移动到 左集的代价. 树状数组/线段树处理区间修改/区间查询 #d ...
- Educational Codeforces Round 81 (Rated for Div. 2) - D. Same GCDs(数学)
题目链接:Same GCDs 题意:给你两个数$a$,$m(1 \leq a < m \leq 10^{10})$,求有多少个$x$满足:$0 \leq x < m$且$gcd(a,m)= ...
- Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship
Problem Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...
- Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)
Problem Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...
随机推荐
- 题解 P2146 [NOI2015]软件包管理器
P2146 [NOI2015]软件包管理器 感觉代码比其他题解更简洁qwq 树链剖分模板题 install x:将1~x的路径上的节点全部变成1(安装x需要先安装1~x) uninstall x:将x ...
- Qt入门-表格类QTableWidget
原文 :http://blog.csdn.net/xgbing/article/details/7774737 表格是GUI中常用的控件,在Qt中,常用的表格类是QTableWidget. 示例: Q ...
- UNICODE编码UTF-16 中的Endian(FE FF) 和 Little Endian(FF FE)
从网上找到的两篇不错的文章,由于被网上多处转载,所以不知道源处,未能注明出处,希望作者见谅,如有意见请发信给我,谢谢! 第一篇很清晰. 介绍Unicode之前,首先要讲解一些基础知识.虽然跟Unico ...
- 计算几何-Dot-Vector
This article is made by Jason-Cow.Welcome to reprint.But please post the article's address. 看了书,然后码 ...
- Bugku-CTF之文件包含2 (150)
Day37 文件包含2
- 09day 命令提示符优化及yum优化
export PS1='\[\e[32;1m\][\u@\h \W]\$ \[\e[0m\]' 设置颜色 内容 结束 export PS1='\[\e[30;1m\][\u@\h \W]\$ \[\e ...
- C9300升级-USB
1.show ver查看设备的版本 2.一些版本信息的参考 3.准备USB查看其具备的镜像命令:dir usbflash0: 4.复制镜像到设备命令:copy usbflash0:cat9k_iosx ...
- Ubuntu安装MySQL密码初始化问题
在Ubuntu上使用sudo apt-get install mysql-server mysql-common 命令安装MySQL以后,安装过程中没有提示输入密码.然后使用mysql -u root ...
- Python连载59-HTTP首部字段和消息头,Thinker简介
一.首部字段或者消息头 1.下面几个类型都是请求的: User-Agent:关于浏览器和它平台的消息,如Mozilla5.0 Accept:客户端能处理的页面的类型,如text/html Accept ...
- 初始css一
初始CSS 一.form表单补充 form表单关键性的属性补充 form表单 关键性的属性 action 控制的是数据的提交路径 1.不写 默认是朝着当前页面所在的地址提交 2.全路径 3.后缀(/i ...