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
KOJ 0002 Extended FizzBuzz 解説
Search
kagamiz
March 29, 2013
Programming
160
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
Transcript
7 slides
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 さんの出題 )
More Decks by kagamiz
See All by kagamiz
KCS v2. の開発
kagamiz
0
300
internship final presentation
kagamiz
0
1.4k
internship-middle term presentation
kagamiz
0
1.2k
すうがくのまほう
kagamiz
0
390
ご当地料理の紹介
kagamiz
0
510
オンラインジャッジシステムの実装
kagamiz
0
1.3k
AOJ 0022 Maximum Sum Sequence 解説
kagamiz
1
1.6k
AOJ 0557 A First Grader 解説
kagamiz
0
1k
JOI2013 本選1 Illumination 解説
kagamiz
0
430
Other Decks in Programming
See All in Programming
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
1.7k
Web3Dライブラリを作ってVue Custom Rendererの仕組みを理解しよう / lets learn vue custom renderer by making 3d library
drumath2237
1
130
Будущее локальных LLM – Алексей Голобурдин, PythoNN
sobolevn
0
120
AI時代のシニアエンジニアとは
yosuke_furukawa
PRO
15
11k
Vue.jsで作る空間解析アプリとCapacitorプラグインのData Bridge
hal_spidernight
1
170
graphql-ruby を Spinel で速くしようとした話
mtsmfm
0
140
Goコンパイラを作ってGoをもっと理解する / Build a Go compiler to better understand Go
ikura_hamu
0
130
Spec-Driven Development - Why Vaadin Is the Perfect Fit
simas
PRO
0
250
AmebaブログはKMPから卒業します
kmars0605
0
350
AI時代のFlutter品質設計 — アプリ品質を守るQuality Layers
omatty198
0
370
AI Augmentation Techniques with Liberty
ivargrimstad
1
460
Secure Your Coding Agent Like It’s Malware (v1.5) 🇬🇧 @Code.talks 2026
richargh
0
140
Featured
See All Featured
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.9k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
Why Our Code Smells
bkeepers
PRO
340
58k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3.1k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
1
310
Un-Boring Meetings
codingconduct
0
490
The World Runs on Bad Software
bkeepers
PRO
72
12k
Building an army of robots
kneath
307
47k
Ruling the World: When Life Gets Gamed
codingconduct
0
440
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
980
SEO for Brand Visibility & Recognition
aleyda
0
4.9k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
12k