
回答 1 已采纳 Problem Description
The wide dissemination of calculators and computers is not without disadvantages. Teachers all over the world find out that even students in technical disciplines tend to have a surprising lack of calculating ability. Accustomed as they are to the use of calculators and computers, many of them are unable to make calculations like 7*8 mentally, or to factor 91 by heart.
We all know, but who cares?
Professor Bartjens cares. Professor Bartjens is a bit oldfashioned. He decided to give his students some training in calculating without electronic equipment  even without a slide rule. He invented a twoperson game involving mental calculations.
Professor Bartjens would write a positive number on the blackboard. During the game more positive numbers may appear on the blackboard. The two players will then make moves in turn. A player on move is obliged to make a move, unless the blackboard is empty, in which case the game
is over. A move is one of the following:
－－If you see the number 1 on the blackboard, you may take it. That means: you gain one point,and the number disappears from the blackboard.
－－If you see a prime number p on the blackboard, you may subtract one. That is: you gain one point, and the p on the blackboard is replaced by p －1.
－－If you see a composite number c on the blackboard, you may replace it by two smaller (positive) numbers, a and b, such that a * b = c. You do not gain any points.
The goal is of course to obtain as many points as you can.
Professor Bartjens was hoping that his students would find the game so interesting that they would spend all day playing, thereby improving their skills in calculation. Indeed his students did find the game interesting, and spent many hours, not so much playing the game as discussing optimal strategies.
The students came to two conclusions. First, the sum of the two players' points after any given game are the same regardless of the actual scheme played. Thus," a player maximising his own points also minimises his opponent's! Second, it is always best to take a point when you have the
chance. Thus, whenever prime numbers or ones are written on the blackboard, the player on move takes one of them.
Here is your problem: given a starting number, and assuming both players play to maximise their own points, what will be the outcome?
Input
On the first line of the input is a single positive integer n, telling the number of test scenarios to follow. Each scenario consists of a single line containing the positive integer m<1000000, the number initially written on the blackboard.
Output
For each test scenario, output one line containing two numbers separated by one space character, equal to the points gained by the two players, both playing to maximise their own points. The first number is the number of points gained by the first player.
Sample Input
6
1
2
3
4
5
6
Sample Output
1 0
1 1
2 1
2 2
3 2
2 3

回答 1 已采纳 Description
Alice Catherine Morris and her sister Irene Barbara frequently send each other emails. Ever wary of interceptions and wishing to keep their correspondence private, they encrypt their messages in two steps. After removing all nonalphabetic characters and converting all letters to upper case, they: 1)replace each letter by the letter s positions after it in the alphabet (1 <= s <= 25)we call this a shift by sand then, 2) divide the result of step 1 into groups of m letters and reverse the letters in each group (5 <= m <= 20). If the length of the message is not divisible by m, then the last k (less than m) letters are reversed. For example, suppose s = 2 and m = 6. If the plaintext were
Meet me in St. Louis, Louis.
after removing unwanted characters and changing to upper case we get
MEETMEINSTLOUISLOUIS
We will call this the modified plaintext. We then shift each letter by 2 (Y would be replaced with A and Z would be replaced by B, here), getting the intermediate result:
OGGVOGKPUVNQWKUNQWKU
And finally reverse every group of 6 letters:
GOVGGOQNVUPKWQNUKWUK
Note the last two letters made up the last reversed group. As is customary, we write the result in groups
of 5 letters. So the ciphertext would be:
GOVGG OQNVU PKWQN UKWUK
Alas, it's not so hard to find the values for s and m when the ciphertext is intercepted. In fact it's even easier if you know a crib, which is a word in the modified plaintext. In the above example, LOUIS would be a crib. Your job here is to find s and m when presented with a ciphertext and a crib.
Input
Input will consist of multiple problem instances. The first line of input will contain a positive integer indicating the number of problem instances. The input for each problem will consist of multiple lines. The first line of input for a problem will contain the integer n (20 <= n <= 500) which is equal to the number of characters in the ciphertext. The following lines will contain the ciphertext, all upper case in groups of 5 letters separated by a single space. (The last group of letters may contain fewer than 5 letters.) There will be 10 groups of letters per line, except possibly for the last line of ciphertext. The input line following the last line of ciphertext will contain the crib; a single word consisting of between 4 and 10 (inclusive) upper case characters.
Output
Output will be two integers, s and m on a line, separated by a single space, indicating the encryption key that produces the crib, where s is the shift and m is the reversed group size. If there is more than one solution, output the one with smallest s. If there is more than one with the same s, output the one with smallest m. If no such s and m exist, output the message Crib is not encrypted.
Sample Input
4
83
FIQMF IISFN QMFIB EOPFH FNQMV PSFIU IZNGP UPEUS BFPEP PEPPE
PPEPN QMFIP EOPIS FIQMF IBSFN QMFBE OPI
RHONDA
105
VDBMN DQDGS LNQEM ZLZRZ RNGVX ZALNA TERZV CZDGD MZQHZ GENKK
KONSC DJHKC KKZAD RZAXZ SNMRH GBHGV RZVDG XZRNS XZKOS ZCNNF
SHFMH
BOMBAY
50
QFNWX YQFNW YSAQX FYNWY XQFNW SXYQF FXNYS AXYQF NASXY QFNAX
HEAVEN
20
GOVGG OQNVU PKWQN UKWUK
LOUIS
Sample Output
1 6
25 6
Crib is not encrypted.
2 6

