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 ...
随机推荐
- MySQL对大小写敏感吗
见字如面,见标题知内容.你有遇到过因为MYSQL对大小写敏感而被坑的体验吗? 之前看过阿里巴巴Java开发手册,在MySql建表规约里有看到: [强制]表名.字段名必须使用小写字母或数字 , 禁止出现 ...
- Cheapest Palindrome
这个区间dp解的话是先知道小区间再推大区间,具体需要分类讨论当小区间已经是回文串了,下一层判断,所以一层一个呢还是一层两个呢, 下面讨论一层一个的话是什么情况,那么如果一层两个,可以在评论区写下代码供 ...
- 计算几何-Line-Left-Intersect
This article is made by Jason-Cow.Welcome to reprint.But please post the article's address. 好好领悟一下ve ...
- 【音乐欣赏】《Forget》 - The Tech Thieves
曲名:Forget 作者:The Tech Thieves [00:00.000] 作曲 : Mark Emmanuel/Alia May Plesa-Topham [00:01.000] 作词 : ...
- MySQL数学函数简明总结
1. ABS(x): 返回x的绝对值 mysql> select ABS(1), ABS(-1), ABS(0); +--------+---------+--------+| ABS(1) | ...
- Sublime Text3搭建完美开发环境(Python+PHP+Javascript+nodejs+C++)
一.Sublime配置(如已安装Package Control可跳过) sublime下载地址:http://www.sublimetext.com/3 安装Package Control插件: 直接 ...
- Java的Path、Paths和Files
前言 因为这几天被java.nio的这几个接口和工具类卡到了,就顺便地查了一波文档以及使用方法,这篇其实更像是API的复制粘贴,只不过我在注释里多写了一些output和注意事项,看不惯API的可以选择 ...
- 一个简单的python爬虫,爬取知乎
一个简单的python爬虫,爬取知乎 主要实现 爬取一个收藏夹 里 所有问题答案下的 图片 文字信息暂未收录,可自行实现,比图片更简单 具体代码里有详细注释,请自行阅读 项目源码: # -*- cod ...
- JS高级---体会面向对象和面向过程的编程思想
体会面向对象和面向过程的编程思想 ChangeStyle是自定义的构造函数,再通过原型添加方法的函数. 实例化对象,导入json参数,和创建cs,调用原型添加的方法函数 过渡,先熟悉记忆 <!D ...
- Java方法的定义和使用
/* 定义一个方法的格式: public static void 方法名称() { 方法体 } 方法名称的命名规则和变量一样,使用小驼峰. 方法体:也就是大括号当中可以包含任意条语句. 注意事项: 1 ...