Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
KOJ 0002 Extended FizzBuzz 解説
Search
kagamiz
March 29, 2013
Programming
150
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
KOJ 0002 Extended FizzBuzz 解説
OkNCT-ICT 2013 春合宿 Day 5 (らしい) で解説したもの.
kagamiz
March 29, 2013
More Decks by kagamiz
See All by kagamiz
KCS v2. の開発
kagamiz
0
290
internship final presentation
kagamiz
0
1.4k
internship-middle term presentation
kagamiz
0
1.2k
すうがくのまほう
kagamiz
0
380
ご当地料理の紹介
kagamiz
0
500
オンラインジャッジシステムの実装
kagamiz
0
1.2k
AOJ 0022 Maximum Sum Sequence 解説
kagamiz
1
1.6k
AOJ 0557 A First Grader 解説
kagamiz
0
1k
JOI2013 本選1 Illumination 解説
kagamiz
0
420
Other Decks in Programming
See All in Programming
Go 1.27 における memory allocation の高速化
andpad
0
160
Go言語とトイモデルで学ぶTransformerの気持ち / fukuokago23-transformer
monochromegane
0
170
<title><a id="</title>君はこのHTMLをパースできるか"></a></title> #雑LT_study
pizzacat83
0
140
【やさしく解説 設計編・中級 #6】良いアーキテクチャとは ~ 一本の登り道の、行き先 ~
panda728
PRO
0
210
人間の目はかわらない、だからJPEGは30年もつ
yuzneri
12
18k
Jindong: Introducing Declarative Haptics in Compose Multiplatform
l2hyunwoo
0
110
yield再入門 #phpcon
o0h
PRO
0
1k
PHP に部分適用が来るぞ!……ところで何それ?おいしいの? #phpcon / phpcon-2026
shogogg
0
630
Claude CodeとAgentCore Gatewayを繋ぐ際の認証認可 / Authentication and authorization when connecting Claude Code with AgentCore Gateway
har1101
2
270
ここ半年くらいでAIに作らせたR用ツール
eitsupi
0
370
変わらないものが、変わるものを決める — 意図駆動開発 × イベントソーシング × イミュータブル | What Doesn't Change Decides What Can — IDD × Event Sourcing × Immutability
tomohisa
0
1.5k
Terraform標準の組織で AWS CDKをどう使うか
mu7889yoon
1
500
Featured
See All Featured
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.7k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
540
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
850
Tell your own story through comics
letsgokoyo
1
1k
The untapped power of vector embeddings
frankvandijk
2
1.8k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Side Projects
sachag
455
43k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.3k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
450
Crafting Experiences
bethany
1
250
Transcript
KOJ 0002 Extended FizzBuzz 解説 @kagamiz
問題の概要 • 数字 N と発言 S が与えられます . • N
が 3 の倍数なら Fizz, 5 の倍数なら Buzz, 3 の倍数かつ 5 の倍数なら FizzBuzz と出力 . そうじゃなければ N を そのまま出力 . • S が上記の基準とおりなら YES, そうでなければ NO を出力 . • N 10^100 ≦
N 10^100 ≦ • int 型や long long 型 ,
__int64 型で整数を入力→死 • 文字列として N だったり S だったりを読み込もう .
文字列として入力できた (AA 略 ) • どうやって比較しよう (AA 略 ) •
if (N % 3 == 0) (AA 略 ) • Compile Error (AA 略 ) • ▂▅▇█▓▒░('ω') █▇▅▂ ░▒▓ うわああああ
倍数条件 • 数 x が 3 の倍数 <=> 数 x
の各桁の和が 3 の倍数 • 数 x が 5 の倍数 <=> 数 x が 5 か 0 で終わる • これを判定すれば良いのであった ( 完 )
Let's 実装 • 数 x が 3 の倍数 <=> 数
x の各桁の和が 3 の倍数 for ( すべての桁 ): S ← S + 桁 i if (S が 3 の倍数 ) 数 x は 3 の倍数 • 数 x が 5 の倍数 <=> 数 x が 5 か 0 で終わる if ( 最後の桁が 0 か 5) 数 x は 5 の倍数
ちなみに • この問題は , 合同式というものの性質を知っていれば , 倍数条件を考えずに任意の数 A と B
で同じ事が出来 ます . • 練習問題 => Extended Extended FizzBuzz (KOJ 0004) http://koj.cms.am/show.php?p=4 (japlj さんの出題 )