回答 1 已采纳
i've got an array, which i know that its values would be JPGs from somewhere
i need to go to each value returned to that array and preg_replace some characters
then set the values of the returned values to some other value
here's the code and here's what i've tried
//first piece of code
$data['images'] = array();
foreach ($single['PictureURL'] as $ispec) {
$data['images'][] = $ispec;
$ispec = preg_replace('/\$_[09]+.JPG\b/i', '$_10.JPG', $ispec);
$file = 'C:\wamp64\www\mz\images1.txt';
file_put_contents ($file, $ispec, FILE_APPEND);
//images1.txt shows all images returned fine with modified strings
}
//second piece of code
$product>imageUrl = $data['images'][0];
unset($data['images'][0]);
$product>subImageUrl = $data['images'];
$file = 'C:\wamp64\www\mz\images3.txt';
file_put_contents ($file, $data['images'], FILE_APPEND);
//images3.txt shows all the images returned but without being modified?? WHY??!
the first piece of the code is working on all values and replacing is working just fine.
the second piece of the code is my issue, it is returning the values of the old none modified images, which i don't
i need to modify the images before its being written to
'$product>imageUrl & $product>subImageUrl'

回答 2 已采纳 Description
Math Olympiad is called “Aoshu” in China. Aoshu is very popular in elementary schools. Nowadays, Aoshu is getting more and more difficult. Here is a classic Aoshu problem:
ABBDE __ ABCCC = BDBDE
In the equation above, a letter stands for a digit(0 – 9), and different letters stands for different digits. After you fill the blank with '+', '', '×' or '÷', and replace the letters with digits, you get an equation.
How to make the equation right? Here is a solution:
12245 + 12000 = 24245
In that solution, A = 1, B = 2, C = 0, D = 4, E = 5, and '+' is filled in the blank.
When I was a kid, finding a solution is OK. But now, my daughter’s teacher tells her to find all solutions. That’s terrible. I doubt whether her teacher really knows how many solutions are there. So please write a program for me to solve this kind of problems.
Input
The first line of the input is an integer T( T <= 20) indicating the number of test cases.
Each test case is a line which is in the format below:
s1 s2 s3
s1, s2 and s3 are all strings which are made up of capital letters. Those capital letters only include 'A','B','C','D' and 'E', so forget about 'F' to 'Z'. The length of s1,s2 or s3 is no more than 8.
When you put a '=' between s2 and s3, and put a operator('+', '', '×' or '÷'.) between s1 and s2, and replace every capital letter with a digit, you get a equation.
You should figure out the number of solutions making the equation right.
Please note that same letters must be replaced by same digits, and different letters must be replaced by different digits. If a number in the equation is more than one digit, it must not have leading zero.
Output
For each test case, print an integer in a line. It represents the number of solutions.
Sample Input
2
A A A
BCD BCD B
Sample Output
5
72

