Blue Bridge Cup with score (Java edition)

Source: Internet
Author: User

Recently are busy stocks, long time No blog, Blue Bridge Cup finals, today must come


Evaluation Link: http://lx.lanqiao.org/problem.page?gpid=T26


Problem Description:

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

It 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 format

Reads a positive integer N (n<1000*1000) from the standard input

Output format

The program outputs this number with a digital 1~9 not to be omitted to make up the total number of points expressed with fractions.

Note: No output is required for each representation, only how many representations are counted!

Sample input 1100 Sample Output 111 example input 2105 sample output 26
Import Java.util.linkedlist;import Java.util.scanner;public class main{static int n, Count;    static int arr[] = {1,2,3,4,5,6,7,8,9};        Static Boolean flag[] = new BOOLEAN[10];        static int dev (int s, int e) {int ans = 0;            for (int i = s; I <= e; i++) {ans + = arr[i];        Ans *= 10;    } return ANS/10;            } static void Fun2 () {for (int i = 0; i < 7; ++i) {int a = dev (0,i);            if (a >= n) {continue;                } for (int j = i+1; J < 8; ++j) {int b = dev (i+1,j);                int c = Dev (j+1,arr.length-1);                    if (a+1.0*b/c==n) {count++;                System.out.println (A + "+" +b+ "/" +c+ "=" +n ");             }}}}: static void fun (int cnt) {if (cnt = = Arr.length) {fun2 ();     Return   } for (int i = cnt; i < arr.length; ++i) {{int t = arr[cnt];arr[cnt] = arr[i];arr[i] = t;}            Fun (cnt+1);        {int t = arr[cnt];arr[cnt] = arr[i];arr[i] = t;}        }} public static void Main (string[] args) {Scanner sc = new Scanner (system.in);        n = sc.nextint ();        Fun (0);    System.out.println (count); }}


Blue Bridge Cup with score (Java edition)

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.