JXNU 新生选拔赛

1001

最小的数

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 28   Accepted Submission(s) : 4

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

定义一种正整数集合K,集合中有N个数,集合中元素Ki(1<=i<=N)是包含i个不同质因子的最小的数。因为Ki可能会很大,所以将集合中所有Ki对10^9+7取余。

Input

本题只有唯一一组测试数据,第一行给出N,q,表示K的个数以及q次询问。1<=N<=1000,q<=10^5.
接下来q行每行一个正整数(64位整数范围内),请判断其对10^9+7取余后,是否在集合K中。

Output

对于每次询问,根据题意输出Yes或No

Sample Input

3 3
2
6
33

Sample Output

Yes
Yes
No
解题思路:先求出1000个素数,在按条件存入容器中就行了。
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll a[1000006],vis[1000006],n,m,x;
set<ll>s;
void init()
{
    memset(a,0,sizeof(a));
    int pos=0;
    for(int i=2;i<=1000000;i++)
    {
        if(a[i]==1) continue;
        vis[++pos]=i;
        if(pos>=1000) break;
        for(int j=2;j*i<=1000000;j++)
        {
            a[i*j]=1;
        }
    }
}
int main()
{
    init();
    while(scanf("%lld%lld",&n,&m)!=EOF)
    {
        int ans=1;
        s.clear();
        for(int i=1;i<=n;i++)
        {
            ans=(ans*vis[i])%MOD;
            s.insert(ans);
        }
        while(m--)
        {
            scanf("%lld",&x);
            if(s.count(x)==0) puts("No");
            else puts("Yes");
        }
    }
}

1002

不安全字符串

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 29   Accepted Submission(s) : 3

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

集训十分无聊,于是boss发明了一个“益智”游戏——假设有一段仅由U和L构成的字符串,我们定义当连续的U的个数大于等于三的时候,这个字符串是不安全的。现告诉你字符串的长度n,请你算出能够生成多少个不安全字符串。

Input

输入有多组,每组仅输入一个n,代表字符串的长度,当n等于0的时候输入结束。(4<=n<=30)

Output

输出可生成的不安全字符串的个数。

Sample Input

4
5
0

Sample Output

3
8

Hint:对于第一个样例,当n为4的时候,我们满足条件的有 UUUU LUUU UUUL 三种情况
思路:打表dp[i][0]没有三个连续U的序列最右边为Ldp[i][1]没有三个连续U的序列最右边有一个Udp[i][2]没有三个连续U的序列最右边有两个连续的Udp[i][3]有三个连续的U的序列1.dp[i][0]可以由dp[i-1][0]+dp[i-1][1]+dp[i-1][2]转变过来,因为前一状态只要不是有了3个连续的U的序列,在最右边加一个L就可以形成2.dp[i][1]可以由dp[i - 1][0]转变过来,因为只能是在最右边没有U的序列加上个U形成3.dp[i][2]可以由dp[i - 1][1]转变过来,因为只能是在最右边有一个U的序列加上个U形成3.dp[i][3]可以由dp[i - 1][3] * 2 + dp[i - 1][2]转变过来,因为如果原本就是有连续3个U的序列最右边加上什么都是该情况,然后也可以在最右边有两个U的序列加上个U形成
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int dp[35][5],n;
void init()
{
    dp[1][0]=1;dp[1][1]=1;dp[1][2]=0;dp[1][3]=0;
    for(int i=2;i<32;i++)
    {
        dp[i][0]=dp[i-1][0]+dp[i-1][1]+dp[i-1][2];
        dp[i][1]=dp[i-1][0];
        dp[i][2]=dp[i-1][1];
        dp[i][3]=dp[i-1][3]*2+dp[i-1][2];
    }
}
int main()
{
    init();
    while(scanf("%d",&n)&& n)
    {
        printf("%d\n",dp[n][3]);
    }
}
//***************************************************************/
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll a[55]={0, 0, 1, 3, 8, 20, 47, 107, 238, 520, 1121, 2391, 5056, 10616, 22159,
    46023, 95182, 196132, 402873, 825259, 1686408, 3438828, 6999071, 14221459, 28853662,
    58462800, 118315137, 239186031, 483072832, 974791728, 1965486047};
