Extended Twin Composite Number

The 19th Zhejiang University Programming Contest Sponsored by TuSimple (Mirror) - J

题目链接:http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5977

Do you know the twin prime conjecture? Two primes  and  are called twin primes if . The twin prime conjecture is an unsolved problem in mathematics, which asks for a proof or a disproof for the statement "there are infinitely many twin primes".

On April 17, 2013, Yitang Zhang announced a proof that for some integer  that is less than 70 million, there are infinitely many pairs of primes that differ by . As of April 14, 2014, one year after Zhang's announcement, the bound has been reduced to 246. People are hoping for the bound to be smaller and smaller, so that a proof for the conjecture can finally be found.

For our dear contestants, we've prepared another similar problem for you, which is the extended twin composite number problem: Given a positive integer , find two integers  and  such that  and both  and  are composite numbers.

Input

There are multiple test cases. The first line of the input contains an integer  (about ), indicating the number of test cases. For each test case:

The only line contains one integer  ().

Output

For each test case output two integers in one line, indicating  and  where . If there are multiple valid answers, you can print any of them; If there is no valid answer, output "-1" (without quotes) instead.

Sample Input

3
11
1805296
5567765

Sample Output

4 15
114514 1919810
111234 5678999

题目大意:

给出一个n找到一个x,y使得x+n=y,应当注意的是x,y指的是合数。因此我们可以得到 kn+n=(k-1)n

这样 kn-(k-1)n等于n而且可以保证 kn和(k-1)n为合数。

代码:

#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
    int t;
    scanf("%d",&t);
    while(t--){
        long long n;
        scanf("%lld",&n);
        if(n==1)            //n==1的情况需要特判,随便满足条件的一组就可以
            printf("14 15\n");
        else
            printf("%lld %lld\n",2*n,3*n);
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/Krismile_/article/details/89810955