The 12th Blue Bridge Cup Provincial Tournament Group B


Answer: 40257

				k = (y2-y1)/(x2-x1);
           		b = (y1*x2-y2*x1)/(x2-x1);
import java.util.Set;
import java.util.TreeSet;

public class Main{
    public static void main(String[] args){
        int res = 20+21; // The slope does not exist the situation of the X-axis in the X-axis
        Set<Node> set = new TreeSet<>();
        Node[] nodes = new Node[20*25];
        int cnt = 0;
        for(int i=0;i<=19;i++){
            for(int j=0;j<=20;j++){
                nodes[cnt++] = new Node(1.0*i,1.0*j);
            }
        }
        for(int i=0;i<cnt;i++){
            for(int j=i+1;j<cnt;j++){
                double x1 = nodes[i].x;
                double y1 = nodes[i].y;
                double x2 = nodes[j].x;
                double y2 = nodes[j].y;
                if(x1==x2||y1==y2) continue;
                double k = (y2-y1)/(x2-x1);
                double b = (y1*x2-y2*x1)/(x2-x1);
                set.add(new Node(k,b));
            }
        }
        System.out.println(res+set.size());
    }
}
class Node implements Comparable<Node>{
    double x,y;

    public Node(double x, double y) {
        this.x = x;
        this.y = y;
    }



    @Override
    public int compareTo(Node o) {
        if(Double.compare(this.x,o.x)!=0) return Double.compare(this.x,o.x);
        return Double.compare(this.y,o.y);
    }
}


Answer: 2430
Idea: Test Division acquires all the amounts of approximately 2021041820210418 and then decomposes the decomposition of the decomposition into two products, obtains three counting products, and sequencing three numbers, if there is no such alumnus, then Cumulatory answers based on the three numbers

import java.util.Arrays;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        Set<Long> set = new TreeSet<>();// Store all the amounts
        for(long i=1;i<=n/i;i++){
            if(n%i==0) {
                set.add(i);
                set.add(n/i);
            }
        }
        Set<Node> res = new TreeSet<>();// Record the answer
        Object[] objects = set.toArray();
        int ans = 0;
        for(int i=0;i<objects.length;i++){
            Long a = (Long)objects[i];
            for(long j=1;j<=a/j;j++){// Decompose a product of two to two about
                if(a%j==0){
                    long[] arr = new long[3];
                    arr[0] = j;
                    arr[1] = a/j;
                    arr[2] = n/a;
                    Arrays.sort(arr,0,3);
                    if(res.contains(new Node(arr[0],arr[1],arr[2]))) continue;
                    if(arr[0]==arr[1]&&arr[1]==arr[2]){
                        ans += 1;
                    }else if(arr[0]==arr[1]||arr[1]==arr[2]){
                        ans += 3;
                    }else{
                        ans += 6;
                    }
                    res.add(new Node(arr[0],arr[1],arr[2]));
                }
            }
        }
        System.out.println(ans);
    }
}
class Node implements Comparable<Node>{
    long a,b,c;

    public Node(long a, long b, long c) {
        this.a = a;
        this.b = b;
        this.c = c;
    }

    @Override
    public int compareTo(Node o) {
        if(Long.compare(this.a,o.a)!=0) return Long.compare(this.a,o.a);
        if(Long.compare(this.b,o.b)!=0) return Long.compare(this.b,o.b);
        return Long.compare(this.c,o.c);
    }
}


Idea

Intelligent Recommendation

2019 10th Blue Bridge Cup Provincial Tournament Group B

Write in front: Recalling the past, knowing the way. One, team up As a basketball team coach, you need to select one player from position 1 to position 5 from the following list to form the team's sta...

Tenth Blue Bridge Cup Provincial Tournament C / C ++ Group B

Tenth Blue Bridge Cup Provincial Tournament C / C ++ Group B to sum up March 24th was completed. Personally, since 2013, this year's province has been the easiest. Although I don't do it, it is possib...

2020 The 11th Blue Bridge Cup Provincial Tournament Group B

Question A: Running training This topic: 5 points 【Problem Description】 Xiao Ming wants to be a running training. Initial, Xiao Ming is full of physical strength, and the physical value is 10000. If t...

2018 Blue Bridge Cup Provincial Tournament B Group Java Question

2018 Province B group Topic description The shape of the Chinese characters exists in the font, even in today, the 16-point font is still wide. 16 o'clock in the font library regards each Chinese char...

Blue Bridge Cup 7th Provincial Tournament Group B - four square and

Four square and theorem, also known as the Lagrangian theorem: Each positive integer can be represented as a square sum of up to 4 positive integers. If 0 is included, it may be represented as a squar...

More Recommendation

[The 7th Blue Bridge Cup Provincial Tournament C++B Group] Solutions to all questions in the Provincial Tournament

Article Directory Fast branch channel Number of briquettes Birthday candles Imputation formula Quick sort Draw lots Square fill Cut stamps Four square sum Exchange bottles Maximum ratio Number of briq...

The 12th Blue Bridge Cup Provincial Tournament Java C Follow Follow

Question A: ASCLL 【Problem Description】 It is known that the ASCII code of uppercase letters A is 65. What is the ASCII code of uppercase letters L? [Answer submission] This is a question that fills t...

2018 Blue Bridge Cup Provincial Tournament Group B Simulation Tournament (5) B. Fill in the blanks: the number of primes

Among all the integers composed of 8 numbers 0,1,2,3...7, how many prime numbers are there (each number must be used and can only be used once). Tip: Numbers starting with 0 are illegal numbers. answe...

Ji Suanke 2018 Blue Bridge Cup Provincial Tournament Group B Simulation Tournament (5)

A. Fill in the blanks: matrix summation(3 points) Give you an n×n matrix filled with 1 to n×n. For example, when n is equal to 3, the filled matrix is ​​as follows. Now we connect the midp...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top