int main()
{
    int n;
    while(scanf("%d",&n)&&n)
    {
        printf("%lld\n",a[n-1]);
    }
}

1003

壮壮的数组

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 4   Accepted Submission(s) : 0

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

A,B,C为三个元素个数为n的数组,A={a1,a2,a3...an},B={b1,b2,b3...bn},C={c1,c2,c3...cn};
已知A、B数组,而且有ci等于ai或bi(1<=i<=n),毫无疑问,C数组有很多种组合。
但是zz不希望C数组全由A数组或者B数组组成,每一种组合都有一个K值,K=c1*c2*c3*...*cn。
现在需要你求出每一种组合对应的K值,并将它们加起来的结果。这个结果可能会很大,请将答案对1e9+7取模。
例如A={1,2,3} B={2,2,4}。
C数组可能为{a1,b2,b3} {b1,a2,b3} {b1,b2,a3} {a1,a2,b3} {a1,b2,a3} {b1,a2,a3}
K值分别为8,16,12,8,6,12,所以你应该输出62。

大量输入,建议使用scanf

Input

输入数据包含多个测试实例,每个测试实例的第一行只有一个整数n(1<=n<=100000),表示A,B,C数组元素个数,第二行有n个数据表示a1
a2 a3...an,第三行有n个数据表示b1 b2 b3...bn,(1<=ai,bi<=1e9)。处理到文件的结束。

Output

对于每个测试实例,输出一行数据表示问题的答案,请将答案对1e9+7取模。

Sample Input

3
1 2 3
2 2 4
1
3
4

Sample Output

62
0

1004

涛涛的Party

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 33   Accepted Submission(s) : 2

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

涛神因为极强,并且特别帅,所以拥有很多美女的联系方式,每个美女都有自己的食量以及魅力值,大家都知道,物以类聚,人以群分,朋友的朋友就是自己的朋友,所以美女一般都是有自己的美女朋友圈,而且这些美女特别团结,如果她的朋友有没有被邀请的她就不会答应邀请。涛涛想办一个party,但是他只准备了w kg的食物,他想获得最大的美女魅力值,不知道怎么邀请美女,于是他去问你,你能告诉他,他能获得的美女魅力数是多少吗

Input

数据有多组,第一行输入n,m和w(1≤n≤1000,0≤m≤min(n*(n-1)/2,10^5),1≤w≤1000);第二行输入n个整型变量w1,w2,...,wn(1≤wi≤1000)代表美女i的食量;第三行输入n个整型变量b1,b2,...,bn(1≤bi≤106)代表美女i的魅力值;接下来的m行输入两个数x和y(1≤xi,yi≤n,xi≠yi),代表x和y是朋友

Output

输出涛涛能获得的最大魅力值

Sample Input

3 1 5
3 2 5
2 4 2
1 2
4 2 11
2 4 6 6
6 4 2 1
1 2
2 3

Sample Output

6
1

1005

手机信号

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 85   Accepted Submission(s) : 19

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

现在在市面上流传了一款功能极简的手机,在手机上用一个 7×7 的显示屏来显示手机信号,每个区块能显示一个字符。满信号的时候显示如下:

+-----+
|- 4G|
|-- |
|--- |
|---- |
|-----|
+-----+
(杭电描述区块对字宽的设定不统一,正确显示请看输出样例)
每一格信号(第i(1≤i≤5) 格信号有 i个-)代表 20% 的信号强度,不足一格信号的部分不显示。同时会在右上角显示当前的网络传输模式。在信号强度不低于 90% 的时候显示4G;当信号低于 90%、不低于 60% 的时候显示3G;否则显示E。
对于给定的当前信号强度 d%,输出信号的 7×7 像素的图案。

