Fifth annual Blue Bridge Cup B/C + + undergraduate (real trial)

Source: Internet
Author: User
Tags ming strcmp

Chicken can only be reported in a group B. So I reported the sixth session of undergraduate B. I found the last undergraduate B's question to do.



A:

Title: Beer and drink    beer 2.3 yuan per can, drink 1.9 yuan per can. Xiao Ming bought a number of beers and drinks, which cost 82.3 yuan altogether.    We also know that he buys less beer than the number of drinks, please calculate he bought a few cans of beer.    Note: The answer is an integer. Please submit your answer via the browser.    do not write any extra content (e.g., write the number of drinks, add explanatory text, etc.).

For this, I was directly violent.

    Double a=2.3,b=1.9;    for (J,0,size)    for (i,0,j)    {        if (ABS (a*i+b*j-82.3) <=eps)        {            pf ("%d%d\n", i,j);            return 0;        }    }
The answer is 11, 30.


B:

Title: Cut Noodles    a high-gluten ramen, cut a knife in the middle, you can get 2 noodles.    If you fold 1 times in the middle, you can get 3 noodles by cutting a knife.    If you fold 2 times in a row, cut a knife in the middle, you can get 5 noodles.    so, 10 times in a row, cut a knife in the middle, how much noodles will get? The answer is an integer, please submit the answer through the browser. Do not fill in any extra content.

It would be nice to find the recursive equation.

f[n]=f[n-1]*2-1;

The answer is 1025.


C:

Title: Li Bai Cider    The words of the great poet Li Bai, a good life drink. Fortunately, he never drives.    one day, he was carrying a flask, out of the house, a flask of wine 2. He sang as he walked:    There was nothing to go on the street, and a pot to cider. Every    shop adds one times, meets the flower to drink a fight.    on this road, he met the shop 5 times, met the flowers 10 times, known the last encounter is a flower, he just drank the wine.     Please calculate the order that Li Bai meets the shop and the flower, can take the shop to remember as a, meet the flower to remember as B. Then: BABAABBABBABBBB is a reasonable order. How many are there in the answer like this? Please calculate the number of all possible scenarios (including the topic given).    Note: Submit an answer via the browser. The answer is an integer. Don't write any extra content.

ORZ, I'm still in a mob search. Anyway, not the card time.

However, it is important to note that it is not possible to 0*2=0 in the middle of a drink.

The answer is 14.

#include <cstdio> #include <cstring> #include <string> #include <queue> #include <algorithm > #include <map> #include <stack> #include <iostream> #include <list> #include <set># include<bitset> #include <vector> #include <cmath> #define INF 0x7fffffff#define EPS 1e-8#define LL Long Long#define PI 3.141592654#define CLR (A, B) memset (A,b,sizeof (a)) #define for (I,A,B) for (int i=a;i<b;i++) #define For_ (I,A,B) for (int i=a;i>=b;i--) #define PUB push_back#define PUF push_front#define pob pop_back#define pof pop_front #define MP make_pair#define ft first#define SD second#define SF scanf#define PF printf#define sz (v) ((int) (v). Size ()) #defi NE All (v) (v). Begin (), (v). End () #define ACFUN Std::ios::sync_with_stdio (FALSE) #define SIZE 10000 +1using namespace std; int F=10,s=5;char a[16];int ans=0;void dfs (int u,int i,int j,int k) {if (u==0&&i==0&&j==0) {i        F (a[14]== ' a ') return;        ans++; for (p,0,15) pf ("%c", A[p]);    PF ("\ n");    }//pf ("%d%d\n", i,j); if (i<0| |    J&LT;0) return;    A[k]= ' a ';    DFS (U*2,I-1,J,K+1);    A[k]= ' B '; DFS (u-1,i,j-1,k+1);}    int main () {DFS (2,s,f,0); PF ("\n%d\n", ans);}

D:

