[Blue Bridge Cup] with fractions

Source: Internet
Author: User

[Blue Bridge Cup] with fractions

Peak memory consumption < 64M CPU consumption < 3000ms

"Title Description-Problem Description"

100 can be expressed as a fractional form: 100 = 3 + 69258/714

can also be represented as: 100 = 82 + 3546/197

Note features: With fractions, the digital 1~9 appear only once (not including 0).

Similar to the band score, 100 has 11 notation.

"Input sample 1-sample input 1"

"Output sample 1-sample outputs 1"

100 11

"Input sample 2-sample input 2"

"Output sample 2-sample outputs 2"

105 6

Exercises

Probably estimated the limit calculation of the table, 1s should barely can take a chance, and then looked back to see the time to 3s ...

The brain immediately terminates the thinking of other solutions ...

"Code C + +"

#include <cstdio>#include<algorithm>#defineMX 1000005intdata[9], opt[mx];intReadintLintR) {//[L, R]    ints =0;  for(; L <= R; ++L) {s= S *Ten+Data[l]; }    returns;}intMain () {intI, AL, AR, BL, BR, A, B, C;  for(i =0; I <9; ++i) Data[i] = i +1;  Do{         for(Al = AR =0; Ar <=6; ++ar) {a=Read (AL, AR);  for(bl = BR = AR +1; BR-BL +1<8-BL; ++R) {b= Read (BL, br), C = Read (BR +1,8); if(C/b*b! = c)Continue; if(A + c/b < MX) ++opt[a + c/b]; }        }    }  while(Std::next_permutation (data, Data +9)); scanf ("%d", &i); printf ("%d", Opt[i]); return 0;}

"Measurable Address" http://acmore.cc/problem.php?id=1596

[Blue Bridge Cup] with fractions

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.