回答 1 已采纳 Russian nesting dolls are brightly painted hollow wooden figures. The dolls in a set have roughly the same shape, typically humanoid, but different sizes. When the set is assembled, the biggest doll contains the secondbiggest doll, the secondbiggest contains the thirdbiggest, and so on.
We can approximate the shape of a doll as a cylinder of height h, diameter d, and wall thickness w. Such a doll would have a hollow of height h2w and diameter d2w.
Boris and Natasha each has a set of dolls. The sets are nearly identical; each has the same number of dolls, which look the same but differ in their dimensions. Last night Boris and Natasha were playing with their dolls and left them in the living room. Their mother tidied them away, dumping them all in one box. Can you help Boris and Natasha separate their sets of dolls?
Input
Standard Input will consist of several test cases. The first line of each test case will contain n, the number of dolls in each set (1 = 2w > 0). A line containing 0 follows the last test case.
Output
For each test case, separate the dolls into two sets of nesting dolls such that, within each set, the dolls fit within each other, standing straight up, as described above. The first n lines of output should give the dimensions of the dolls in one set, in decreasing order by height. The next line should contain a single hyphen, "". The next n lines should give the dimensions of the dolls in the second set, also in decreasing order by height. There will always be a solution. If there are many solutions, any will do. Output an empty line between test cases.
Sample Input
3
100 100 3
97 97 3
94 94 3
91 91 3
88 88 3
85 85 3
5
100 100 1
97 97 3
98 98 1
96 96 1
94 94 1
92 92 1
90 90 1
88 88 1
86 86 1
84 84 1
0
Sample Output
100 100 3
94 94 3
88 88 3

97 97 3
91 91 3
85 85 3
100 100 1
98 98 1
96 96 1
94 94 1
92 92 1

