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 ...
随机推荐
- MinGW dll导入导出类
dll不仅可以导入导出函数,还可以导入导出类.这篇文章就来介绍如何将类导入dll中并导出. 首先我们建立一个名为dll.cpp的文件(又是这种破名字),里面写上: #include <iostr ...
- appium---切换webview时报错
在上一篇中简单介绍了如何查看webview和切换到webview的方法,可能第一次切换webview的时候会报错“Error: session not created exception: Chrom ...
- 压缩/批量压缩/合并js文件
写在前面 如果文件少的话,直接去网站转化一下就行. http://tool.oschina.net/jscompress?type=3 1.压缩单个js文件 cnpm install uglify-j ...
- 自己centos7成功的修改了主机名(记录了该改哪些文件)
1.更改/etc/hosts 方法(1)可以直接的去更改这个文件,更改的格式:直接vi编辑器打开,之后直接写上自己想要的主机名字就好,不用写成键值对的形式 [root@localhost etc]# ...
- Python开发五子棋游戏【新手必学】
五子棋源码,原创代码,仅供 python 开源项目学习.目前电脑走法笨笨的,下一期版本会提高电脑算法ps:另外很多人在学习Python的过程中,往往因为遇问题解决不了或者没好的教程从而导致自己放弃,为 ...
- warmup
先简单了解下源码中的2个函数: <?php echo mb_strpos("朋友比生命还重要?或许是吧" . '?',"?"); echo "\ ...
- Yii2框架 常用函数整合
1.使用事务添加数据: public function create() { if($this->validate()) { $trans = Yii::$app->db->begi ...
- PAT 1014 Waiting in Line (模拟)
Suppose a bank has N windows open for service. There is a yellow line in front of the windows which ...
- websocket协议实现
# websocket协议实现 1.抓包 wireshark规则: tcp.port == 9000 2. 结果解析 客户端请求: GET /ws/test_2 HTTP/1.1 Host: loca ...
- plutosdr初步
关于最近新出的pluto sdr ,一款较新的sdr,可以通过破解将ad9363改成ad9361,提升频率范围,但是据说没有办法改变带宽. 可以通过补丁方式使用某款软件来进行收听fm