Input

输入一个整数 d(0≤d≤100),表示信号强度。

Output

按照题目要求输出,每行末尾不要输出多余的空白字符。

Sample Input

0
65

Sample Output

+-----+
|    E|
|     |
|     |
|     |
|     |
+-----+
+-----+
|-  3G|
|--   |
|---  |
|     |
|     |
+-----+水题
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        int k=n/20;
        char a[5];
        if(n>=90) a[0]=‘4‘,a[1]=‘G‘;
        else if(n>=60) a[0]=a[0]=‘3‘,a[1]=‘G‘;
        else a[0]=‘ ‘,a[1]=‘E‘;
        printf("+-----+\n");
        for(int i=1;i<=k;i++)
        {
            printf("|");
            for(int j=1;j<=5;j++)
            {
                if(j<=i) printf("-");
                if(i==1 && j==4)
                {
                    if(n>=90)printf("4G");
                    else if(n>=60)printf("3G");
                    else printf(" E");
                    break;
                }
                else if(j>i)printf(" ");
            }
            printf("|\n");
        }
        for(int i=k+1;i<=5;i++)
        {
            printf("|");
            for(int j=1;j<=5;j++)
            {
                if(i==1 && j==4)
                {
                    if(n>=90)printf("4G");
                    else if(n>=60)printf("3G");
                    else printf(" E");
                    break;
                }
                else printf(" ");
            }
            printf("|\n");
        }
        printf("+-----+\n");
    }
    return 0;
}

1006

涛神的城堡

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 37   Accepted Submission(s) : 2

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

涛神有一个城堡给游客参观,涛神特别的强壮,涛神的强壮值是strong,每个游客也有自己的强壮值,涛神为了赚钱,他会选取多个区间去打劫别人,所以如果比涛神弱的,他就要收取他们的强壮值的差值,但是还是有比涛涛强壮的,所以涛涛打劫那个人的话,涛涛要给那个人他们的强壮值的差值,所以涛涛可以选择打不打劫那个区间的人,(人是可以重复打劫的,区间不行)涛涛最多能赚多少钱呢?

Input

第一行给你三个整型变量n,m,strong(1≤n,m≤10000,1≤strong≤200),
第二行给你n个人的强壮值a1,a2,...,an(1≤ai≤200).
接下来m行给你两个整型变量l,r(1≤li≤ri≤n),代表区间里包括了第l个游客到第r个游客,涛涛可以选择打不打劫这个区间

Output

输出涛涛可以打劫到的最多的钱

Sample Input

5 4 10
9 12 9 7 14
1 2
4 5
3 4
1 4

Sample Output

7

1007

dada的GCD

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 36   Accepted Submission(s) : 8

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

C语言都学过了怎么计算两个数的最大公约数,而一段区间[L,R]的GCD即这段区间所有数的最大公约数。现在给你一串长度为n的序列,如果对于序列的任意子区间[L,R],都有这段区间的gcd>=2,那么这段序列就叫做dada的GCD序列。
n<=10^4
序列的每个数小于10^9

Input

第一行有一个整数t,代表t组数据
每组输入有一个正整数n,
随后一行n个正整数。

大量输入,使用cin的同学请关闭stdio同步

Output

如果是dada的GCD序列,就输出Yes,反之输出No

Sample Input

2
3
2 6 4
3
4 6 9

Sample Output

Yes
No
简单判断
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll gcd(ll x,ll y)
{
    return y==0?x:gcd(y,x%y);
}
int main()
{
    ll n,a[10005],b[10005],t;
    scanf("%lld",&t);
    while(t--)
    {
        int m=0;
        scanf("%lld",&n);
        for(int i=0;i<n;i++)
            scanf("%lld",&a[i]);
        for(int i=1;i<n;i++)
        {
            ll x=gcd(a[i],a[i-1]);
            if(x==1)
            {
                puts("No");
                goto k;
            }
            b[m++]=x;
        }
        sort(b,b+m);
        for(int i=1;i<m;i++)
        {
            if(b[i]%b[0]!=0)
            {
                puts("No");
                goto k;
            }
        }
        puts("Yes");
        k:;
    }
    return 0;
}
时间: 2024-08-24 10:30:34

