A

题目:

Jessie has a magic mirror.

Every morning she will ask the mirror: 'Mirror mirror tell me, who is the most beautiful girl in the world?' If the mirror says her name, she will praise the mirror: 'Good guy!', but if the mirror says the name of another person, she will assail the mirror: 'Dare you say that again?'

Today Jessie asks the mirror the same question above, and you are given a series of mirror's answers. For each answer, please output Jessie's response. You can assume that the uppercase or lowercase letters appearing anywhere in the name will have no influence on the answer. For example, 'Jessie' and 'jessie' represent the same person.

Input

The first line contains an integer T(1 \le T \le 100)T(1≤T≤100), which is the number of test cases.

Each test case contains one line with a single-word name, which contains only English letters. The length of each name is no more than 1515.

Output

For each test case, output one line containing the answer.

样例输入复制

2
Jessie
Justin

样例输出复制

Good guy!
Dare you say that again?

题目来源

ACM-ICPC 2018 焦作赛区网络预赛


题解:

题目的意思即是 现在有一个已经确定的字符串,然后输入字符串,与源字符串进行比较,若除大小写外无差别就输出“ Good guy!” ,否则输出“Dare you say that again?" 。

仅仅需要一个字符串的逐个位比较。


代码:

代码1

#include <cstdio>
#include <iostream>using namespace std;int main(){int a;string c ="jessie",b;scanf("%d",&a);for(;a;a--){cin>>b;int i=0,q=0;if(b.length()!=6){printf("Dare you say that again?\n");continue;}for(;i<7;i++){if(b[i]==c[i] ||b[i]==c[i] - 32 ){q++;}else{printf("Dare you say that again?\n");break;}if(q==6){printf("Good guy!\n");}}  }return 0;
}

代码2

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;int main(){int t;scanf("%d",&t);string s;string tt="jessie";while(t--){cin>>s;int flag=1;if(s.length()!=6){printf("Dare you say that again?\n");continue;}for(int i=0;i<s.length();i++){if(s[i]==tt[i]||s[i]==tt[i]-32)continue;else {flag=0;break;}}if(!flag)printf("Dare you say that again?\n");else printf("Good guy!\n");}
}

B

题目

A prince of the Science Continent was imprisoned in a castle because of his contempt for mathematics when he was young, and was entangled in some mathematical curses. He studied hard until he reached adulthood and decided to use his knowledge to escape the castle.

There are NNN rooms from the place where he was imprisoned to the exit of the castle. In the ithi^{th}ith room, there is a wizard who has a resentment value of a[i]a[i]a[i]. The prince has MMM curses, the jthj^{th}jth curse is f[j]f[j]f[j], and f[j]f[j]f[j] represents one of the four arithmetic operations, namely addition(‘+’), subtraction(‘-‘), multiplication(‘*’), and integer division(‘/’). The prince’s initial resentment value is KKK. Entering a room and fighting with the wizard will eliminate a curse, but the prince’s resentment value will become the result of the arithmetic operation f[j]f[j]f[j] with the wizard’s resentment value. That is, if the prince eliminates the jthj^{th}jth curse in the ithi^{th}ith room, then his resentment value will change from xxx to (x f[j] a[i]x\ f[j]\ a[i]x f[j] a[i]), for example, when x=1,a[i]=2,f[j]=x=1, a[i]=2, f[j]=x=1,a[i]=2,f[j]=’+’, then xxx will become 1+2=31+2=31+2=3.

Before the prince escapes from the castle, he must eliminate all the curses. He must go from a[1]a[1]a[1] to a[N]a[N]a[N] in order and cannot turn back. He must also eliminate the f[1]f[1]f[1] to f[M]f[M]f[M] curses in order(It is guaranteed that N≥MN\ge MN≥M). What is the maximum resentment value that the prince may have when he leaves the castle?
Input

The first line contains an integer T(1≤T≤1000)T(1 \le T \le 1000)T(1≤T≤1000), which is the number of test cases.

