写份DIV2的完整题解

A

判断下HQ9有没有出现过

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 112
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
char s[N];
int main()
{
int i,j,k;
cin>>s;
k = strlen(s);
for(i = ; i < k ;i++)
if(s[i]=='H'||s[i]==''||s[i]=='Q')
break;
if(i==k)
puts("NO");
else
puts("YES");
return ;
}

B

模拟下就OK

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 112
#define LL long long
#define INF 0xfffffff
#define mod 1000003
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
char s[N];
int a[];
int main()
{
int i,j,k;
a['>'] = ;
a['<'] = ;
a['+'] = ;
a['-'] = ;
a['.'] = ;
a[','] = ;
a['['] = ;
a[']'] = ;
cin>>s;
k = strlen(s);
int ans = ;
for(i = ;i < k ; i++)
{
// cout<<a[s[i]]<<endl;
ans = (ans*+a[s[i]])%mod;
}
cout<<ans<<endl;
return ;
}

C

题意有点费解 给定操作 使其数字变为字符 先给你字符 问原先数字为多少 模拟。。

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 112
#define LL long long
#define INF 0xfffffff
#define mod 256
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
char s[N];
int a[];
int main()
{
int i,j,k;
gets(s);
k = strlen(s);
int ans = ;
int kt = ;
for(i = ;i < k ; i++)
{
int x = s[i];
int y = kt;
int g = ;kt=;
memset(a,,sizeof(a));
while(y)
{
a[g++] = y%;
y/=;
}
for(j = ; j < ;j++)
kt+=pow(,-j-)*a[j];
memset(a,,sizeof(a));
g = ;
while(x)
{
a[g++] = x%;
x/=;
}
int ans = ;
for(j = ; j < ;j++)
ans+=pow(,-j-)*a[j];
kt = (kt-ans+mod)%mod;
cout<<kt<<endl;
kt = s[i];
}
return ;
}

D

题意更是费解 大意:你当前在某一个颜色块中 你有两个指向标  一个是向另一块前进的方向 另一个是在本块的前进方向 0块和边外不能走 问m次后你在哪个块中

模拟。。

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 112
#define LL long long
#define INF 0xfffffff
#define mod 256
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
char s[][];
int a[][][],n,k;
int judge(int x,int y)
{
if(x<||x>=n||y<||y>=k)
return ;
if(s[x][y]=='') return ;
return ;
}
int main()
{
int i,j,m,g;
cin>>n>>m;
for(i = ; i < n ;i++)
cin>>s[i];
k = strlen(s[]);
for(i = ;i < n ;i++)
{
for(j = ; j < k ;j++)
{
for(g = j ; g >= ; g--)
if(s[i][g]!=s[i][j]) break;
a[i][j][] = g+;
for(g = i ; g >= ; g--)
if(s[g][j]!=s[i][j]) break;
a[i][j][] = g+;
for(g = j ; g < k; g++)
if(s[i][g]!=s[i][j]) break;
a[i][j][] = g-;
for(g = i ; g < n ;g++)
if(s[g][j]!=s[i][j]) break;
a[i][j][] = g-;
}
}
int d1 = ,d2 = ,x = ,y = ;
char c = s[][];
int k1 = ;
while(k1<=m)
{
if(d1==||d1==)
x = a[x][y][d1];
else y = a[x][y][d1];
if(d2==||d2==)
x = a[x][y][d2];
else y = a[x][y][d2];
int tx,ty;
if(d1==)
{
tx = x-;ty = y;
}
else if(d1==)
{
tx = x;ty = y+;
}
else if(d1==)
{
tx = x+;ty = y;
}
else
{
tx = x;ty = y-;
}
if(!judge(tx,ty))
{
//cout<<",";
if((d2+)%==d1)
d2 = (d1+)%;
else
{ d1 = (d1+)%;d2 = (d1-+)%;
}
}
else
{
c = s[tx][ty];
x = tx,y = ty;
}
k1++;
//x = tx
//cout<<c<<" "<<d1<<" "<<d2<<" "<<k1<<" "<<x<<" "<<y<<endl;
}
cout<<c<<endl;
return ;
}

E

当时的思路貌似不太对 按照zp说的思路又重写了一遍

dp[i][j][0] 表示在i位置已经改变了j次方向为正的最大移动距离 dp[i][j][1]类似表反方向。

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 112
#define LL long long
#define INF 0xfffffff
#define mod 256
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
int dp[N][][];
char s[N];
int main()
{
int i,j,k;
cin>>s;
cin>>k;
int kk = strlen(s);
for(i = ; i < kk ; i++)
for(j = ; j <= k ; j++)
dp[i][j][] = dp[i][j][] = -INF;
if(s[]=='T')
{
for(i = ; i <= k ; i++)
{
if(i%!=)
dp[][i][] = -;
else
dp[][i][] = ;
}
}
else
{
for(i = ; i <= k ; i++)
if(i%==)
dp[][i][] = ;
else
dp[][i][] = ;
}
for(i = ; i < kk ;i++)
{
if(s[i]=='T')
{
dp[i][][] = dp[i-][][];
dp[i][][] = dp[i-][][];
}
else
{
dp[i][][] = dp[i-][][]+;
dp[i][][] = dp[i-][][]-;
}
for(j = ; j <= k ; j++)
{
if(s[i]=='T')
{
dp[i][j][] = max(dp[i-][j][],dp[i-][j-][]+);
dp[i][j][] = max(dp[i-][j][],dp[i-][j-][]-);
}
else
{
dp[i][j][] = max(dp[i-][j][]+,dp[i-][j-][]);
dp[i][j][] = max(dp[i-][j][]-,dp[i-][j-][]);
}
}
}
int ans1 = max(dp[kk-][k][],dp[kk-][k][]);
for(i = ; i < kk ; i++)
for(j = ; j <= k ; j++)
dp[i][j][] = dp[i][j][] = -INF;
if(s[]=='T')
{
for(i = ; i <= k ; i++)
{
if(i%!=)
dp[][i][] = ;
else
dp[][i][] = ;
}
}
else
{
for(i = ; i <= k ; i++)
if(i%==)
dp[][i][] = -;
else
dp[][i][] = ;
}
for(i = ; i < kk ;i++)
{
if(s[i]=='T')
{
dp[i][][] = dp[i-][][];
dp[i][][] = dp[i-][][];
}
else
{
dp[i][][] = dp[i-][][]+;
dp[i][][] = dp[i-][][]-;
}
for(j = ; j <= k ; j++)
{
if(s[i]=='T')
{
dp[i][j][] = max(dp[i-][j][],dp[i-][j-][]+);
dp[i][j][] = max(dp[i-][j][],dp[i-][j-][]-);
}
else
{
dp[i][j][] = max(dp[i-][j][]+,dp[i-][j-][]);
dp[i][j][] = max(dp[i-][j][]-,dp[i-][j-][]);
}
}
}
int ans2 = max(dp[kk-][k][],dp[kk-][k][]);
//cout<<ans1<<" "<<ans2<<endl;
int ans = max(ans1,ans2);
cout<<ans<<endl;
return ;
}

