SlideShare a Scribd company logo
1 of 6
Download to read offline
choi@startlink.io
https://www.acmicpc.net/problem/10986
• N 	
   	
  A1,	
  A2,	
  …,	
  AN	
  
• 	
   	
   	
   	
  M 	
   	
   	
   	
   	
  
• ,	
  Ai	
  +	
  …	
  +	
  Aj 	
  M 	
   	
   	
  (i,	
  j) 	
   	
  
• 1	
  ≤	
  N	
  ≤	
  106	
  
• 2	
  ≤	
  M	
  ≤	
  103	
  
• 0	
  ≤	
  Ai	
  ≤	
  109
https://www.acmicpc.net/problem/10986
• 	
   	
   	
  N^2 	
  
• O(N^2)	
  =	
  (10^6)^2	
  =	
  10^12	
  	
  
• 10^12	
  ≥	
  1 	
  
• !
	
  
https://www.acmicpc.net/problem/10986
• Si	
  =	
  A1	
  +	
  …	
  +	
  Ai	
   	
   	
  
• Ai +	
  …	
  +	
  Aj =	
  Sj – Si-­‐1
• (Ai +	
  …	
  +	
  Aj)	
  %	
  M	
  =	
  (Sj – Si-­‐1)	
  %	
  M
• (Ai +	
  …	
  +	
  Aj)	
  %	
  M	
  ==	
  0 	
   	
   	
   	
   	
  
• (Sj – Si-­‐1)	
  %	
  M ==	
  0	
   	
   	
  
• 	
   	
  0 	
   	
  
• Sj	
  %	
  M	
  ==	
  Si-­‐1	
  %	
  M	
   	
   	
   	
  
https://www.acmicpc.net/problem/10986
• 	
   	
  
• Sj %	
  M	
  ==	
  Si-­‐1 %	
  M
• 	
   	
  (i,	
  j)	
   	
   	
   	
   	
   .	
  
• cntk 	
  Si	
  %	
  M	
  ==	
  k	
   	
  i 	
   	
   	
  
• 0	
  ≤	
  k	
  <	
  M 	
  k 	
   	
  	
  
• cntk	
  *	
  (cntk	
  -­‐	
  1)	
  /	
  2	
   	
   	
   	
   .	
  
https://www.acmicpc.net/problem/10986
• https://gist.github.com/Baekjoon/6d45e5ef5d7eed6039b5	
  
	
  

More Related Content

Similar to Baekjoon Online Judge 10986번 풀이

Attention-Based Adaptive Selection of Operations for Image Restoration in the...
Attention-Based Adaptive Selection of Operations for Image Restoration in the...Attention-Based Adaptive Selection of Operations for Image Restoration in the...
Attention-Based Adaptive Selection of Operations for Image Restoration in the...MasanoriSuganuma
 
Al Fazl International 2nd January 2015
Al Fazl International 2nd January 2015Al Fazl International 2nd January 2015
Al Fazl International 2nd January 2015muzaffertahir9
 
Al Fazl International - 4th March 2016 Weekly UK
Al Fazl International - 4th March  2016 Weekly UKAl Fazl International - 4th March  2016 Weekly UK
Al Fazl International - 4th March 2016 Weekly UKmuzaffertahir9
 
Review: Cyrus, Samii, Laura Paler, and Sarah Zukerman Daly. 2016. “Retrospect...
Review: Cyrus, Samii, Laura Paler, and Sarah Zukerman Daly. 2016. “Retrospect...Review: Cyrus, Samii, Laura Paler, and Sarah Zukerman Daly. 2016. “Retrospect...
Review: Cyrus, Samii, Laura Paler, and Sarah Zukerman Daly. 2016. “Retrospect...Jaehyun Song
 
音響信号に対する異常音検知技術と応用
音響信号に対する異常音検知技術と応用音響信号に対する異常音検知技術と応用
音響信号に対する異常音検知技術と応用Yuma Koizumi
 
Festival Universitário de Surf 2014
Festival Universitário de Surf 2014Festival Universitário de Surf 2014
Festival Universitário de Surf 2014Mari Peixoto
 
Festival Universitário de Surf 2014
Festival Universitário de Surf 2014Festival Universitário de Surf 2014
Festival Universitário de Surf 2014ibrasurf
 
Nouveaux services, nouveaux workflows et François Abbe Mesclado
Nouveaux services, nouveaux workflows et François Abbe MescladoNouveaux services, nouveaux workflows et François Abbe Mesclado
Nouveaux services, nouveaux workflows et François Abbe MescladoMarc Bourhis
 
