2018 ACM-ICPC 中国大学生程序设计竞赛线上赛 Goldbach

B Goldbach
猜想……验证猜想,

所以就大胆猜想吧。我猜从x/2开始可以很快就找到那两个素数,感谢学长的Java真找到了,尤其是判素数,还挺快。

Description:

Goldbach’s conjecture is one of the oldest and best-known unsolved problems in number theory and all of mathematics. It states:

Every even integer greater than 2 can be expressed as the sum of two primes.

The actual verification of the Goldbach conjecture shows that even numbers below at least 1e14 can be expressed as a sum of two prime numbers.

Many times, there are more than one way to represent even numbers as two prime numbers.

For example, 18=5+13=7+11, 64=3+61=5+59=11+53=17+47=23+41, etc.

Now this problem is asking you to divide a postive even integer n (2

Input:

The first line of input is a T means the number of the cases.

Next T lines, each line is a postive even integer n (2

Output:

The output is also T lines, each line is two number we asked for.

T is about 100.

本题答案不唯一,符合要求的答案均正确

样例输入

1
8

样例输出

3 5

//Problem B
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner Cin = new Scanner(System.in);
        int t = Cin.nextInt();
        for(int ca = 0;ca <= t;ca ++){

            long x = Cin.nextLong();
            if(x == 4){
                System.out.println("2 2");
                continue;
            }
            long y = x / 2;
            if(y % 2 == 0)  y ++;
            while(y > 0){
                long z = x - y;
                if(BigInteger.valueOf(y).isProbablePrime(100) && BigInteger.valueOf(z).isProbablePrime(100)){
                    System.out.println(y + " " +z);
                    break;
                }
                y -= 2;
            }
        }
    }
}
以下是3道小题
//Prolem E
#include <iostream>

using namespace std;
const long long M = 1000000007;
const long long MAXL = 1000000;
typedef long long int lli;

int main() {
    int n;
    while (cin >> n) {
        lli ans = 1;
        for(int i = 0;i < n;i ++){
            int tmp;
            scanf("%d",&tmp);
            ans = ans * (tmp + 1) % M;
        }
        printf("%lld\n",ans);
    }
    return 0;
}
//Problem I 很神奇,y-x总是能够被9整除。
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner Cin = new Scanner(System.in);
        while (Cin.hasNext()) {
            BigInteger x = Cin.nextBigInteger();
            char[] y = x.toString().toCharArray();
            for (int i = 0; i < y.length - i - 1; i++) {
                char tmp = y[i];
                y[i] = y[y.length - i - 1];
                y[y.length - i - 1] = tmp;
            }
            String z = new String(y);
            BigInteger p = new BigInteger(z);
            char[] q = p.subtract(x).divide(BigInteger.valueOf(9)).abs().toString().toCharArray();
            boolean flag = true;
            for(int i = 1;i < q.length;i ++){
                if(q[i] != q[i - 1]){
                    flag = false;
                }
            }
            if(flag)    System.out.println("YES");
            else        System.out.println("NO");
        }
    }
}
//Problem L,异或函数fx的最大值等于最大元素的值
#include <bits/stdc++.h>

using namespace std;
int T,a[10001],s,mx,n;


int main() {
    scanf("%d",&T);
    while (T--) {
        s=mx=0;
        scanf("%d",&n);
        for (int i=0;i<n;++i) {
            scanf("%d",&a[i]);
            s=max(s,a[i]);

        }
        printf("%d\n",s);
    }
    return 0;
}
ACM-ICPC(国际大学程序设计竞赛)是一项全球性的大学程序设计比赛,每年吸引来自世界各地的顶尖大学代表队参与。ACM-ICPC竞赛的核心内容是团队编程和问题解决能力。 首先,ACM-ICPC竞赛对参赛选手的编程能力要求很高。参赛队伍需要在规定的时间内解决一系列的算法问题,这些问题常常包含复杂的数据结构和算法,要求选手在有限的时间内设计和实现高效的程序。 其次,ACM-ICPC竞赛强调团队协作。每个队伍由三名选手组成,他们需要分工合作,保持良好的沟通与协调,共同解决问题。团队成员需要相互理解、相互信任,快速地协商和决策,同时要保持高效的任务分配和时间管理。 此外,ACM-ICPC竞赛也需要选手具备良好的问题解决能力。这些问题往往是实际应用或理论推导相关的,选手需要从数学、计算机科学和算法等多个角度出发,找到最佳解决方案。在面对问题时,选手需要对问题进行分析、抽象和建模,运用各种算法和数据结构进行解决。 对于参赛选手来说,ACM-ICPC提供了一个学习与交流的平台。在比赛中,选手可以接触到不同国家和地区的优秀程序设计人才,学习他们的思维方式和编程技巧。同时,ACM-ICPC还举办了一系列的培训和研讨会,让选手有机会深入了解计算机科学和算法领域最新的研究成果。 总之,ACM-ICPC国际大学程序设计竞赛是一个挑战性与学习性兼具的比赛。它要求选手具备扎实的编程技能、团队合作能力和问题解决能力。参与此竞赛不仅可以锻炼自己的编程能力,还能与全球的顶尖程序设计人才进行交流,拓宽自己的视野和思维方式。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值