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. 您的凭依不工作/登录没有成功
  2. SQL Server数据库镜像部署 错误1418’处理及证书验证
  3. 开源一个ShellCode生成框架
  4. 条款五:对应的new和delete要采用相同的形式
  5. lucene全文搜索之三:生成索引字段,创建索引文档(给索引字段加权)基于lucene5.5.3...
  6. java mp3 to wav_java实现wavToMP3格式转换详解
  7. 用反射方法使用户控件动态调用父页面的方法
  8. vcneter5.5添加域用户权限
  9. ssl 命令访问其他的服务器
  10. 如何在面试中发现优秀程序员
  11. 计算机发展史_最全计算机发展史
  12. nagios原装配置文件
  13. Multisim12\Multisim14访问主数据库失败的解决方法
  14. html5 css3 JavaScript响应式中文静态网页模板js源代码
  15. 高配游戏组装电脑配置清单表 2021 组装电脑配置推荐2021
  16. 原生JS实现各种运动之匀速运动
  17. NFC Forum发布NFC数据交换格式(NDEF)规范
  18. Linux-Shell脚本练习
  19. Learn to Give Up
  20. Android QQ登录集成

热门文章

  1. selenium:定位一闪而过的弹窗
  2. 西电计算机学院有保研清华的吗,北邮西电保送清华人数进前10,不输双一流,哪些大学学生能读清华...
  3. 07.nodejs文件操作
  4. 2021级-JAVA02 基础语法1--标识符、常量与变量、数据类型、运算符与表达式209 天
  5. 【CS224n-5】Linguistic Structure: Dependency Parsing
  6. 北邮复试 | 北邮机试往年题汇总 | 计算机院 | 网研院 | 网安院 | 软院
  7. 19个三维GIS软件对比
  8. python中random模块
  9. Android创建Excel表格
  10. 新手Python爬虫教学(Request+BeautifulSoup)