Fifth annual Blue Bridge Cup B/C + + undergraduate (real title trial) (6~8)

Source: Internet
Author: User
Tags bitset cmath

Finally finished the exam ... But the Hang Ke's definitely.

Let's do the math.

The previous eight questions are easy to do.

F:

Title: Strange Fractions in    Elementary School, Xiaoming often invented his own new algorithm. Once, the teacher out of the title is:    1/4 times 8/5     Xiao Ming incredibly put together the numerator, the denominator stitching together, the answer is: 18/45 (see figure 1.png) The    teacher just wanted to criticize him, then thought, this answer coincidentally also right ah, really damn!    for the numerator and denominator are all one-digit numbers in the 1~9, what other formulas can be computed like this?    please write down the number of all the different formulas (including examples in the question).    obviously, after the numerator's denominator, for example: 4/1 times 5/8 is satisfying, this is a different formula.    but for the same numerator denominator, 2/2 times 3/3 has too many types, not counting! Note: The answer is an integer (consider symmetry, which is definitely even). Please submit via browser. Don't write extra content.

or violence. 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 main () {int ans=0;            for (i1,1,10) {for (j1,1,10) {if (i1==j1) continue;  for (i2,1,10) {for (j2,1,10) {                  if (I2==J2) continue;                    Double TMP1,TMP2;                    TMP1=I1/(j1*1.0) * (i2/(j2*1.0));                    Tmp2= (I1*10+I2) *1.0/((j1*10+j2) *1.0);                    PF ("%.2f%.2f\n", TMP1,TMP2);                if (ABS (TMP1-TMP2) <=eps) ans++; }}}} pf ("%d\n", ans);}

G:

Title: Hex Fill    "1.png" in the hexagonal shape, fill in the 1~12 number.    so that the sum of the numbers on each line is the same.    figure, you have filled out 3 numbers, please calculate the asterisk position represents the number? Please submit your answer through the browser, do not fill in the superfluous content.

Represented by an array as a[12].

Enumerate on it, or be violent.

The answer is 10.

All 12 numbers are 1 8 9 2 7 10 12 6 5 4 11 3

BOOL Vis[13];int A[13];bool Cheack () {    int tmp=a[1]+a[3]+a[6]+a[8];    if (a[1]+a[4]+a[7]+a[11]!=tmp) return 0;    if (a[2]+a[3]+a[4]+a[5]!=tmp) return 0;    if (a[8]+a[9]+a[10]+a[11]!=tmp) return 0;    if (a[2]+a[6]+a[9]+a[12]!=tmp) return 0;    if (a[5]+a[7]+a[10]+a[12]!=tmp) return 0;    return 1;} void Dfs (int i) {    if (i==12)    {        if (!cheack ()) return;        for (i,1,13)        pf ("%d", A[i]);    }    for (j,1,13)    {        if (vis[j]) continue;        Vis[j]=1;        A[i]=j;        DFS (i+1);        vis[j]=0;}    } int main () {    a[1]=1,a[2]=8,a[12]=3;    CLR (vis,0);    Vis[1]=1,vis[8]=1,vis[3]=1;    DFS (3);}

H:

Title: Ants    have n ants on slender straight poles with a cold length of 100 centimeters. They have their heads on the left, some facing to the right.     each ant can only climb along the pole, at a speed of 1 centimeters per second.    when two ants meet, they will turn around at the same time and crawl in the opposite direction.    of these ants, 1 ants have a cold. And when they meet with other ants, they will infect the ant with the cold.    Please calculate how many ants have a cold when all the ants are climbing away from the pole. The first line of "data format"    enters an integer n (1 < n < 50), which represents the total number of ants.    the next line is n a space-separated integer XI ( -100 < Xi <), the absolute value of Xi, indicating the distance the ant leaves the left end of the pole. A positive value indicates a head to the right, a negative value indicates a head to the left, no 0 values appear in the data, and no two ants occupy the same position. Among them, the first data represents the ants catching a cold.    requires an output of 1 integers, indicating the number of last cold ants. For example, input: 35-2 8 program should output: 1 again for example, input: 5-10 8-20 12 25 program should output: 3 Resource contract: Peak memory consumption < 256MCPU consumption  < 1000ms Please strictly according to the requirements of output, do not superfluous printing similar: "Please enter ...” Redundant content. All the code is placed in the same source file, after debugging passed, the copy is submitted to the source. Note: The main function needs to return 0 Note: Use only ANSI c/ansi C + + standards, do not invoke special functions that depend on the compilation environment or the operating system. Note: All dependent functions must explicitly #include <xxx> in the source file, and the common header files cannot be omitted from the project settings. When committing, be careful to choose the type of compiler you expect.

It would be nice to collide with two ants without touching them. Statistics on the contrary, if any, add the same back.


#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;    BOOL Cheack (int a,int b) {if (a>0&&b<0) return 1;    if (a<0&&b>0) return 1; return 0;}    int main () {int n,a[51]; while (~SF ("%d", &n)) {for (I,0,n) SF ("%d", &a[i]);        int l=0,r=0;        int ans=0; for (I,0,n) {if (a[0]>0) {if (ABS (A[i)) >abs (a[0]) &&cheack (a[0],a[                I])) ans++;            if (ABS (A[i]) <abs (a[0]) &&cheack (-a[0],a[i])) ans++; } else {if (ABS (A[i]) <abs (a[0]) &&cheack (A[0],a[i])) ans                ++;            if (ABS (A[i]) >abs (a[0]) &&cheack (-a[0],a[i])) ans++;    }} PF ("%d\n", ans+1); }}

As for the following two questions. One should be a memory search, there is a should be reverse, merge or a number of arrays, first put on New Year's Day, have time to do.

Fifth annual Blue Bridge Cup B/C + + undergraduate (real title trial) (6~8)

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.