模拟钟表的时分秒针的走动,给出时间求出夹角。注意每组输出要有一个空格

以后要想好再写代码,这样一个水题做了50分钟,太弱了。。。

 #include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std; string s;
int dp[][];
int save[]; int main(){
int T;
int cas = ;
scanf("%d", &T);
while(T--){
cin >> s;
memset(dp, , sizeof(dp));
memset(save, , sizeof(save));
for(int i = ; i < s.length(); i++){
scanf("%d", &save[i]);
}
if(s[] == ''){
dp[][] += save[];
dp[][] = ;
}else if(s[] == ''){
dp[][] = dp[][] = ;
}else{
dp[][] += save[];
dp[][] = ;
}
//printf("%d\n", max(dp[0][1], dp[0][0]));
for(int i = ; i < s.length(); i++){
if(s[i] == ''){
if(s[i-] == ''){
dp[i][] = dp[i-][] + save[i];
}else if(s[i-] == ''){
dp[i][] = dp[i-][];
}else if(s[i-] == '?'){
dp[i][] = max(dp[i-][] + save[i], dp[i-][]);
}
}else if(s[i] == ''){
if(s[i-] == ''){
dp[i][] = dp[i-][];
}else if(s[i-] == ''){
dp[i][] = dp[i-][] + save[i];
}else if(s[i-] == '?'){
dp[i][] = max(dp[i-][] + save[i], dp[i-][]);
//printf("dp[%d][0] = %d \n", dp[i][0]);
}
}else if(s[i] == '?'){
if(s[i-] == ''){
dp[i][] = dp[i-][] + save[i];
//printf("dp[%d][1] = %d \n", i, dp[i][1]);
dp[i][] = dp[i-][];
//printf("dp[%d][0] = %d \n", i, dp[i][0]);
}else if(s[i-] == ''){
dp[i][] = dp[i-][] + save[i];
dp[i][] = dp[i-][];
}else if(s[i-] == '?'){
dp[i][] = max(dp[i-][] + save[i], dp[i-][]);
dp[i][] = max(dp[i-][] + save[i], dp[i-][]);
}
}
//printf("%d\n", max(dp[i][1], dp[i][0]));
}
int n = s.length() - ;
printf("Case #%d: %d\n", ++cas, max(dp[n][], dp[n][]));
}
return ;
}

HDU5387-模拟水题的更多相关文章

  1. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  2. POJ 2014:Flow Layout 模拟水题

    Flow Layout Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 3091   Accepted: 2148 Descr ...

  3. 模拟水题,查看二维数组是否有一列都为1(POJ2864)

    题目链接:http://poj.org/problem?id=2864 题意:参照题目 哈哈哈,这个题discuss有翻译哦.水到我不想交了. #include <cstdio> #inc ...

  4. UVA 10714 Ants 蚂蚁 贪心+模拟 水题

    题意:蚂蚁在木棍上爬,速度1cm/s,给出木棍长度和每只蚂蚁的位置,问蚂蚁全部下木棍的最长时间和最短时间. 模拟一下,发现其实灰常水的贪心... 不能直接求最大和最小的= =.只要求出每只蚂蚁都走长路 ...

  5. Codeforces 1082B Vova and Trophies 模拟,水题,坑 B

    Codeforces 1082B Vova and Trophies https://vjudge.net/problem/CodeForces-1082B 题目: Vova has won nn t ...

  6. HDU4287-STL模拟水题

    一场2012天津网络预选赛的题,签到题. 但是还是写了三四十分钟,C++和STL太不熟悉了,总是编译错误不知道怎么解决. 一开始用的Char [] 后来改成了string,STL和string搭配起来 ...

  7. hdu 4891 模拟水题

    http://acm.hdu.edu.cn/showproblem.php?pid=4891 给出一个文本,问说有多少种理解方式. 1. $$中间的,(s1+1) * (s2+1) * ...*(sn ...

  8. Mishka and Contest(模拟水题)

    Mishka started participating in a programming contest. There are nn problems in the contest. Mishka' ...

  9. 模拟水题,牛吃草(POJ2459)

    题目链接:http://poj.org/problem?id=2459 题目大意:有C头牛,下面有C行,每头牛放进草地的时间,每天吃一个草,总共有F1个草,想要在第D的时候,草地只剩下F2个草. 解题 ...

  10. 洛谷 1079 Vigenère 密码——模拟水题

    题目:https://www.luogu.org/problemnew/show/P1079 大水题. #include<iostream> #include<cstdio> ...

随机推荐

  1. Zephyr的Shell

    1 前言 通过Shell可以跟子系统打交道,子系统也可以提供很多接口供外部设置和读取信息. 下面就Shell的Kconfig配置.Shell的使用以及如何新建一个Shell命令展开. 可以说Shell ...

  2. SkylineGlobe 如何实现二次开发加载KML文件

    示例代码如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www ...

  3. BZOJ3676 APIO2014 回文串 Manacher、SA

    传送门 首先一个结论:串\(S\)中本质不同的回文串个数最多有\(|S|\)个 证明考虑以点\(i\)结尾的所有回文串,假设为\(S[l_1,i],S[l_2,i],...,S[l_k,i]\),其中 ...

  4. Luogu3524 POI2011 Party 图论、构造

    题目传送门:https://www.luogu.org/problemnew/show/P3524 大意:给一个$N$个点的图,其中一定有一个大小为$\frac{2}{3}N$的团,程序需给出一个大小 ...

  5. Ionic Android项目Splash设置

    ionic项目中,在splashscreen消失后会出现零点几秒的白屏,再出现app页面. 1. 安装Cordova splash screen插件 ionic plugin add org.apac ...

  6. linux环境下nc命令的应用

    一.安装 下载 http://vault.centos.org/6.6/os/x86_64/Packages/nc-1.84-22.el6.x86_64.rpm rpm -iUv nc-1.84-22 ...

  7. 理解标准盒模型和怪异模式&box-sizing属性

    盒子模型 主要有两种,w3c标准盒模型,IE下的怪异盒模型,其实还有就是弹性盒模型(上篇文章我们用他很好的解决了对齐问题) DTD规范 盒模型分为:标准w3c盒模型.IE盒模型.以及css中的伸缩盒模 ...

  8. Net-SNMP V3协议 安装配置笔记(CentOS 6.3/5.6)

    注意:snmp V3,需要需要关闭selinux和防火墙: 关闭selinux方法: #vi /etc/selinux/config 将文件中的SELINUX="" 为 disab ...

  9. js控制css时注意

    font-size:10px--------e.style.fontSize="10px " 属性名:font-size--------fontSize; 属性值:10px---- ...

  10. Java实验二

    北京电子科技学院(BESTI) 实     验    报     告 课程:Java程序设计 班级:1351    姓名:黄君如  学号:20135117 成绩:             指导教师:娄 ...