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)