回答 1 已采纳 Problem Description
The wellknown physicist Alfred E Neuman is working on problems that involve multiplying polynomials of x and y. For example, he may need to calculate
getting the answer
Unfortunately, such problems are so trivial that the great man's mind keeps drifting off the job, and he gets the wrong answers. As a consequence, several nuclear warheads that he has designed have detonated prematurely, wiping out five major cities and a couple of rain forests.
You are to write a program to perform such multiplications and save the world.
Input
The file of input data will contain pairs of lines, with each line containing no more than 80 characters. The final line of the input file contains a # as its first character. Each input line contains a polynomial written without spaces and without any explicit exponentiation operator. Exponents are positive nonzero unsigned integers. Coefficients are also integers, but may be negative. Both exponents and coefficients are less than or equal to 100 in magnitude. Each term contains at most one factor in x and one in y.
Output
Your program must multiply each pair of polynomials in the input, and print each product on a pair of lines, the first line containing all the exponents, suitably positioned with respect to the rest of the information, which is in the line below.
The following rules control the output format:
1.Terms in the output line must be sorted in decreasing order of powers of x and, for a given power of x, in increasing order of powers of y.
2.Like terms must be combined into a single term. For example, 40x2y3  38x2y3 is replaced by 2x2y3.
3.Terms with a zero coefficient must not be displayed.
4.Coefficients of 1 are omitted, except for the case of a constant term of 1.
5.Exponents of 1 are omitted.
6.Factors of x0 and y0 are omitted.
7.Binary pluses and minuses (that is the pluses and minuses connecting terms in the output) have a single blank column both before and after.
8.If the coefficient of the first term is negative, it is preceded by a unary minus in the first column, with no intervening blank column. Otherwise, the coefficient itself begins in the first output column.
9.The output can be assumed to fit into a single line of at most 80 charactes in length.
10.There should be no blank lines printed between each pair of output lines.
11.The pair of lines that contain a product should be the same lengthtrailing blanks should appear after the last nonblank character of the shorter line to achieve this.
Sample Input
yx8+9x31+y
x5y+1+x3
1
1
#
Sample Output
13 2 11 8 6 5 5 2 3 3
x y  x y + 8x y + 9x  x y + x y + 8x + x y  1 + y
1

回答 1 已采纳
I have to find a php code to solve a math problem.
This is the problem description:
Players A and B are playing a new game of stones. There are N stones
placed on the ground, forming a sequence. The stones are labeled from
1 to N. Players A and B play in turns take exactly two consecutive stones
on the ground until there are no consecutive stones on the ground.
That is, each player can take stone i and stone i+1, where 1≤i≤N−1. If
the number of stone left is odd, A wins. Otherwise, B wins. Assume
both A and B play optimally and A plays first, do you know who the
winner is?
The line has N stones and are indexed from 1 to N > N (1 ≤
N ≤ 10 000 000)
If the number of stone left is odd, A wins. Otherwise, B wins.
This is my code. It does work, but it is not correct.
<?php
$nStones = rand(1, 10000000);
$string = ("i");
$start = rand(1, 10000000);
$length = 2;
while($nStones > 0) {
substr( $nStones , $start [, $length ]): string;
}
if ($nStones % 2 == 1) {
echo "A";
} else {
echo "B";
}
?>
I think am missing the alternant subtraction of two consecutive stones by A & B, while $nStones > 0. Furthermore, the problem description mentions an optima subtraction until there is only one stone left. Therefore I guess the stones move together to their closest stones (the gaps disappear and are replaced by the closest stones).

