krvangala98
BAN USER
- 10of 10 votes
AnswersYou want to create a staff to use in your martial arts training, and it has to meet some specific requirements.
- krvangala98 in United States
1. You want it to be composed of two smaller staves of equal length so that you can either use it as a single staff or as two smaller ones.
2. You want the full sized staff's center of gravity to be exactly in the middle of the staff.
You have a very, very long branch from which you can cut the pieces for your staff. The mass of the branch varies significantly throughout it, so you use just any two pieces of the same length. Given a description of the mass throughout the branch, determine the longest staff you can make, then return three integers on a single line, the first two indicating the first index of each half-staff, and the third indicating the length of each half-staff.
The input will be given on a single line as a string of digits [1-9], each digit representing the mass of a section of the branch. All sections are the same size and the maximum length of the string is 500. Here is an example:
41111921111119
11119 11119
If the indicated sections are cut from the branch they will satisfy your requirements. They are both the same length, and they can be put together as either 9111111119 or 1111991111, both of which have a center of gravity exactly in the center of the staff.
Center of gravity can be determined by taking a weighted average of the mass of each section of the staff. Given the following distances and masses:
Distance: 12345678
Mass: 22241211
Sum of the mass of each section: 2 + 2 + 2 + 4 + 1 + 2 + 1 + 1 = 15
Weighted sum of the masses:
2*1 + 2*2 + 2*3 + 4*4 + 1*5 + 2*6 + 1*7 + 1*8 = 60
Weighted sum / regular sum = 60 / 15 = 4
This means that the center of mass is in section 4 of the staff. If we wanted to use this staff the center of gravity would need to be (8+1)/2 = 4.5.
Here is an example problem:
131251141231
---- ----
If we take the sections indicated we get 1312 and 1231. By reversing the first one and putting them together we get 21311231
Sum of the mass of each section: 2 + 1 + 3 + 1 + 1 + 2 + 3 + 1 = 14
Weight sum of the masses:
2*1 + 1*2 + 3*3 + 1*4 + 1*5 + 2*6 + 3*7 + 1*8 = 63
Weighted sum / regular sum = 63 / 14 = 4.5
This puts the center of mass exactly in the center of the staff, for a perfectly balanced staff. There isn't a longer staff that can be made from this, so the answer to this problem is
0 8 4
Because the half-staves begin at indices 0 and 8 (in that order) and each is of length 4.| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm
RepAbigailFlores, AT&T Customer service email at A9
I have outstanding creative thinking skills that are helpful for overcoming issues in writing and for coming up with new ...
RepSusanHonda, Analyst at A9
I meet with clients to negotiate terms and prices on sales agreements, draw up the contract, and ensure the documents ...
RepLeenFawn, Analyst at A9
I have experience in managing all facets of front office administration, including handling multi-line phone systems, managing schedules, and maintaining ...
Repkristenjjimenezk, Analyst at ADP
We Statistical assistants establish and check numerical facts in many different areas of business, government, and industry. Right now I ...
RepAtiDavis, Analyst at 8x8
I am a skilled construction worker with 3+ years of experience erecting structures according to blueprints and safely utilizing power ...
RepVictoriaMitchell, Animator at ABC TECH SUPPORT
I am an Analysis Manager.I have 7 years of experience in leveraging data analysis to develop. And I love ...
RepBeccaElyn, Accountant at ADP
Basic literacy is generally a requirement for order-filling positions, because order fillers need to be able to understand written lists ...
Repsheilabjones023, abc at 8x8
Hello,I am a Press operator. I completed my degree from Chicago and now am a Press operator in Lechmere ...
RepKelseyOliver, Security Analyst at Accenture
Kelsey , a Storyboard Artist with demonstrated experience in developing visual templates, storyboards, and sketches. The Award winner (2020) for storyboard ...
RepJesseCarlson, Cloud Support Associate at Alfa Chemaical Laboratory
Jesse , a video producer with 4 years of experience in running production processes from start to finish. Excellent at client ...
RepChloeKing, Accountant at A9
I like to snowboard, rock climb, and water ski. I volunteer some of my time each spring and summer to ...
Replauriedfrankel8754, Analyst at 247quickbookshelp
Hey, I am a Data typist. I love this work. My hobby like write story and different types of article ...
Repjanetjgonzales87, Android Engineer at 247quickbookshelp
Hello I am an internet developer. And I am very much sorry to travel and read some interesting books. Right ...
RepEarlEvans, Android Engineer at ASAPInfosystemsPvtLtd
EarlEvans a Material dispatching working at Lazysize . It's been almost 5 years since I started working here . Online istikhara ...
RepEstaaMoore, Accountant at A9
I am working as a cashier. I quickly and accurately counted drawers at the start and end of each shitt ...
RepJanaSmith, Integration Software Engineer at Deloitte Consulting LLP
I am Jana , an order processor with my strong work ethic. My interests are listening to music which helps me ...
RepYaniraBryant, Accountant at CGI-AMS
I am Yanira , a writer by fate. Went from writing for media outlets to exploring the world of content creation ...
RepMaryLopal, Applications Developer at Coupondesh
I am a 41 year old dermatologist in Saginaw USA. I do like to face the challenges . I'm active ...
Repcloptonchirsty, Android Engineer at 8x8
Hello, I am an Organic chemist and my all study and degree is complete from New York.Apart from this ...
RepDavlinaSmith, abc at ADP
I am a current residential landlord with 5 years’ experience looking to expand into commercial property management.Former florist by ...
RepKeciaFowler, Area Sales Manager at Auto NInja
My name is Kecia and I am a results-oriented Real Estate Appraiser Trainee with a strong determination to perform great ...
RepHenryLee, Accountant at AMD
I am a creative and 5 years experienced beautician. I have experience with most cosmetology tools, including razors, nail clippers ...
RepAbbyCox, abc at 8x8
I am an experienced, officially certified driving instructor. Excellent driver with a great safety record. Encyclopedic knowledge of traffic rules ...
RepGladysHenley, Blockchain Developer at ASU
Gladys , a Staffing Consultant adept at managing the whole lifecycle of candidate recruitment, organizing job fairs, workshops, and webinars, and ...
RepEvaSanchez, Animator at Abs india pvt. ltd.
Eva , Manufacturing Worker with 3+ years of experience working in Dynatronics . Went for traveling around the world and gets to ...
Repmirezwanda, Android test engineer at Arista Networks
Computer database administrator with 3+ years of experience working in Gamma Realty . I often plan security measures, making sure that ...
RepNancyCramer, Financial Software Developer at Abs india pvt. ltd.
Nancy , an administrative assistant at Libera Inc. to leverage organizational and research skills to support internal and external prayer to ...
Repjoshuacmurphy36, Animator at ABC TECH SUPPORT
Hey,I am an agricultural engineer. And I love this job. We Agricultural Engineers do engineering design and planning in ...
RepAileen Kate, HR Executive Trainee at Bankbazaar
Aileen , a game designer with 4+ years of experience in a creative yet deadline-driven environment. Eager to join The Rock ...
RepAasiHarris, abc at 8x8
I am a creative designer with innovative ideas and a unique approach to visuals. I am also a skilled painter ...
RepGalateeLabrie, Accountant at ABC TECH SUPPORT
Bonjour, je suis organisateur de congrès. toutes mes études terminées depuis la france. et je suis actuellement en train de ...
RepDarikaLee, Applications Developer at ADP
I am a knowledgeable and performance-driven Network Administrator with a comprehensive background in managing servers, maintaining software/hardware, performing backups ...
RepElizabethMaxim, Android test engineer at AMD
A financial economist is responsible for the production and distribution of goods and services. We are also responsible for collecting ...
Repggroverwmiller, Android Engineer at 247quickbookshelp
Hello I am a Budget officer with 5 years of experience. The Budget Officer implements budgeting and financial record keeping ...
RepRomiTerry, Member Technical Staff at Cleartrip.com
Romi , a Dynamic Property Manager highly regarded for increasing and maintaining a high level of occupancy adhering to all regulations ...
RepRianaHudge, Integration Software Engineer at Autoportal.com
Riana , a caring and compassionate Home Health Aide with more than 7 years of experience in providing daily living and ...
Replinhhonibh, Animator at ABC TECH SUPPORT
I am an experienced, officially certified driving instructor. Excellent driver with a great safety record. Encyclopedic knowledge of traffic rules ...
RepAmyuDiaz, abc at 8x8
Professional cost accountant with several years of experience in accounting tasks such as maintaining inventory, calculating liability, budgeting labor costs ...
RepTracieHoutz, Animator at ADP
I am Tracie , currently the Associate Art Director at Curtie , where I have an excellent reputation for my strong conceptual ...
RepMairaSmith, Integration Software Engineer at Absolute Softech Ltd
MairaSmith , an Quality Control Assistant with a record of success in developing and implementing new quality control policies and procedures ...
RepKeilyPrice, Applications Developer at 247quickbookshelp
I am a creative chef with 5 years of experience making the kitchen run efficiently. Collaborated with marketing specialists to ...
RepBravoDwayne, Blockchain Developer at ADP
Bravo , a Broker Assistant skilled at assisting financial advisors and stockbrokers in any tasks as required. As I love to ...
RepDeevaAllen, Android Engineer at Absolute Softech Ltd
I am Deeva, currently a Credit Card Authorizer , where I assess authorization requests for credit limit increases, and handle lost ...
RepNorinaKen, iOS Developer at ASU
Norina, a certified ENP and Emergency Medical Dispatcher with 7 + years of work experience got the opportunity to join the ...
RepJeremyBrett, Consultant at Capgemini
Jeremy , a Business Administrator with more than 4 years experience helping companies from various industries plan, organize and control specific ...