Title: The revolutionary contribution of the Sfeng calculator Sfeng speed algorithm is to predict rounding from a high.    Do not need 99 tables, completely subvert the traditional hand count!    The core foundation of the calculator is the multiplication of 1-bit numbers multiplied by multiple digits.    Where multiplying by 7 is the most complex, take it for example. Because, 1/7 is a repeating decimal: 0.142857 ..., if the number of digits more than 142857 ..., will go 1 the same, 2/7, 3/7, ...    6/7 are similar repeating decimal, multi-digit more than N/7, it is necessary to enter n the program simulates the Sfeng speed algorithm multiplied by 7 of the operation process.    The single-digit rule multiplied by 7 is: even times 2, odd times 2, plus 5, all take only one digit. The Carry rule multiplied by 7 is: Full 142857 ... Enter 1, full 285714 ... Enter 2, full 428571 ... Enter 3, full 571428 ... Enter 4, full 714285 ... Enter 5, full 857142 ... In 6 please analyze the program flow and fill in the missing code of the underlined part. Computes the single digit int Ge_wei (int a) {if (a% 2 = = 0) return (A * 2)% 10;elsereturn (A * 2 + 5)% 10;} Calculate carry int Jin_wei (char* p) {char* level[] = {"142857", "285714", "428571", "571428", "714285", "857142"};char buf[7];buf[6 ] = ' + '; strncpy (buf,p,6); int i;for (i=5; i>=0; i--) {int r = strcmp (Level[i], buf); if (r<0) return I+1;while (r==0) {p + = 6;strncpy (buf,p,6), R = strcmp (Level[i], buf), if (r<0) return i+1;//if (r>0) return i;//_________________________  _____; Fill in the blanks}}return 0;} Multiply the number of digits by 7void F (char* s) {int head = Jin_wei (s), if (Head > 0) printf ("%d", head), char* p = s;while (*p) {int a = (*p-' 0 '); NT x = (ge_wEI (a) + Jin_wei (p+1))% 10;printf ("%d", x);p + +;} printf ("\ n");} int main () {f ("428571428571"); F ("34553834937543"); return 0;} Note: Submit an answer via the browser. Only fill in the missing content, do not fill in any superfluous content (for example: descriptive text)

Just figure it out. The answer is: if (r>0) return i;


E:

Title: Print graphics Xiao Ming found the shape and text in the Castle of Planet X: Rank=3 * * * * * * * * * *rank=5 *                                                                * *                                                                  *   *       * * * *                                                              *                                                          *                                                            * *     * *                                                      *   *   *   *                                                        * * * * * * * *                                                  *               *                                                    * *             * *         *   *           *   *                                                * * * *   * * * *                                              *       *       *       *    * *     * *     * *     * *   *   * *   *   *   *   *   ** * * * * * * * * * * * * * * * * * * * * * * * * * ran=6 *                                                                * *                                                                  *   *                                                            * * * *                                                              *       *    * *     * *                                                          *   *                                                      *   *                                                        * * * * * * * *                                                  *               *                                                    * *             * *                                              *   *           *   *                                                * * * *         * * * * *       *       *       *                                            * *     *       *     * *     * *                                   *   *   *   *   *   *   *   *                                        * * * * * * * * * * * * * * * *                                      *                               *                                    *                                *                             * *                                  *   *                           *   *       * * * *                         * * * *                              *       *                       *                   *                            * *     * *                     * *     * *                          *   *   *   *               *   *   *   *                        * * * * * * * *                 * * * * * * * *                      *                  *               *               *                    * *             * *             * *             * *         *   *           *   *           *   *           *   *                * * * *         * * * *         * * * *             * * * * *       *       *       *       *       *       *       *            * *     * *     * *     * *     * *     * *     * * * *          *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *        * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *, write the following To print the graphic. #define N 70void F (char a[][n], int rank, int row, int col) {if (rank==1) {A[row][col] = ' * '; return;} int w = 1;int i;for (i=0; i<rank-1; i++) W *= 2;//____________________________________________;//f (A, rank-1, row, col+w /2); F (A, rank-1, Row+w/2, col); F (A, rank-1, ROW+W/2, col+w);} int main () {char a[n][n];int i,j;for (i=0;i<n;i++) for (j=0;j<n;j++) a[i][j] = "; F (a,6,0,0); for (i=0; i<n; i++) { for (j=0; j<n; j + +) printf ("%c", A[i][j]);p rintf ("\ n");}    return 0;}    Please carefully analyze the program logic and fill in the Missing Code section. Submit an answer via the browser. Be careful not to fill in the code that is already in the title. Do not write any superfluous content (such as descriptive text).

is to print graphics, it is clear that the fact is recursive three copies.

The answer is: f (A, rank-1, row, COL+W/2);

Fifth annual Blue Bridge Cup B/C + + undergraduate (real trial)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.