Codeforces Beta Round #96 (Div. 2) (A-E)的更多相关文章

  1. Codeforces Beta Round #96 (Div. 1) C. Logo Turtle —— DP

    题目链接:http://codeforces.com/contest/132/problem/C C. Logo Turtle time limit per test 2 seconds memory ...

  2. Codeforces Beta Round #96 (Div. 2) E. Logo Turtle dp

    http://codeforces.com/contest/133/problem/E 题目就是给定一段序列,要求那个乌龟要走完整段序列,其中T就是掉头,F就是向前一步,然后开始在原点,起始方向随意, ...

  3. Codeforces Beta Round #96 (Div. 1) D. Constants in the language of Shakespeare 贪心

    D. Constants in the language of Shakespeare Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codef ...

  4. Codeforces Beta Round #96 (Div. 1) C. Logo Turtle DP

    C. Logo Turtle   A lot of people associate Logo programming language with turtle graphics. In this c ...

  5. 『NYIST』第九届河南省ACM竞赛队伍选拔赛[正式赛二]- Nearly Lucky Number(Codeforces Beta Round #84 (Div. 2 Only)A. Nearly)

    A. Nearly Lucky Number time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  6. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

  7. Codeforces Beta Round #73 (Div. 2 Only)

    Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...

  8. Codeforces Beta Round #69 (Div. 2 Only)

    Codeforces Beta Round #69 (Div. 2 Only) http://codeforces.com/contest/80 A #include<bits/stdc++.h ...

  9. Codeforces Beta Round #40 (Div. 2)

    Codeforces Beta Round #40 (Div. 2) http://codeforces.com/contest/41 A #include<bits/stdc++.h> ...

随机推荐

  1. 杭电1232畅通project

    畅通project Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total ...

  2. MySQL基础笔记(五) 视图

    一.什么是视图 视图是一个虚拟表.也就是说,视图在外观和行为上都类似于表,但它不需要实际的物理存储,只保存了视图定义(查询语句). 视图由select查询所定义 -- 当创建一个视图时,实际上是在数据 ...

  3. Selenium系列之--测试框架断言【转】

    selenium提供了三种模式的断言:assert .verify.waitfor 1)Assert(断言) 失败时,该测试将终止. 2)Verify(验证) 失败时,该测试将继续执行,并将错误记入日 ...

  4. 优化 html 标签 为何能用HTML/CSS解决的问题就不要使用JS?

    优化 html 标签 2018年05月11日 08:56:24 阅读数:19 有些人写页面会走向一个极端,几乎页面所有的标签都用div,究其原因,用div有很多好处,一个是div没有默认样式,不会有m ...

  5. 到底该不该使用存储过程 MySQL查询性能优化一则

    到底该不该使用存储过程   看到<阿里巴巴java编码规范>有这样一条 关于这条规范,我说说我个人的看法 用不用存储过程要视所使用的数据库和业务场景而定的,不能因为阿里巴巴的技术牛逼,就视 ...

  6. BZOJ 1122 POI2008 账本BBB 单调队列

    题目大意:给定一个由+1和−1构成的长度为n的序列,提供两种操作: 1.将某一位取反,花销为x 2.将最后一位移动到前一位.花销为y 要求终于p+sumn=q.且p+sumi≥0(1≤i≤n),求最小 ...

  7. android ImageUtils 图片处理工具类

    /** * 加入文字到图片.相似水印文字. * @param gContext * @param gResId * @param gText * @return */ public static Bi ...

  8. Hibernate 之 Locking

    在我们业务实现的过程中,往往会有这样的需求:保证数据访问的排他性,也就是我正在访问的数据,别人不能够访问,或者不能对我的数据进行操作.面对这样的需求,就需要通过一种机制来保证这些数据在一定的操作过程中 ...

  9. swift中的@objc的作用

    转载:https://www.jianshu.com/p/6c5b45d9d042 自动清除冗余代码减小包大小 得益于 Swift 的静态语言特性,每个函数的调用在编译期间就可以确定.因此在编译完成后 ...

  10. Mac Mysql [ERR] 2006 - MySQL server has gone away

    Mac mysql 安装后,导入sql数据,出现这个错误: 处理方式,是因为sql文件太大,需要修改mysql的配置.如果没有my.cnf就自己建一个. cd /etc sudo vim my.cnf ...