Acdream 1704 (violence)

Source: Internet
Author: User

Test instructions
Problem Description

Small Sunny is one of the Acdream team's most cattle teacher, he is best at mathematical arithmetic ~ This day he opened a book "AC is not a Dream" magazine, found that the last page has a very classic thinking problem, the topic is very simple, each box fill a number, constitute a vertical type, each number of the highest bit can not be 0, But there are some numbers that are hidden and then let you fill out hidden numbers based on numbers that are not hidden.

Such as:

Then the small sunny apart, rinsed wrote the answer:

Then a small sunny day that the topic is too simple, so ask you if there is a way to find out how many different answers to a topic? (As long as there is a box with different numbers for different answers)
Input

Multiple sets of data, first an integer t (t<=20), representing the number of data groups.
For each set of data, a vertical is represented by 5 rows, each line is a string and contains only an asterisk (*) and a number (' 0 ' ~ ' 9 '), where the asterisk denotes a blank
A string where the first behavior is 3 length.
A string with a second behavior length of 2.
The third behavior is a string with a length of 4.
The string with the length of the behavior of 3.
A string with a length of 5.
Output

For each set of data, output an integer x representing the kind of fill that conforms to the multiplicative vertical law.
Sample Input

2

**
3384
846

4**
**
3384
846

Sample Output

2
1
Puzzle: Because the first multiplier 3 digits, enumeration from 100 to 999, the second multiplier 2 digits, enumeration from 10 to 99, first to match the existing value, do not satisfy continue, otherwise get the third number and the fourth number, then go to match, do not meet continue, otherwise get the last number, Match the successful answer plus one.

#include <stdio.h>#include <string.h>Charstr[Ten][Ten];ints[Ten][Ten];intres =0, flag[5] = {3,2,4,3,5};voidSolveintx) { for(inti =0; i < flag[x]; i++)if(Str[x][i]! =' * ') S[x][i] = Str[x][i]-' 0 ';ElseS[x][i] =-1;}BOOLJudgeintXintcur) {intA = Flag[cur]-1, temp[Ten]; while(X >0&& a >=0) {intb = x%Ten;if(S[cur][a]! =-1&& S[cur][a]! = b)return false;        a--; X/=Ten; }if(x = =0&& A = =-1)return true;return false;}intMain () {intTscanf("%d", &t); while(t--) { for(inti =0; I <5; i++) {scanf('%s ', Str[i]);        Solve (i); } res =0; for(inti = -; I < +; i++) {if(!judge (I,0))Continue; for(intj =Ten; J < -; J + +) {if(!judge (J,1))Continue;intTemp1 = i * (j%Ten);if(!judge (Temp1,2))Continue;intTEMP2 = i * (J/Ten);if(!judge (TEMP2,3))Continue;inttemp = Temp1 + Temp2 *Ten;if(!judge (temp,4))Continue;            res++; }        }printf("%d\n", res); }return 0;}

Acdream 1704 (violence)

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.