Наибольшая общая мера: 2500 лет
Наибольшая общая мера: 2500 летНаибольшая общая мера: 2500 лет
Наибольшая общая мера: 2500 летsixtyone
 
Companies act kenya.pdf
Companies act kenya.pdfCompanies act kenya.pdf
Companies act kenya.pdfMeshack Mwangi
 
16º Circuito Paulista Universitário de surf 2014 - 1ª Etapa
16º Circuito Paulista Universitário de surf 2014 - 1ª Etapa16º Circuito Paulista Universitário de surf 2014 - 1ª Etapa
16º Circuito Paulista Universitário de surf 2014 - 1ª Etapaibrasurf
 
Location and Language in Social Media (Stanford Mobi Social Invited Talk)
Location and Language in Social Media (Stanford Mobi Social Invited Talk)Location and Language in Social Media (Stanford Mobi Social Invited Talk)
Location and Language in Social Media (Stanford Mobi Social Invited Talk)Ed Chi
 

Similar to Baekjoon Online Judge 10986번 풀이 (16)

Attention-Based Adaptive Selection of Operations for Image Restoration in the...
Attention-Based Adaptive Selection of Operations for Image Restoration in the...Attention-Based Adaptive Selection of Operations for Image Restoration in the...
Attention-Based Adaptive Selection of Operations for Image Restoration in the...
 
Prelude to halide_public
Prelude to halide_publicPrelude to halide_public
Prelude to halide_public
 
Python lists
Python listsPython lists
Python lists
 
Al Fazl International 2nd January 2015
Al Fazl International 2nd January 2015Al Fazl International 2nd January 2015
Al Fazl International 2nd January 2015
 
Al Fazl International - 4th March 2016 Weekly UK
Al Fazl International - 4th March  2016 Weekly UKAl Fazl International - 4th March  2016 Weekly UK
Al Fazl International - 4th March 2016 Weekly UK
 
Review: Cyrus, Samii, Laura Paler, and Sarah Zukerman Daly. 2016. “Retrospect...
Review: Cyrus, Samii, Laura Paler, and Sarah Zukerman Daly. 2016. “Retrospect...Review: Cyrus, Samii, Laura Paler, and Sarah Zukerman Daly. 2016. “Retrospect...
Review: Cyrus, Samii, Laura Paler, and Sarah Zukerman Daly. 2016. “Retrospect...
 
音響信号に対する異常音検知技術と応用
音響信号に対する異常音検知技術と応用音響信号に対する異常音検知技術と応用
音響信号に対する異常音検知技術と応用
 
機械学習と自動微分
機械学習と自動微分機械学習と自動微分
機械学習と自動微分
 
Festival Universitário de Surf 2014
Festival Universitário de Surf 2014Festival Universitário de Surf 2014
Festival Universitário de Surf 2014
 
Festival Universitário de Surf 2014
Festival Universitário de Surf 2014Festival Universitário de Surf 2014
Festival Universitário de Surf 2014
 
Delta5 Summary
Delta5 SummaryDelta5 Summary
Delta5 Summary
 
Nouveaux services, nouveaux workflows et François Abbe Mesclado
Nouveaux services, nouveaux workflows et François Abbe MescladoNouveaux services, nouveaux workflows et François Abbe Mesclado
Nouveaux services, nouveaux workflows et François Abbe Mesclado
 
Наибольшая общая мера: 2500 лет
Наибольшая общая мера: 2500 летНаибольшая общая мера: 2500 лет
Наибольшая общая мера: 2500 лет
 
Companies act kenya.pdf
Companies act kenya.pdfCompanies act kenya.pdf
Companies act kenya.pdf
 
16º Circuito Paulista Universitário de surf 2014 - 1ª Etapa
16º Circuito Paulista Universitário de surf 2014 - 1ª Etapa16º Circuito Paulista Universitário de surf 2014 - 1ª Etapa
16º Circuito Paulista Universitário de surf 2014 - 1ª Etapa
 
Location and Language in Social Media (Stanford Mobi Social Invited Talk)
Location and Language in Social Media (Stanford Mobi Social Invited Talk)Location and Language in Social Media (Stanford Mobi Social Invited Talk)
Location and Language in Social Media (Stanford Mobi Social Invited Talk)
 

Recently uploaded

How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 

Recently uploaded (20)

How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 

Baekjoon Online Judge 10986번 풀이