博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Lightning Lessons 史上最蛋疼的英文题
阅读量:6708 次
发布时间:2019-06-25

本文共 4717 字,大约阅读时间需要 15 分钟。

Lightning Lessons
Time Limit: 5000ms, Special Time Limit:12500ms, Memory Limit:32768KB
Total submit users: 8, Accepted users: 8
Problem 12545 : No special judgement
Problem description
Zeus wrung his hands nervously. “I’ve come to you because I agreed to duel Thor in the upcoming Godfest. You’re good in a fight, Raiden; you’ve got to help me!”
Raiden, smiling thinly beneath the rim of his hat, replied, “What help could I provide a god as mighty as yourself? Your thunderbolts are the stu? of legends!” Zeus looked down and stammered, “I’ve...I’ve been lucky. I don’t know how the thunderbolts actually work. Sometimes I turn my foe into a charred heap, but other times...weird stu? happens. If Apollo hadn’t convinced the bards to keep my secret, I’d be a laughingstock.”
Raiden raised his eyebrows and asked, “Weird stu??” Zeus looked up and took a deep breath.“Sometimes it just fizzles out. Other times it rolls up and turns into a...a bunny.” Raiden burst out laughing. “A bunny! That’s some chi you’ve got there.” As Zeus began to redden, Raiden held up his hand and said, “Don’t worry, I’ll help you out.”
Raiden went on to explain. “A thunderbolt is a sequence of chi pivots, or ‘zigs and zags’ as the mortals call them. Each pivot has an integer amplitude—”
“Yes, I know that much.”, Zeus interrupted. “But lightning is lively and unpredictable. The amplitudes go all random once the bolt hits!”
“Not all that flickers is flame. If you watch the bolt closely, you’ll see it goes through ‘cycles’,and gets shorter by one pivot each cycle. When the bolt cycles, each successive pivot’s amplitude is decreased by the amplitude of its predecessor from the end of the previous cycle, and the first pivot vanishes. If a bolt ever reaches a state of all zero amplitudes, it converges and zaps its target with power proportional to the number of preceding cycles. Your ‘weird stu?’ happens only when a bolt cycles down to a single non-zero amplitude. A positive amplitude just fizzles out into waste heat, but negative amplitudes produce odd low-entropy states. It’s the latter you’ve seen hopping away in the midst of battle.”
Help Zeus avoid embarrassment by writing a program that predicts how powerful a given bolt will be if it converges, or what will happen to it if it diverges.
Input
The first line of input contains a single positive integer N which denotes how many lightning bolt follow. Each bolt is specified by a line beginning with an integer M (0 < M ≤ 20), followed by M space-delimited integers denoting the initial amplitudes of each successive pivot. No initial amplitude will have an absolute value larger than 1000.
Output
For each bolt that converges, output the letter “z” repeated P times, where P is the number of cycles encountered before the bolt converges, followed by the string “ap!” (the all-zero cycle does not count toward P).
For each bolt that fails to converge, output “*fizzle*” if the final amplitude was positive,“*bunny*” if it was negative.
Sample Input
42 1 15 1 3 6 10 155 1 2 4 8 162 1 0
Sample Output
zap!zzzap!*fizzle**bunny*
Problem Source
2011 Pacific Northwest Region Programming Contest

其实就看 If you watch the bolt closely, you’ll see it goes through ‘cycles’,and gets shorter by one pivot each cycle. When the bolt cycles, each successive pivot’s amplitude is decreased by the amplitude of its predecessor from the end of the previous cycle, and the first pivot vanishes. If a bolt ever reaches a state of all zero amplitudes, it converges and zaps its target with power proportional to the number of preceding cycles. Your ‘weird stu?’ happens only when a bolt cycles down to a single non-zero amplitude. A positive amplitude just fizzles out into waste heat, but negative amplitudes produce odd low-entropy states. 这一段就可以了,模拟一遍,每一次拿后一个数减去前一个数,直到出现了整个序列为0,要是最后的一个数不为零的话,那么根据正负数来判定输出。

代码如下:

#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;int N, seq[2][25];bool allz(int x) { for (int i = x; i <= N; ++i) { if (seq[0][i] != 0) { return false; } } return true;}void solve() { int sta = 2; if (allz(1)) { puts("ap!"); return; } while (sta <= N) { for (int i = sta; i <= N; ++i) { seq[0][i] -= seq[1][i-1]; } memcpy(seq[1], seq[0], sizeof (seq)); if (allz(sta)) { for (int j = 2; j <= sta; ++j) { putchar('z'); } puts("ap!"); return; } ++sta; } if (seq[0][N] < 0) puts("*bunny*"); else puts("*fizzle*");}int main(){ int T; scanf("%d", &T); while (T--) { scanf("%d", &N); for (int i = 1; i <= N; ++i) { scanf("%d", &seq[0][i]); } memcpy(seq[1], seq[0], sizeof (seq[0])); solve(); } return 0;}

转载地址:http://rqnlo.baihongyu.com/

你可能感兴趣的文章
用Python的 __slots__ 节省9G内存
查看>>
产品经理到底是要做全职保姆式,还是要做合作伙伴式?
查看>>
如何安装 Debian 的非 systemd 复刻版本 Devuan Linux
查看>>
《C++ 开发从入门到精通》——2.2 分析C++的程序结构
查看>>
《像计算机科学家一样思考Python》——3.12 为什么要有函数
查看>>
德国队的大数据策略|虽然被淘汰了但是人家准备很充分啊
查看>>
一个小型数据库的核心组件
查看>>
码农如何快速打造一个有设计感的网站
查看>>
你应该知道的人工智能三大分类
查看>>
《Unity 游戏案例开发大全》一6.2 游戏的策划及准备工作
查看>>
《JavaScript设计模式》——9.2 Module(模块)模式
查看>>
《企业大数据系统构建实战:技术、架构、实施与应用》一第3章 企业大数据解决方案3.1 企业大数据解决方案实现方式...
查看>>
Linux下的七个类Dropbox同步工具推荐
查看>>
非ROOT实现静默安装的一些思考与体会,AIDL获取IPackageManager,反射ServiceManager,系统签名...
查看>>
如何快速搭建钉钉微应用?
查看>>
《C语言及程序设计》实践参考——翻转数组
查看>>
Android 仿百合网超火爆社交app首页滑动效果
查看>>
Sublime Text 3 全程详细图文
查看>>
小心FOR IN遍历数组
查看>>
移动Web开发的bug及解决方案
查看>>