写份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. 理解Android ANR的触发原理(转)

    一.概述 ANR(Application Not responding),是指应用程序未响应,Android系统对于一些事件需要在一定的时间范围内完成,如果超过预定时间能未能得到有效响应或者响应时间过 ...

  2. POI 的使用

    POI 使用 一. POI简介 Apache POI是Apache软件基金会的开放源码函式库,POI提供API给Java程序对Microsoft Office格式档案读和写的功能..NET的开发人员则 ...

  3. Selenium系列之--01 简介【转】

    1.selenium 工具组件 1.1 selenium2,也称为selenium webdriver.webdriver原来是另一个自动化测试工具,后与selenium 合并了.webdriver直 ...

  4. AnkhSVN介绍

    AnkhSVN介绍 Posted on 2012-11-15 23:24 ArRan 阅读(3120) 评论(1) 编辑 收藏 AnkhSVN是一款在VS中管理Subversion的插件,您可以在VS ...

  5. AIDL/IPC Android AIDL/IPC 进程通信机制——超具体解说及使用方法案例剖析(播放器)

    首先引申下AIDL.什么是AIDL呢?IPC? ------ Designing a Remote Interface Using AIDL 通常情况下,我们在同一进程内会使用Binder.Broad ...

  6. Coding Ninja 修炼笔记 (1)

    大家好啊~我又回来了. 这次主要是给大家带来一些提升 Coding 效率的建议. 效率都是一点一滴优化出来的,虽然每一条建议给你带来的提升可能都不大,但是积累起来,仍然是一股不可忽视的力量. 第一条 ...

  7. 比 git log 更强大的 git reflog

    最近做了个骚操作 git checkout commitId 修改了部分内容 git add . git commit -m '修改了些东西'   -> 此时git 会自动生成一个新的 comm ...

  8. 【iOS系列】- iOS吸附效果的实现 之 UICollectionView的使用全解

    [iOS系列]- iOS吸附效果的实现 之 UICollectionView的使用全解 UICollectionView可以做很多的布局,在iOS开发中较为重要,所以这里就以实例来讲解UICollec ...

  9. ubuntu安装jdk 1.6

    linux下安装JDK1.6 1. 去http://java.sun.com/j2se/1.4.2/download.html 下载一个Linux Platform的JDK,建议下载RPM自解压格式的 ...

  10. String StringBuffer StringBuilder 对比

      1.StringBuffer是线程安全的,StringBuilder是非线程安全的   2.对String的修改其实是new了一个StringBuilder并调用append方法,然后调用toSt ...