For each test case, the first line contains three non-zero integers: N(1≤N≤1000),M(1≤M≤5)N(1 \le N \le 1000), M(1 \le M \le 5)N(1≤N≤1000),M(1≤M≤5) and K(−1000≤K≤1000K(-1000 \le K \le 1000K(−1000≤K≤1000), the second line contains NNN non-zero integers: a[1],a[2],…,aNa[1], a[2], …, a[N](-1000 \le a[i] \le 1000)a[1],a[2],…,aN, and the third line contains MMM characters: f[1],f[2],…,f[M](f[j]=f[1], f[2], …, f[M](f[j] =f[1],f[2],…,f[M](f[j]=’+’,’-‘,’*’,’/’, with no spaces in between.
Output

For each test case, output one line containing a single integer.

Input

3
2 1 5
2 3
/
3 2 1
1 2 3
++
4 4 5
1 2 3 4
+-*/

Output

2
6
3

题目来源

ACM-ICPC 2018 焦作赛区网络预赛

题意:
有n个房间,m个诅咒,每个房间有一个数值,刚开始有一个初始值,每次进入一个房间可以选择消除诅咒或者不消除,消除诅咒只能顺序消除,消除诅咒就是拿初始值和房间的数值做运算,求最后最大的数是多少

分析:
Max[i][j] 表示 第i个房间 第j个操作的最大值, Min[i][j]

表示第i个房间第j个操作的最小值

因为乘法 负负相乘可能变得很大

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1010;
const ll INF = 0x3f3f3f3f3f3f3f3f;int T,n,m;
int arr[N];
char f[10];
ll Max[N][10],Min[N][10];ll k,ans;int main(){scanf("%d",&T);while(T--){scanf("%d%d%lld",&n,&m,&k);for(int i = 1; i <= n; i++) scanf("%d",&arr[i]);scanf("%s",f+1);memset(Max,-0x3f,sizeof(Max));memset(Min,0x3f,sizeof(Min));Max[0][0] = Min[0][0] = k;ans = -INF;for(int i = 1; i <= n; i++){Max[i][0] = k;Min[i][0] = k;//没有运算符的时候就是初始值kfor(int j = 1; j <= min(m,i); j++){Max[i][j] = Max[i-1][j];Min[i][j] = Min[i-1][j];//当前i房间第j个运算符先初始化为上一个房间第j个运算符的值ll a = Max[i-1][j-1],c = Min[i-1][j-1],b = (ll)arr[i];//当前i房间第j个运算符的值应该由上一个房间的j-1运算符转移过来if(f[j] == '+'){a += b,c += b;}else if(f[j] == '-'){a -= b,c -= b;}else if(f[j] == '*'){a *= b,c *= b;}else if(f[j] == '/'){a /= b,c /= b;}if(a < c) swap(a,c);Max[i][j] = max(Max[i][j],a);Min[i][j] = min(Min[i][j],c);}ans = max(Max[i][m],ans);}printf("%lld\n",ans);}return 0;
}

ACM-ICPC 2018 焦作赛区网络预赛 A. Magic Mirror (水)| B . Mathematical Curse(dp)相关推荐

  1. ACM-ICPC 2018 焦作赛区网络预赛A. Magic Mirror(签到题)

    Jessie has a magic mirror. Every morning she will ask the mirror: 'Mirror mirror tell me, who is the ...

  2. ICPC 2018 焦作赛区网络预赛G Give Candies 组合数学隔板法+欧拉降幂

    G Give Candies 计蒜客 G Give Candies 题意 n n n个糖果, n n n个人从 1 1 1~ n n n编号,每次给一个人发糖可以发任意数量但不能小于 1 1 1,直到 ...

  3. ACM-ICPC 2018 焦作赛区网络预赛 J(二分+JAVA高精)

    传送门 题面: 65536K Jessie and Justin want to participate in e-sports. E-sports contain many games, but t ...

  4. ACM-ICPC 2018 焦作赛区网络预赛 H题 String and Times(SAM)

    Now you have a string consists of uppercase letters, two integers AA and BB. We call a substring won ...

  5. L. Poor God Water(ACM-ICPC 2018 焦作赛区网络预赛,ac自动机+矩阵快速幂 或 BM线性递推)

    描述 God Water likes to eat meat, fish and chocolate very much, but unfortunately, the doctor tells hi ...

  6. ACM-ICPC 2018 焦作赛区网络预赛(A B E F G H I K L)

    ACM-ICPC 2018 焦作赛区网络预赛(A B E F G H I K L) 发了博客一万年之后才发现H1写错了(tao A. Magic Mirror 题目链接 题面: Jessie has ...

  7. ACM-ICPC 2018 焦作赛区网络预赛

    Give Candies 题意:有n颗糖,有n个人,按顺序出列,每次随机给那个人一些糖(至少一颗),分完为止,求有多少方案 思路:规律是2^(n−1) 根据费马小定理  a^(p−1)=1(mod p ...

  8. ACM-ICPC 2018 焦作赛区网络预赛 L Poor God Water(BM算法)

    题目链接:https://nanti.jisuanke.com/t/31721 题目大意:三种食物,n小时,连续三小时不能吃一样的东西,中间吃巧克力时连续三个小时吃的东西不能完全不同,如果中间吃鱼或者 ...

  9. ACM-ICPC 2018 焦作赛区网络预赛 L. Poor God Water

    #题解 大佬的递推式子..本弱鸡具体怎么得到的也不是很清楚 f(1)=3,f(2)=9,f(3)=20,f(4)=46,f(5)=106 f(n)=2f(n-1)-f(n-2)+3f(n-3)+2*f ...

最新文章

  1. Unity学习笔记 - Assets, Objects and Serialization
  2. 她把肥皂放在矿泉水瓶盖上,第二天大吃一惊...…
  3. 回溯法解决工作分配问题及分析
  4. 使用Apache Zookeeper进行协调和服务发现
  5. 程序员写的数字代表什么_代表性不足的国家的程序员可以取得成功的6种方法...
  6. 中的挂起是什么意思_仪表板亮奇怪指示灯,乌龟晒太阳是什么意思?老司机:不懂别上路...
  7. ceph rbd双挂载导致ext4文件系统inode链接数据污染
  8. 推荐几个好评率超高的公众号,有远见的程序员都关注了!
  9. R语言数据集合并、数据增减、不等长合并
  10. Linux下mysql主从同步备份master-slave详细配置
  11. 19所大陆高校上榜!2021泰晤士世界大学影响力排名发布
  12. 千兆网卡为什么慢_宽带300M,光猫是千兆的,电脑网卡和无线路由器都是千兆的。但是速度仍是100M。这是为什么?...
  13. 后深度学习的挑战与思考(PRCV 焦李成 报告记录)
  14. win7 计算机登录用户名和密码忘记,电脑win7登陆密码忘记了怎么办_win7忘记登陆密码如何进入-win7之家...
  15. Oracle用户管理的备份与恢复(冷热)
  16. No way to dispatch this command to Redis Cluster because keys have different slots.
  17. matlab 按照字符串运行,matlab中将字符串视为语句运行的方法——eval()函数
  18. 解决路由报错Uncaught (in promise) NavigationDuplicated:
  19. 2022 年最值得学习的 10 种编程语言 [更新]
  20. python的学习笔记案例3--基础代谢率计算1.0

热门文章

  1. qt窗体设置圆角后出现黑色的直角
  2. B1019(数字黑洞)
  3. 使用联机搜索求解Wumpus World
  4. 刀片之家礼品兑换帮助
  5. 【微信小程序开发】(三)首页banner组件使用swiper
  6. Elasticsearch学习(四) - 查询①
  7. Barsetto百胜图BAV01咖啡机——效率超神buff获取攻略
  8. Cassandra_教程二_利用 CQL 操作 Cassandra
  9. 【成电860考研】经验贴汇总(专业课部分)-扒遍所有网站:信软群、王道、知乎、csdn等,截止21年7月整理出的所有帖子-共15篇
  10. java集合-set练习题