P1204--0 and questions
Time limit: 1000MS
Memory Limit: 131072KB
Description
Master Chuan, look what you've chosen to tell me how to change the description. ╮ (╯_╰) ╭ Now, please, I can't make up my mind. _ (: 3 J Z) _
Please consider a 1 to N (N=3, 4, 5 ... 9) The number of numbers consists of the increment sequence: 1 2 3 ... N.
Now please insert "+" in the column to indicate plus, or "-" for minus, or "" for whitespace to combine each pair of numbers (do not insert a symbol before the first number).
Calculate the result of the expression and note whether you get the sum as zero.
Please write a program to find out all the resulting and zero length of the sequence of N.
Input Format
A single line represents an integer n (3 <= n <= 9).
Output Format
In the order of ASCII code, output all numbers that can be obtained and zero after inserting "+", "-", or "" between each pair of digits. (Note: You should keep a space even if there are no caret between two numbers)
Sample Input
7
Sample Output
1+2-3+4-5-6+71+2-3-4+5+6-71-2 3+4+5+6+71-2 3-4 5+6 71-2+3+4-5+6-71-2-3-4-5+6+7
Exercises
Water and water search questions, 0S404KB, but hit the table 0s242kb TAT.
1#include <bits/stdc++.h>2 using namespacestd;3 intN;4 Charpos[ A];5 voidprt () {6 for(intI=1; i<n;++i) printf ("%d%c", I,pos[i]);7printf"%d\n", n);8 }9 voidDfsintNowintSumintWintk) {Ten if(now==n) {if(sum+w*k==0) PRT ();return;} Onepos[now]=' ';d FS (now+1, sum,w*Ten+now+1, k); Apos[now]='+';d FS (now+1, sum+w*k,now+1,1); -pos[now]='-';d FS (now+1, sum+w*k,now+1,-1); - } the intMain () { -scanf"%d",&n); -Dfs1,0,1,1); - return 0; +}
View Code
To Changzhou, Qaq to start training tomorrow =-= sat for a whole day's bullet train
[Fzyzoj 1204] 0 and questions