97 97 3
90 90 1
88 88 1
86 86 1
84 84 1
回答 2 已采纳 As a doll master, Alice owns a wide range of dolls, and each of them has a number tip on it's back, the tip can be treated as a positive integer. (the number can be repeated). One day, Alice hears that her best friend Marisa's birthday is coming , so she decides to sent Marisa some dolls for present. Alice puts her dolls in a row and marks them from 1 to n. Each time Alice chooses an interval from i to j in the sequence ( include i and j ) , and then checks the number tips on dolls in the interval from right to left. If any number appears more than once , Alice will treat this interval as unsuitable. Otherwise, this interval will be treated as suitable.
This work is so boring and it will waste Alice a lot of time. So Alice asks you for help .
Input
There are multiple test cases. For each test case:
The first line contains an integer n ( 3≤ n ≤ 500,000) ,indicate the number of dolls which Alice owns.
The second line contains n positive integers , decribe the number tips on dolls. All of them are less than 2^311. The third line contains an interger m ( 1 ≤ m ≤ 50,000 ),indicate how many intervals Alice will query. Then followed by m lines, each line contains two integer u, v ( 1≤ u< v≤ n ),indicate the left endpoint and right endpoint of the interval. Process to the end of input.
Output
For each test case:
For each query, If this interval is suitable , print one line "OK". Otherwise, print one line ,the integer which appears more than once first.
Print an blank line after each case.
Sample Input
5
1 2 3 1 2
3
1 4
1 5
3 5
6
1 2 3 3 2 1
4
1 4
2 5
3 6
4 6
Sample Output
1
2
OK
3
3
3
OK
回答 1 已采纳 Problem Description
A doll vendor has just received a shipment of dolls from the factory. The vendor can only sell dolls in pairs, and have to ensure that in each pair one doll is K times as large as the other. What is the maximum number of pairs that the vendor can assemble? Each doll can only be sold one time. Now the vendor wants your help to solve this problem. Of course, he will give you 30% of the profit, so, what are you waiting for?
Input
There are multiple test cases.For each case the input contains two integers N (1<=50<=N) and K (1<=K<=25) in first line and N doll sizes (integers between 1 and 100000, inclusive) below, where N is the number of dolls. The doll sizes may separated by white spaces or newline.Input ends when N and K is 0.
Output
For each case, output the maximum number of pairss that the vendor can assemble in one line.
Sample Input
5 2
1 2 1 2 4
0 0
Sample Output
2
Hint: you can sell two pairs at most, {(1,2),(1,2)} or {(1,2),(2,4)}.
回答 1 已采纳
We're running sphinx on a midsized product database (10 mm records, 2gb) using the standard EXTENDED2 / SPH_RANK_PROXIMITY_BM25 approach. Speed is great, relevancy is spot on.
However we're running into increasing complaints from endusers who are searching with terms that are more complex than what our database has and thus getting no results.
For example, we have the product "KitchenAid Artisan 5Quart Mixers" while a common search is "KitchenAid Artisan 5Quart Stand Mixers brown". The result with our current settings is no match when we should be able to return the item we have.
We've tried using the MATCH_ANY sorting by @weight mode but relevancy goes completely sideways [think dolls and board games showing up] as sphinx picks up other products with individual words.
Is there a best practice way to build our query parameters that will allow for more open matching while still ranking off of proximity and word density?
Here is our current PHP API commands if that helps
$cl = new SphinxClient();
$cl>SetServer('1.23.4', 456);
$cl>SetMaxQueryTime(15000);
$cl>SetMatchMode(SPH_MATCH_EXTENDED2);
$cl>SetRankingMode(SPH_RANK_PROXIMITY_BM25);
$cl>SetArrayResult(true);
$cl>SetFilter('active', array(1));
$cl>SetSortMode(SPH_SORT_RELEVANCE, '@weight DESC, priced ASC');
$cl>SetLimits(intval($try), 1, 20, 500);
$cl>SetFieldWeights(array('ptitle' => 60, 'description' => 40));
$res = $cl>query($searchterm,"products");
回答 1 已采纳
I have this json file that I get from ebay api and I'm trying to echo it.
How can I reach specific values such as title, galleryURL, viewItemURL etc.
This is how I tried and getting error
<?php
$json = file_get_contents('ebay api url');
$obj = json_decode($json);
echo $obj> item[0]>title;
?>
I placed item[0] because usualy I recieve bunch of items inside json
And this is json file
{"findItemsIneBayStoresResponse":[{"ack":["Success"],"version":["1.13.0"],"timestamp":["20150303T22:06:11.764Z"],"searchResult":[{"@count":"1","item":[{"itemId":["121579650061"],"title":["McCall's
9119 18\" Doll PatternCarry Case and Accessories Carry Case Doll Trunk
"],"globalId":["EBAYUS"],"primaryCategory":[{"categoryId":["38057"],"categoryName":["Dolls,
Toys,
Animals"]}],"galleryURL":["http://thumbs2.ebaystatic.com/m/mBpbxhUvsUvTKYMVasM8xA/140.jpg"],"viewItemURL":["http://www.ebay.com/itm/McCalls911918DollPatternCarryCaseandAccessoriesCarryCaseDollTrunk/121579650061?pt=LH_DefaultDomain_0"],"paymentMethod":["PayPal"],"autoPay":["false"],"postalCode":["85260"],"location":["Scottsdale,AZ,USA"],"country":["US"],"storeInfo":[{"storeName":["Sew
Lovely
Patterns"],"storeURL":["http://stores.ebay.com/SewLovelyPatterns"]}],"shippingInfo":[{"shippingServiceCost":[{"@currencyId":"USD","value":"0.0"}],"shippingType":["FlatDomesticCalculatedInternational"],"shipToLocations":["Worldwide"],"expeditedShipping":["false"],"oneDayShippingAvailable":["false"],"handlingTime":["1"]}],"sellingStatus":[{"currentPrice":[{"@currencyId":"USD","value":"21.99"}],"convertedCurrentPrice":[{"@currencyId":"USD","value":"21.99"}],"sellingState":["Active"],"timeLeft":["P22DT22H41M24S"]}],"listingInfo":[{"bestOfferEnabled":["false"],"buyItNowAvailable":["false"],"startTime":["20150224T20:42:35.000Z"],"endTime":["20150326T20:47:35.000Z"],"listingType":["StoreInventory"],"gift":["false"]}],"returnsAccepted":["true"],"galleryPlusPictureURL":["http://galleryplus.ebayimg.com/ws/web/121579650061_1_0_1.jpg"],"condition":[{"conditionId":["1000"],"conditionDisplayName":["New"]}],"isMultiVariationListing":["false"],"topRatedListing":["false"]}]}],"paginationOutput":[{"pageNumber":["1"],"entriesPerPage":["1"],"totalPages":["117"],"totalEntries":["117"]}],"itemSearchURL":["http://stores.ebay.com/SewLovelyPatterns/_i.html?_saslop=1&_fss=1&LH_SpecificSeller=1&_ddo=1&_exmaitems=1&_ipg=1&_mPrRngCbx=1&_os=ST%7CD&_pgn=1&_sid=181133160&_ssn=sewlovelypatterns&_udlo=11"]}]}