回答 2 已采纳 Description
TEX is a typesetting language developed by Donald Knuth. It takes source text together with a few typesetting instructions and produces, one hopes, a beautiful document. Beautiful documents use doubleleftquote and doublerightquote to delimit quotations, rather than the mundane " which is what is provided by most keyboards. Keyboards typically do not have an oriented doublequote, but they do have a leftsinglequote ` and a rightsinglequote '. Check your keyboard now to locate the leftsinglequote key ` (sometimes called the "backquote key") and the rightsinglequote key ' (sometimes called the "apostrophe" or just "quote"). Be careful not to confuse the leftsinglequote ` with the "backslash" key \. TEX lets the user type two leftsinglequotes `` to create a leftdoublequote and two rightsinglequotes '' to create a rightdoublequote. Most typists, however, are accustomed to delimiting their quotations with the unoriented doublequote ".
If the source contained
"To be or not to be," quoth the bard, "that is the question."
then the typeset document produced by TEX would not contain the desired form: "To be or not to be," quoth the bard, "that is the question." In order to produce the desired form, the source file must contain the sequence:
``To be or not to be,'' quoth the bard, ``that is the question.''
You are to write a program which converts text containing doublequote (") characters into text that is identical except that doublequotes have been replaced by the twocharacter sequences required by TEX for delimiting quotations with oriented doublequotes. The doublequote (") characters should be replaced appropriately by either `` if the " opens a quotation and by '' if the " closes a quotation. Notice that the question of nested quotations does not arise: The first " must be replaced by ``, the next by '', the next by ``, the next by '', the next by ``, the next by '', and so on.
Input
Input will consist of several lines of text containing an even number of doublequote (") characters. Input is ended with an endoffile character.
Output
The text must be output exactly as it was input except that:
the first " in each pair is replaced by two ` characters: `` and
the second " in each pair is replaced by two ' characters: ''.
Sample Input
"To be or not to be," quoth the Bard, "that
is the question".
The programming contestant replied: "I must disagree.
To `C' or not to `C', that is The Question!"
Sample Output
``To be or not to be,'' quoth the Bard, ``that
is the question''.
The programming contestant replied: ``I must disagree.
To `C' or not to `C', that is The Question!''

回答 2 已采纳 Description
Us: So why don’t you just recompile the program on the new hardware?
Them: We cannot. We lost the source code.
Us: How typical! What does the program do? Do you have any documentation?
Them: The manual page does mention something about the documentation in the source code.
Us: A manual page is good. What does it say? Them: Just one line: “See the source code for more information.”
Us: Argh! What do you know about the program?
Them: Well, it seems to be taking simple text, similar to that found in an English dictionary, and printing it after some modification.
Us: What kind of modification?
Them: It removes any character that is not a lowercase letter. But not white spaces. White spaces are preserved as seen in the input.
Us: Do you have a sample input/output?
Them: Plenty. Here’s one. (see next section.)
Us: This is rather small! Did you try it on anything bigger?
Them: It works on any text as long as the lines are less then eighty characters wide. It doesn’t seem to mind working on lengthy documents. But it does terminate once it sees the sequence "EOF" (without the double quotes.)
One of them: Don’t forget to tell them about the "dd" thingy.
Us: What "dd" thingy?
Them: Whenever it sees a pair of small letter "d", one right after the other, it replaces them with "p".
Us: Why?
Them: Who knows? It just does that!
Us: What about "ddd" and "dddd"? How does it behave then?
Them: Where in English will you find a "dddd" or even a "ddd"? Haven’t you been listening?
Us: Oops. We’ll pay more attention. Anything else?
Another one of them: There is also the "vv" thingy.
Us: What about "vv"?
Them: Every "vv" is replaced with a "m".
Yet another one of them: No, wait! That was a printer problem. it had nothing to do with the program. Remember?
Them: Oh, that’s right. Forget about the "vv" thingy.
Us: What about the "dd" thingy? Was that just a printer problem too?
Them: No. That was the program.
Us: What else?
Them: One last thing. It seems to be replacing every "ei" with "ie".
Us: Every one of them?
Them: Except if it comes right after "c" then it remains as is.
Us: Makes sense. That’s all, right?
Them: No, we just remembered one more thing: It replaces the sequence "pink" with "floyd" anywhere in the text.
Us: What?! Who wrote this program? Why do you need it in the first place?
Them: We think it will increase our chances of going to Banff in April 2008 if we get it right.
Us: Yeah! Right.
Sample Input
unpinked is an 8 letter word. Honest!
vv is ok, d123d is ok, 123dd is not
i received mail from liechtenstein
.. ...adding means to imitat.#$!%%$e
EOF
Sample Output
unfloyded is an letter word onest
vv is ok dd is ok p is not
i received mail from liechtenstien
aping means to imitate

yangjia_cheng的博客 Programming Guide and Reference Version 5.2.8 c ? 20042018 Oracle Corporation http://www.virtualbox.org Contents 1 Introduction 21 1.1 Modularity: the building blocks of VirtualBox . . . . . . . . . ... 
凌风探梅的博客 On the other hand it annoys the heck out of some Danish folk who write us things like "ØMG røtfl", and "Ø is not a funny looking zero!" and " Rødgrød med Fløde! ", which is apparently an ... 
Max_Cong的博客 ØMQ  The Guide Table of Contents By Pieter Hintjens, CEO of iMatix ...issue tracker for all comments and errata(勘误表). This version covers the latest stable(稳定的) relea 
weixin_34309543的博客 noconfig do not read any config file rejectedlog=FILE log reasons for URL rejection to FILE Download: t, tries=NUMBER set number of retries to NUMBER (0 unlimits) retryconnrefused ... 
wslz2001的博客 If this option is set and libcurl has been built with the standard name resolver, timeouts will not occur while the name resolve takes place. Consider building libcurl with cares support to enable ... 
mybluetiankong的博客 We create a wallet on node 1 and copy to nodes 2 & 3. Open the wallet and we are able to select encrypted data on all three nodes. Now, we want to REKEY the MASTER KEY. What do we have to do? How do... 
congxinlan3332的博客 One of the nodes had to be completely rebuilt as a result of a problem. As there are no backups, What is the proper procedure to remove the 3rd node from the cluster so it can be added back in? ... 
cuilian2013的博客 One of the nodes had to be completely rebuilt as a result of a problem. As there are no backups, What is the proper procedure to remove the 3rd node from the cluster so it can be added back in? Does... 
clin003的博客 and probably others, and discuss such topics as firmware hacking, telnet scripting, router application building (and testing) without all the noise of folk asking how to get Command And Conquer ... 
junmuzi的博客 It is a collection of servers that run on the Mach microkernel to implement file systems, network protocols, file access control, and other features that are implemented by the Unix kernel or similar ... 
回答 1 已采纳 A common but insecure method of encrypting text is to permute the letters of the alphabet. That is, in the text, each letter of the alphabet is consistently replaced by some other letter. So as to ensure that the encryption is reversible, no two letters are replaced by the same letter.
Your task is to decrypt several encoded lines of text, assuming that each line uses a different set of replacements, and that all words in the decrypted text are from a dictionary of known words.
Input
The input consists of a line containing an integer n, followed by n lower case words, one per line, in alphabetical order. These n words comprise the dictionary of words which may appear in the decrypted text. Following the dictionary are several lines of input. Each line is encrypted as described above.
Output
Decrypt each line and print it to standard output. If there is more than one solution, any will do. If there is no solution, replace every letter of the alphabet by an asterisk.
There are no more than 1000 words in the dictionary. No word exceeds 16 letters. The encrypted lines contain only lower case letters and spaces and do not exceed 80 characters in length.
Sample Input
6
and
dick
jane
puff
spot
yertle
bjvg xsb hxsn xsb qymm xsb rqat xsb pnetfn
xxxx yyy zzzz www yyyy aaa bbbb ccc dddddd
Sample Output
dick and jane and puff and spot and yertle
**** *** **** *** **** *** **** *** ******

xmsheji的博客 ('rods', 100) ('carbohydrates', 100) ('stresses', 100) ('premiered', 100) ('cyrus', 100) ('drastically', 100) ('eukaryotic', 100) ('witchcraft', 100) ('accompaniment', 100) ('conventionally',