zoukankan      html  css  js  c++  java
  • codeforce 1474B Different Divisors 模拟 素数筛 C

    **------------恢复内容开始------------**

    codeforce 1474B Different Divisors 模拟 素数筛 C
    B. Different Divisors
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    Positive integer xx is called divisor of positive integer yy, if yy is divisible by xx without remainder. For example, 11 is a divisor of 77 and 33 is not divisor of 88.

    We gave you an integer dd and asked you to find the smallest positive integer aa, such that

    • aa has at least 44 divisors;
    • difference between any two divisors of aa is at least dd.
    Input

    The first line contains a single integer tt (1t30001≤t≤3000) — the number of test cases.

    The first line of each test case contains a single integer dd (1d100001≤d≤10000).

    Output

    For each test case print one integer aa — the answer for this test case.

    Example
    input
    Copy
    2
    1
    2
    
    output
    Copy
    6
    15
    
    Note

    In the first test case, integer 66 have following divisors: [1,2,3,6][1,2,3,6]. There are 44 of them and the difference between any two of them is at least 11. There is no smaller integer with at least 44 divisors.

    In the second test case, integer 1515 have following divisors: [1,3,5,15][1,3,5,15]. There are 44 of them and the difference between any two of them is at least 22.

    The answer 1212 is INVALID because divisors are [1,2,3,4,6,12][1,2,3,4,6,12]. And the difference between, for example, divisors 22 and 33 is less than d=2d=2.

    分析

    要求两个因子之间至少差d,至少四个,最好是素数

    那数据1e4。也不大,打表素数,挨个寻找,找到两个就可以了。

    代码

     https://codeforces.com/contest/1474/submission/105586801

    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <vector>
    #include <math.h>
    #include <string.h>
    #include <algorithm>
    #include <iostream>
    #include <string>
    #include <sstream>
    #include <iostream>
    #include <time.h>
    #include <queue>
    #include <list>
    #include <map>
    #include <set>
    #include <vector>
    #include <stack>
    #include <string.h>
    #include <bitset>
    #define sf scanf
    #define pf printf
    #define lf double
    #define p123 printf("123
    ");
    #define pn printf("
    ");
    #define pk printf(" ");
    #define p(n) printf("%d",n);
    #define pln(n) printf("%d
    ",n);
    #define s(n) scanf("%d",&n);
    #define ss(n) scanf("%s",n);
    #define ps(n) printf("%s",n);
    #define sld(n) scanf("%lld",&n);
    #define pld(n) printf("%lld",n);
    #define slf(n) scanf("%lf",&n);
    #define plf(n) printf("%lf",n);
    #define sc(n) scanf("%c",&n);
    #define pc(n) printf("%c",n);
    #define gc getchar();
    #define ll long long
    #define re(n,a) memset(n,a,sizeof(n));
    #define len(a) strlen(a)
    #define eps 1e-13
    #define zero(x) (((x) > 0? (x):(-x)) < eps)
    using namespace std;
    int a[40000];
    int main(){
        int t;
        s(t)
        int maxi = 30505;
        for(int i = 0; i <= maxi; i ++){
            a[i] = 1;
        }
        for(int i = 2; i <= maxi; i ++){
            if(a[i] == 1){
                for(int j = i*i; j <= maxi; j += i){
                    a[j] = 0;
                }
            }
        }
        while(t --){
            int n;
            s(n)
            int x,y;
            for(int i = 1+n; i <= maxi; i ++){
                if(a[i] == 1){
                    x = i;
                    break;
                }
            }
            for(int i = x+n; i <= maxi; i ++){
                if(a[i] == 1){
                    y = i;
                    break;
                }
            }
            p(x*y) pn
        }
        return 0;
    }
  • 相关阅读:
    Extjs Ext.extend函数的使用
    Silverlight 4 用户名密码验证提示
    Balsamiq Mockups
    自定义RDLC报表的数据集(手工编辑rdlc文件,配置数据集)
    VS2010 帮助文档离线安装
    为 Silverlight 客户端生成服务
    将Win7电脑改造成无线路由
    RDLC报表:每页显示N条记录
    C# 禁止ALT+F4
    让C#程序run anywhere 脱离.net Framework框架环境
  • 原文地址:https://www.cnblogs.com/Kidgzz/p/14342035.html
Copyright © 2011-2022 走看看