Codeforces Beta Round #96 (Div. 2) (A-E)
写份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)的更多相关文章
- 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 ...
- Codeforces Beta Round #96 (Div. 2) E. Logo Turtle dp
http://codeforces.com/contest/133/problem/E 题目就是给定一段序列,要求那个乌龟要走完整段序列,其中T就是掉头,F就是向前一步,然后开始在原点,起始方向随意, ...
- 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 ...
- 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 ...
- 『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 ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
- Codeforces Beta Round #73 (Div. 2 Only)
Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...
- Codeforces Beta Round #69 (Div. 2 Only)
Codeforces Beta Round #69 (Div. 2 Only) http://codeforces.com/contest/80 A #include<bits/stdc++.h ...
- Codeforces Beta Round #40 (Div. 2)
Codeforces Beta Round #40 (Div. 2) http://codeforces.com/contest/41 A #include<bits/stdc++.h> ...
随机推荐
- 浅谈JavaScript的面向对象程序设计(三)
前面已经对JavaScript的面向对象程序设计作了简单的介绍,包括了对象的属性.对象的工厂模式.构造函数和原型等.通过介绍,这些创建对象的方法依然有不少优化和改进的地方. 组合使用构造函数模式和原型 ...
- iOS开发中正则式的使用
iOS开发中正则式的使用 第一:常规的使用方式 NSString *str = @"abcded111093212qweqw"; //找到内部一个即可 NSString *patt ...
- HDU1251 统计难题 【trie树】
统计难题 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131070/65535 K (Java/Others) Total Subm ...
- [学习笔记]渗透测试metasploit
1.渗透成功后,在meterpreter命令行,需要使用如下命令切换当前目录.更多信息,可以参考: meterpreter > pwd C:\ meterpreter > cd /&quo ...
- 解决IOS滑动页面fixed浮动问题
<div style="position: fixed"></div> <div style="height: 100%; overflow ...
- iOS开发——高级篇——FMDB 数据库简单使用
#import <Foundation/Foundation.h> @interface UserDB : NSObject // 把userDB设计成一个单例类 + (id)shareI ...
- myeclipse提示:Syntax error on tokens, delete these tokens怎么解决
有中文字符或者符号,包括空格. 上次遇到一个问题,检查了一遍语法没错误, 后来发现是拷贝代码的时候有一部分中文空格没删除,就出现这个问题了. 一个个删除就OK了.
- python 线程 进程 标识
s = '%s%s%s%s%s%s%s%s' % ( time.strftime('%Y%m%d %H:%M:%S', time.localtime(time.time())), ' os.getpp ...
- GoodUI:页面布局的技巧和设计理念
http://goodui.org/ 中文翻译:http://www.cnblogs.com/Wayou/p/goodui.html 一年了,小小少年从幼年期过渡到成长期要开始加速冲刺了.毕竟钻头就是 ...
- 清空sql 日志
USE [master] GO ALTER DATABASE 库名 SET RECOVERY SIMPLE GO USE 库名 GO ,,TRUNCATEONLY) GO USE [master] G ...