praveend806
BAN USER
- 0of 0 votes
AnswersYou are given an array A = [1, 2, 3, ..., n]:
- praveend806 in United States
How many sequences (S1) can you get after exact k adjacent swaps on A?
How many sequences (S2) can you get after at most k swaps on A?
An adjacent swap can be made between two elements of the Array A, A[i] and A[i+1] or A[i] and A[i-1].
A swap otherwise can be between any two elements of the array A[i] and A[j] ∀ 1 ≤ i, j ≤ N, i ≠ j.
Input Format
First and only line contains n and k separated by space.
Output Format
Output S1 % MOD and S2 % MOD in one line, where MOD = 1000000007.
Constraints
1 ≤ n ≤ 2500
1 ≤ k ≤ 2500
Sample Input
3 2
Sample Output
3 6
Explanation
Original array: [1, 2, 3]
1. After 2 adjacent swaps:
We can get [1, 2, 3], [2, 3, 1], [3, 1, 2] ==> S1 == 3
2. After at most 2 swaps:
1) After 0 swap: [1, 2, 3]
2) After 1 swap: [2, 1, 3], [3, 2, 1], [1, 3, 2].
3) After 2 swaps: [1, 2, 3], [2, 3, 1], [3, 1, 2]
==> S2 == 6| Report Duplicate | Flag | PURGE
Achieve Internet Computer Scientist Algorithm - 1of 1 vote
AnswersGiven a tree having N vertices and N-1 edges where each edges is having one of either red(r) or black(b) color. I need to find how many triplets(a,b,c) of vertices are there, such that on the path from vertex a to b, vertex b to c and vertex c to a there is atleast one edge having red color.
- praveend806 in India
It should be noted that (a,b,c), (b,a,c) and all such permutation will be considered as the same triplets.
EXAMPLE : Let N=5 and edges with colors are as follow :
1 2 b
2 3 r
3 4 r
4 5 b
Here answer will be 4.
EXPLANATION : (2,3,4) is one such triplet because on all paths i.e 2 to 3, 3 to 4 and 2 to 4 there is atleast one edge having read color. (2,3,5), (1,3,4) and (1,3,5) are such other triplets.| Report Duplicate | Flag | PURGE
Hi5 Student student Algorithm
RepPennyRMullins, xyz at Aspire Systems
I am a creative Interior Designer with 2+ years of experience building customized solutions for residential and commercial clients. Intuitively ...
RepDustinSeals, Accountant at 247quickbookshelp
I am Dustin . Speech-language pathologist in Standard Brands Paint Company. I diagnose and swallow problems. I work with both children ...
Replarenccabral, Title searcher at Fisher Foods
In real estate business and law, a title search or property title search is the process of examining public records ...
Repfrancesdpayne, AT&T Customer service email at Cavium Networks
I am Frances Payne from Jacksonville, United States. I am working as a Rental manager in Magna Gases company. I ...
Replillyalaird, Associate at Achieve Internet
I am Lilly from Eau Claire USA, I am working as a manager in a Best products company. My interest ...
RepSpent high school summers donating toy monkeys in Minneapolis, MN. At the moment I'm building glue in Edison, NJ ...
Repleroydperry, Backend Developer at AppNexus
I am from the USA. I am 27 year old. I drive the train for my company Monk Home Funding ...
Reprickyjwerner, Area Sales Manager at Accolite software
I am Ricky, I live in Houston USA, I am working as a distribution manager in Total Serve company. I ...
RepJennyReimer, Dev Lead at Adobe
Badminton lover, coffee addict, guitarist, International Swiss style practitioner and TDC honorary member. Acting at the nexus of simplicity and ...
RepTinaaJohn, Cloud Support Associate at AMD
Hi,Everyone.I am an art teacher at Woodson Institute.Foster and encourage critical thinking and analysis about art and ...
Repdaysidbass, Junior programmer at AppPerfect
I have 5 years international experience working in the UK. I assist companies to gain greater value out of their ...
Repvickiwgerber, Member Technical Staff at Boomerang Commerce
I am Vicki From San Antonio USA, I am working as an Interior decorator in Golden Joy company. I have ...
Repverarfurman, Problem Setter at Cerberus Capital
I am Vera from Bullard USA, I am working as a Violin repairer in a Handyman company. My interest in ...
Replonnacribbs, DIGITAL MARKETING at Athena Health
I am a Market Research Manager responsible for selecting the appropriate research methodology and supporting techniques to meet a defined ...
Reptaniajclover, Analyst at Amdocs
Hi, I am Tania from Tuckahoe USA, I am working as a Public relations representative in Gamble-Skogmo company. I like ...
Repjuanktait, Blockchain Developer at ADP
I am Juan from Seattle, WA. I am working as a LAN administrator. I love music, reading historical books, and ...
Repangelwilley8, xyz at Asiatic Solutions
I am Angel J. Willey from Gurnee. I am working as a truck driver in Asiatic Solutions company. I also ...
RepSoccer lover, coffee addict, guitarist, International Swiss style practitioner and TDC honorary member. Acting at the nexus of simplicity and ...
Repharoldjmaloney, Accountant at ASU
Hi, I am a Computer systems administrator from texas. Experienced in running a wide variety of software development Company. Looking ...
Repomarcdei, Android Engineer at Abs india pvt. ltd.
I'm Omar. I am working as a Mail carrier in Manning's Cafeterias company. I love to learn and ...
Repannaharricks, Computer Scientist at ABC TECH SUPPORT
Hi, I am a Social worker to help people handle everyday life problems. I also assist people who have issues ...
Repsusanaminick, Research Scientist at CapitalIQ
I am Susan from Dallas, I am working as a Property manager in Kohl's Food Stores company. I love ...
Repjohnagragg0, cox customer service at Deloitte Consulting LLP
I am friendly, I am a hard worker, even through difficult circumstances, I want to know about How to identify ...
Repnyladsomerville, abc
Want to purchase best quality silencer at affordable price manufactured by top most trusted brand Innovative Arms.
Contact Stonefirearms now!
Rephoychrista, Blockchain Developer at ASU
Worked with Clients to guide them through the event details about copier leasing companies and served as their personal coordinator ...
Repdorarwoods, Kuwait airways reservations at Aspire Systems
I am an Application engineer in the network chef company. In my free time, I enjoy reading programming and technology ...
Repethelynfrose, Computer Scientist at 247quickbookshelp
Hello, I am Ethelyn and I live in Lake Worth, USA. I am working as a Dog Trainer and Dog ...
Repkennypmillerk, AT&T Customer service email at 247quickbookshelp
My name is Kenny and I am working as a trusted investor in Pittsburgh USA.I identify / set up a ...
Repalicegpopa, Apple Phone Number available 24/7 for our Customers at AMD
I am working as a U.S. marshal in Pro Property Maintenance. I want to write about I Want My ...
RepLuciaLuci, Animator at Barclays Capital
I am Lucia, a Neuropsychologist in Philadelphia USA . aiming to understand how behavior and cognition are influenced by brain function ...
Repkathimhoke, Product Security Engineer at Argus
Hi, I am Kathi from Mineola. I am working as an Identification clerk in a Tradewell company. I spent over ...
RepAmmoBoard, Employee at A9
The best online ammo shop to buy ammunition for your rifles, handguns & shotguns from top brands you like.
RepCarlERhodes, Cloud Support Associate at Baidu
I am an Engineering manager in Mosier USA. I am a freelance events coordinator and a lifetime entrepreneur. I want ...
its a tree
- praveend806 June 19, 2014