Solve the programming problem Guess the number C C

Updated on educate 2024-03-07
5 answers
  1. Anonymous users2024-02-06

    The bounty is 0....Give me the right answer. Thank you. It's a good thing.

    #include

    #include

    using namespace std;

    int main()

    int n,x[10][4],a[10],b[10],sum=0,ans;

    int check[10][10]=;

    cin>>n;

    for(int i=0;i=0;j--)x[i][j]='0',check[i][x[i][j]]+

    cin>>a[i]>>b[i];

    for(int i=0;i<10000;i++)for(int j=0;jint now[10]=,a=0,b=0;

    for(int k=0;k<4;k++)

    now[i/(int)pow(,k)%10]++if(i/(int)pow(,k)%10==x[j][k])b++;

    for(int k=0;k<10;k++)a+=min(now[k],check[j][k]);

    if(a!=a[j]||b!=b[j])break;

    if(j==n-1)sum++,ans=i;

    if(sum==0)cout<<"no answer!";

    else if(sum==1)coutsystem("pause");

    return 0;

  2. Anonymous users2024-02-05

    Time limit: 1 second.

    Space Limit: 32768k

    This question is more difficult.

    First, apply the idea of dynamic programming.

    First of all, we divide the eyes, dp[i] denotes the legal number of the first i numbers.

    When the ith number is prime, there is nothing in front of it that can be divided except 1, so you can choose y or n at any time for this position, so dp[i] = dp[i-1].

    When the ith number is not a power of a prime number, such as 6,10, then their situation is actually determined by the previous number, for 6, if 2,3 is yy, then 6 must be y, otherwise 6 must be n, so dp[i] = dp[i-1].

    When the ith number is the power of a prime number, that is, 2, 4, 8, 16, then the situation is complicated. Suppose there are 2, 4, 8 now, then how many cases are there, we can find the pattern by careful analysis.

    yyy, ynn, nnn, yyn on these four types of leaking shirts.

    to the plexiform cavity in 2, 4

    YN, YY, NN.

    We found that there is actually a pattern, first of all, you can or neither, and then you add y: from left to right

    ynn,yyn。

    So for this case, we get the law that if there are n powers, there is a feasible case in n+1.

    After the analysis, we can come up with the calculation, for 12:

    The three numbers 2, 4, and 8 are powers, and there is a possibility of 4.

    There are three possibilities for powers of 3 and 9.

    5, 7, and 11 are two possibilities, respectively.

    All other numbers are determined by other numbers.

    So the end result is 43

    So we think about it, and in the end it becomes a number of primes and powers of primes.

  3. Anonymous users2024-02-04

    You can use custom functions to determine the quadrant where the coordinate point is located.

  4. Anonymous users2024-02-03

    A has an ASCII value of 65, so, *s%10 outputs an ASCII value of 66 for 5b, so, *s%10 outputs an ASCII value of 67 for 6c, so, *s%10 outputs 7 So, the output is 567

  5. Anonymous users2024-02-02

    2:while(!e) When!

    e==1 is running, then it is equivalent to running 4 when e==0: because the stop condition of the cycle is b--<0, first b-=a, that is, b=b-a=10-1=9, then a++=2, and then b--<0, because b=9, so it is not true, at this time, b--,b becomes 8, so the result is 8

    First of all, you need to know a8: as mentioned above, 1<=x<=2 is equivalent to (1<=x)<=2, and the value of the expression 1<=x is either 0 or 1, so (1<=x)<=2 is very valid, so it is an endless loop.

Related questions
8 answers2024-03-07

The method used on the 3rd floor is as2.

There is a mistake on the 4th floor, and it would be nice to fix it. >>>More

24 answers2024-03-07

What grade is it? As long as you go to the top and type "xx grade Olympiad questions and answers", there will be a lot of them, and you can't read them all.

16 answers2024-03-07

10 15 5) (7 2) 20 5 4 (years old) The age of the son 10 years ago. >>>More

5 answers2024-03-07

1, Tang Taizong Li Shimin.

2. The previous emperors despised foreign civilizations and attached importance to Chinese civilizations, but I treated them equally and everyone was equal. >>>More

24 answers2024-03-07

Variance s 2=[(x1-x) 2+(x2-x) 2+.xn-x) 2] n is to subtract the square of the mean for each number in the group, and then divide by (n-1), where n is the number of samples in the group. >>>More