JXNU 新生选拔赛的相关文章

dada的GCD ( jxnu acm新生选拔赛)

1007 dada的GCD,输入格式描述有误,已修正 dada的GCD Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other) Total Submission(s) : 36   Accepted Submission(s) : 8 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description C语

jxnu acm新生选拔赛

最小的数 Problem Description 定义一种正整数集合K,集合中有N个数,集合中元素Ki(1<=i<=N)是包含i个不同质因子的最小的数.因为Ki可能会很大,所以将集合中所有Ki对10^9+7取余. Input 本题只有唯一一组测试数据,第一行给出N,q,表示K的个数以及q次询问.1<=N<=1000,q<=10^5.接下来q行每行一个正整数(64位整数范围内),请判断其对10^9+7取余后,是否在集合K中. Output 对于每次询问,根据题意输出Yes或No

JXNU acm选拔赛 壮壮的数组

壮壮的数组 Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other) Total Submission(s) : 18   Accepted Submission(s) : 8 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description A,B,C为三个元素个数为n的数组,A={a1,a2,a3...

JXNU acm选拔赛 最小的数

最小的数 Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other) Total Submission(s) : 14   Accepted Submission(s) : 8 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description 定义一种正整数集合K,集合中有N个数,集合中元素Ki(1<=i<

JXNU acm选拔赛 涛神的城堡

涛神的城堡 Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other) Total Submission(s) : 42   Accepted Submission(s) : 8 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description 涛神有一个城堡给游客参观,涛神特别的强壮,涛神的强壮值是stro

JXNU acm选拔赛 涛涛的Party

涛涛的Party Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other) Total Submission(s) : 21   Accepted Submission(s) : 8 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description 涛神因为极强,并且特别帅,所以拥有很多美女的联系方式,每个

Solve Equation gcd(x,y)=gcd(x+y,lcm(x,y)) gcd(x,y)=1 =&gt; gcd(x*y,x+y)=1

/** 题目:Solve Equation 链接:http://acm.hnust.edu.cn/JudgeOnline/problem.php?id=1643 //最终来源neu oj 2014新生选拔赛题 题意:给定两个数的和以及他们的最小公倍数,求这两个数. 思路: x+y=A lcm(x,y)=B => x*y/gcd(x,y)=B 要把这两个公式联立,那么必须消掉gcd: 设:d = gcd(x,y), x = kx*d, y = ky*d; kx与ky互质: x+y=A => d(

2019 年「计算机科学与工程学院」新生赛 暨ACM集训队选拔赛 # 1

T1 请问这还是纸牌游戏吗 https://scut.online/p/567 这道题正解据说是方根 这里先放着等以后填坑吧qwq 但是由于这道题数据是随机的 所以其实是有各种水法的(但是我比赛根本没有想到任何水法qwq 第一种水法呢 因为数据随机 所以当数据大小变得比较大的时候 基本乘出来的数已经能覆盖1到P-1了 所以我们直接输出1和P-1就可以了 而数据比较小的时候就可以暴力计算了qwq include<cstdio> #include<cstring> #include&l

[Sdoi2017]新生舞会

[Sdoi2017]新生舞会 http://www.lydsy.com/JudgeOnline/problem.php?id=4819 Time Limit: 10 Sec  Memory Limit: 128 MB[Submit][Status][Discuss] Description 学校组织了一次新生舞会,Cathy作为经验丰富的老学姐,负责为同学们安排舞伴.有n个男生和n个女生参加舞会 买一个男生和一个女生一起跳舞,互为舞伴.Cathy收集了这些同学之间的关系,比如两个人之前认识没计算