Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
2012/11/16 問題1
Search
mizti
November 18, 2012
550
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
2012/11/16 問題1
mizti
November 18, 2012
More Decks by mizti
See All by mizti
CutSticks.pdf
mizti
0
660
Maze Maker
mizti
0
630
「銀将ご乱心」
mizti
0
990
paint.pdf
mizti
1
650
kaibun.pdf
mizti
0
660
dfs1.pdf
mizti
0
610
問題1. 解答例
mizti
0
510
Featured
See All Featured
Game over? The fight for quality and originality in the time of robots
wayneb77
1
310
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.5k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
410
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
440
Building AI with AI
inesmontani
PRO
1
1.3k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
Scaling GitHub
holman
464
140k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1.1k
Build your cross-platform service in a week with App Engine
jlugia
234
19k
Odyssey Design
rkendrick25
PRO
2
870
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
570
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Transcript
問題1.ポーの惑星 イントロダクション イントロダクション イントロダクション イントロダクション: あなたがある朝目覚めるとあなたは見知らぬ惑星にいました。この惑星では四 則演算の書き方が地球とは異なるようです。 地球で 3 +
6 と書くはずのところでは (+ 3 6)と演算子を最初に書いて、それを( ) で括るようです。 また、9 – ( 2 + 1) は (- 9 (+ 2 1 ) ) となるようです。 この惑星の科学者やビジネスマンは長い長い式の計算に日々追い立てられ、苦 しんでいるようでした。 あなたはPCを持ったままこの惑星に来たようです。せっかくなのでこの惑星の人 たちのために、式の自動的に計算を行なってあげるプログラムを作ってあげま しょう。
問題1.ポーの惑星 • Input: 入力は以下のような形式の一行のテキストからなる式です。 • 数字 • + - *
の3種類の演算子 • ( ) および半角スペース から構成され、以下のように記述されています。 ( + 4 9 ) あるいは ( - 9 (+ 11 300)) すなわち、式は(演算子 式または数字 式または数字) という方法で記載されてい ます。 数字は-1000から1000の間であり、数字と数字の間、数字と演算子は1文字以 上の半角スペースで分かたれています。カッコと数字の間、カッコとカッコの間は スペースで区切られているとは限りません。 • Output: 各入力に対し,計算の結果を1行に出力してください。 それ以外の余計な文字を 含んではいけません。答えが負数であることはあり得ます。
問題1.ポーの惑星 Sample Input: (+ 6 8) Sample Output: 14 Sample
Input: (+ 5 (- 8 3)) Sample Output: 10 Sample Input: (+ (* (- 9 4) 8) (- 8 3)) Sample Output: 45 Sample Input: (* (- 9 20) (+ 7 (- 999 108)) ) Sample Output: -9878 できたら、
[email protected]
まで送付お願いします。 実行イメージ # cat input.txt (- 8 3) # cat input.txt | ruby a.rb 5 標準入力はRubyなら STDIN.gets.chomp などで拾えます。 (STDIN.getsは改行コードが 入ってしまうためchompが必要)