Download free for 30 days
Sign in
Upload
Language (EN)
Support
Business
Mobile
Social Media
Marketing
Technology
Art & Photos
Career
Design
Education
Presentations & Public Speaking
Government & Nonprofit
Healthcare
Internet
Law
Leadership & Management
Automotive
Engineering
Software
Recruiting & HR
Retail
Sales
Services
Science
Small Business & Entrepreneurship
Food
Environment
Economy & Finance
Data & Analytics
Investor Relations
Sports
Spiritual
News & Politics
Travel
Self Improvement
Real Estate
Entertainment & Humor
Health & Medicine
Devices & Hardware
Lifestyle
Change Language
Language
English
Español
Português
Français
Deutsche
Cancel
Save
Submit search
EN
Uploaded by
ShunsukeOtani1
35 views
桁DP入門
桁DPの入門スライドです
Education
◦
Read more
0
Save
Share
Embed
Embed presentation
Download
Download to read offline
1
/ 28
2
/ 28
3
/ 28
4
/ 28
5
/ 28
6
/ 28
7
/ 28
8
/ 28
9
/ 28
10
/ 28
11
/ 28
12
/ 28
13
/ 28
14
/ 28
15
/ 28
16
/ 28
17
/ 28
18
/ 28
19
/ 28
20
/ 28
21
/ 28
22
/ 28
23
/ 28
24
/ 28
25
/ 28
26
/ 28
27
/ 28
28
/ 28
More Related Content
PDF
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
by
OECD Directorate for Financial and Enterprise Affairs
PDF
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
by
SocialHRCamp
PDF
Storytelling For The Web: Integrate Storytelling in your Design Process
by
Chiara Aliotta
PDF
2024 State of Marketing Report – by Hubspot
by
Marius Sescu
PDF
2024 Trend Updates: What Really Works In SEO & Content Marketing
by
Search Engine Journal
PDF
Everything You Need To Know About ChatGPT
by
Expeed Software
PDF
Product Design Trends in 2024 | Teenage Engineerings
by
Pixeldarts
PDF
How Race, Age and Gender Shape Attitudes Towards Mental Health
by
ThinkNow
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
by
OECD Directorate for Financial and Enterprise Affairs
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
by
SocialHRCamp
Storytelling For The Web: Integrate Storytelling in your Design Process
by
Chiara Aliotta
2024 State of Marketing Report – by Hubspot
by
Marius Sescu
2024 Trend Updates: What Really Works In SEO & Content Marketing
by
Search Engine Journal
Everything You Need To Know About ChatGPT
by
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
by
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
by
ThinkNow
Featured
PDF
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
by
marketingartwork
PDF
Skeleton Culture Code
by
Skeleton Technologies
PDF
PEPSICO Presentation to CAGNY Conference Feb 2024
by
Neil Kimberley
PDF
Content Methodology: A Best Practices Report (Webinar)
by
contently
PPTX
How to Prepare For a Successful Job Search for 2024
by
Albert Qian
PDF
Social Media Marketing Trends 2024 // The Global Indie Insights
by
Kurio // The Social Media Age(ncy)
PDF
Trends In Paid Search: Navigating The Digital Landscape In 2024
by
Search Engine Journal
PDF
5 Public speaking tips from TED - Visualized summary
by
SpeakerHub
PDF
ChatGPT and the Future of Work - Clark Boyd
by
Clark Boyd
PDF
Getting into the tech field. what next
by
Tessa Mero
PDF
Google's Just Not That Into You: Understanding Core Updates & Search Intent
by
Lily Ray
PDF
How to have difficult conversations
by
Rajiv Jayarajah, MAppComm, ACC
PDF
Introduction to Data Science
by
Christy Abraham Joy
PDF
Time Management & Productivity - Best Practices
by
Vit Horky
PDF
The six step guide to practical project management
by
MindGenius
PDF
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
by
RachelPearson36
PDF
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
by
Applitools
PDF
12 Ways to Increase Your Influence at Work
by
GetSmarter
PDF
ChatGPT webinar slides
by
Alireza Esmikhani
PDF
More than Just Lines on a Map: Best Practices for U.S Bike Routes
by
Project for Public Spaces & National Center for Biking and Walking
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
by
marketingartwork
Skeleton Culture Code
by
Skeleton Technologies
PEPSICO Presentation to CAGNY Conference Feb 2024
by
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
by
contently
How to Prepare For a Successful Job Search for 2024
by
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
by
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
by
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
by
SpeakerHub
ChatGPT and the Future of Work - Clark Boyd
by
Clark Boyd
Getting into the tech field. what next
by
Tessa Mero
Google's Just Not That Into You: Understanding Core Updates & Search Intent
by
Lily Ray
How to have difficult conversations
by
Rajiv Jayarajah, MAppComm, ACC
Introduction to Data Science
by
Christy Abraham Joy
Time Management & Productivity - Best Practices
by
Vit Horky
The six step guide to practical project management
by
MindGenius
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
by
RachelPearson36
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
by
Applitools
12 Ways to Increase Your Influence at Work
by
GetSmarter
ChatGPT webinar slides
by
Alireza Esmikhani
More than Just Lines on a Map: Best Practices for U.S Bike Routes
by
Project for Public Spaces & National Center for Biking and Walking
桁DP入門
1.
桁DP入門 Shunsuke Otani
2.
桁DPとは N以下の整数で○○の条件を満たす数の個数 N以下の整数で○○の条件を満たす数の最大値 などの問題で使える桁ごとに分けて考える動的計画法
3.
例題1 Q:100未満の整数で3がつく数の個数は? int型→string型で 数字に3がつくか 全探索? 10ごとに3がつく数は 1増えていそうだから N/10? O(N)では間に合わない ことも…
4.
桁DPの考え方(1の桁に3がつく) 10 1 0 3を含む 3を含まない 1の桁10の桁 全部 10×1 =
10 10の桁の数字 ※箱には○桁目まで見た時の答えが入ります
5.
桁DPの考え方(1の桁に3がつかない) 9 0 81 9 3を含む 3を含まない 1の桁10の桁 3以外 9
× (10 - 1) = 81 10の桁の数字 9 × 1 = 9 ※箱には○桁目まで見た時の答えが入ります
6.
桁DPの考え方(結果を足す) 19 1 81 9 3を含む 3を含まない 1の桁10の桁 100未満(~99)の範囲を求めるため、10の桁まで考えればよい ※箱には○桁目まで見た時の答えが入ります
7.
つまり 先ほどの遷移 + 条件
= 桁DP
8.
条件!???
9.
例題だと… N <
100 この条件を先ほどの遷移に加えたい…
10.
例題2 Q:55以下の整数で3がつく数の個数は?
11.
例題2(1の桁に3がつく) 53を含む 3を含まない 1の桁10の桁 0 1 0 N < 50
N >= 50 && N <= 55 1×5(0,1,2,3,4) 1 1の桁10の桁 0 1 0 1×1(5) 3を含む 3を含まない
12.
例題2(1の桁に3がつかない) 93を含む 3を含まない 1の桁10の桁 36 0 9 N < 50
N >= 50 && N <= 55 9×4(0,1,2,4) 0 1の桁10の桁 5 0 5 5×1(5) 3を含む 3を含まない 9×1(3)
13.
例題2(結果) 143を含む 3を含まない 1の桁10の桁 36 1 9 N < 50
N >= 50 && N <= 55 1 1の桁10の桁 5 1 5 3を含む 3を含まない よって答えは 14 + 1 = 15
14.
しかし… 2桁までの遷移は簡単にプログラムで実装できる Nが3桁以上になった場合は…?
15.
N <= 255のとき
下の桁から見る場合 1. (0~5),(0~9)それぞれの3の個数をカウント 2. (0~55),(0~99)1を使い、それぞれの3の個数をカウント 3. (0~255)2を使い、3の個数をカウント もう少し簡単なアルゴリズムはないのか… 上の桁から見てみよう!
16.
例題2(10の桁に3がつく) 13を含む 3を含まない 1の桁10の桁 0 10 0 N < 50
N >= 50 && N <= 55 1×10(0~9) 0 1の桁10の桁 0 0 0 0×6(0~5) 3を含む 3を含まない
17.
例題2(10の桁に3がつかない) 03を含む 3を含まない 1の桁10の桁 4 4 36 N < 50
N >= 50 && N <= 55 4×9(0~2,4~9) 0 1の桁10の桁 1 1 5 1×5(0,1,2,4,5) 3を含む 3を含まない 4×1(3) 1×1(3)
18.
例題2(結果) 13を含む 3を含まない 1の桁10の桁 4 14 36 N < 50
N >= 50 && N <= 55 0 1の桁10の桁 1 1 5 3を含む 3を含まない よって答えは 14 + 1 = 15
19.
上の桁から見てみよう 前頁と同条件(N<=255)で上の桁から見たとき 1.
(0~1),(2)の3の個数をカウント 2. (0~24),(25)1を使い、それぞれの3の個数をカウント 3. (0~254),(255)2を使い、それぞれの3の個数をカウント 見る順番を変えるだけで考えやすくなった! これをどうやって実装すれば…
20.
未満Flagを導入 Nの制約がない場合の遷移 dp[digit(N)][2] (dp[桁数][3の有無]) 未満Flagを導入
dp[digit(N)][2][2] (dp[桁数][3の有無][N未満]) dp[i][*][0]には N未満となる数についての答え dp[i][*][1]には i桁目までNと同じ数についての答え
21.
未満Flagの具体例 *先ほどのdpから3の有無を除いて考える N =
12345 dp[3][1]:123○○未満となる数(0~12299) つまり(0~122)の範囲の3がつく数の個数 dp[3][0]:123○○となる数(12300~12345) つまり(123)の3がつく数の個数
22.
遷移を見てみる *先ほどのdpから3の有無を除いて考える N = 12345
dp[3][0](123○○)→dp[4][*]の遷移は… dp[4][0]への遷移は(123○○)→(1234○)より dp[4][0]= dp[3][0] dp[4][1]への遷移は(123○○)→(123(0~3)○)より dp[4][1]= dp[3][0]×4(0~3の個数)
24.
簡単な問題から 1~Nの整数の個数を桁DPで求めてみよう まずはdpテーブルを考えてみよう!
25.
DPテーブルは… dp[digit(N)][smaller(未満Flag)]
26.
解法例
27.
演習タイム 1. 0からNまでの整数で3が含まれる数の個数を桁dpで求めてみよう! 2. 0からNまでの整数で桁の和が3の倍数な数の個数を桁dpで求めてみよう!
28.
ご清聴ありがとうございました
Download