JXNU 新生选拔赛
1001
最小的数
Problem Description
Input
接下来q行每行一个正整数(64位整数范围内),请判断其对10^9+7取余后,是否在集合K中。
Output
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[],vis[],n,m,x;
set<ll>s;
void init()
{
memset(a,,sizeof(a));
int pos=;
for(int i=;i<=;i++)
{
if(a[i]==) continue;
vis[++pos]=i;
if(pos>=) break;
for(int j=;j*i<=;j++)
{
a[i*j]=;
}
}
}
int main()
{
init();
while(scanf("%lld%lld",&n,&m)!=EOF)
{
int ans=;
s.clear();
for(int i=;i<=n;i++)
{
ans=(ans*vis[i])%MOD;
s.insert(ans);
}
while(m--)
{
scanf("%lld",&x);
if(s.count(x)==) puts("No");
else puts("Yes");
}
}
}
1002
不安全字符串
Problem Description
Input
Output
Sample Input
4
5
0
Sample Output
3
8 Hint:对于第一个样例,当n为4的时候,我们满足条件的有 UUUU LUUU UUUL 三种情况
思路:打表
dp[i][0]没有三个连续U的序列最右边为L
dp[i][1]没有三个连续U的序列最右边有一个U
dp[i][2]没有三个连续U的序列最右边有两个连续的U
dp[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[][],n;
void init()
{
dp[][]=;dp[][]=;dp[][]=;dp[][]=;
for(int i=;i<;i++)
{
dp[i][]=dp[i-][]+dp[i-][]+dp[i-][];
dp[i][]=dp[i-][];
dp[i][]=dp[i-][];
dp[i][]=dp[i-][]*+dp[i-][];
}
}
int main()
{
init();
while(scanf("%d",&n)&& n)
{
printf("%d\n",dp[n][]);
}
}
//***************************************************************/
#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[]={, , , , , , , , , , , , , , ,
, , , , , , , , , ,
, , , , , };
int main()
{
int n;
while(scanf("%d",&n)&&n)
{
printf("%lld\n",a[n-]);
}
}
1003
壮壮的数组
Problem Description
已知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
Sample Input
3
1 2 3
2 2 4
1
3
4
Sample Output
62
0
注意,inf+MOD-ans+MOD-pos不能省略MOD,避免inf小于ans
//1003
//A{a1,a2};
//B{b2,b2};
//c1=a1,b2,c2=a2,c2;
//k=a1*b2+a2*b1;
//k=(a1+b1)*(a2+b2)-(a1*a2+b1*b2);
#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[],b[];
ll ans,pos,inf,n;
int main()
{
while(scanf("%lld",&n)!=EOF)
{
ans=pos=inf=;
for(int i=;i<=n;i++) scanf("%lld",&a[i]),ans*=a[i],ans%=MOD;
for(int i=;i<=n;i++) scanf("%lld",&b[i]),pos*=b[i],pos%=MOD;
for(int i=;i<=n;i++) inf*=(a[i]+b[i]),inf%=MOD;
printf("%lld\n",(inf+MOD-ans+MOD-pos)%MOD);
}
return ;
}
1004
涛涛的Party
Problem Description
Input
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
并查集+01背包,因为一个小概念不清楚,一直wa,今后的注意
#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 f[],n,m,w,a[],b[];
int c[],d[],vis[],x,y;
int dp[],k;
int find(int x)
{
if(x==f[x]) return x;
return f[x]=find(f[x]);
}
void init(int x,int y)
{
int xx=find(x);
int yy=find(y);
if(xx>yy) f[xx]=yy;
else f[yy]=xx;
}
int main()
{
while(scanf("%d%d%d",&n,&m,&w)!=EOF)
{
for(int i=;i<=n;i++)f[i]=i,c[i]=,d[i]=;
for(int i=;i<=n;i++) scanf("%d",&a[i]);
for(int i=;i<=n;i++) scanf("%d",&b[i]);
while(m--) scanf("%d%d",&x,&y),init(x,y);
for(int i=;i<=n;i++) k=find(i),c[k]+=a[i],d[k]+=b[i];
memset(dp,,sizeof(dp));
for(int i=;i<=n;i++)
{
for(int j=w;j>=c[i];j--)
{
dp[j]=max(dp[j],dp[j-c[i]]+d[i]);
}
}
printf("%d\n",dp[w]);
}
return ;
}
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
+-----+
|- 4G|
|-- |
|--- |
|---- |
|-----|
+-----+
(杭电描述区块对字宽的设定不统一,正确显示请看输出样例)
每一格信号(第i(1≤i≤5) 格信号有 i个-)代表 20% 的信号强度,不足一格信号的部分不显示。同时会在右上角显示当前的网络传输模式。在信号强度不低于 90% 的时候显示4G;当信号低于 90%、不低于 60% 的时候显示3G;否则显示E。
对于给定的当前信号强度 d%,输出信号的 7×7 像素的图案。
Input
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/;
char a[];
if(n>=) a[]='',a[]='G';
else if(n>=) a[]=a[]='',a[]='G';
else a[]=' ',a[]='E';
printf("+-----+\n");
for(int i=;i<=k;i++)
{
printf("|");
for(int j=;j<=;j++)
{
if(j<=i) printf("-");
if(i== && j==)
{
if(n>=)printf("4G");
else if(n>=)printf("3G");
else printf(" E");
break;
}
else if(j>i)printf(" ");
}
printf("|\n");
}
for(int i=k+;i<=;i++)
{
printf("|");
for(int j=;j<=;j++)
{
if(i== && j==)
{
if(n>=)printf("4G");
else if(n>=)printf("3G");
else printf(" E");
break;
}
else printf(" ");
}
printf("|\n");
}
printf("+-----+\n");
}
return ;
}
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
Input
第二行给你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
文字游戏,(人是可以重复打劫的,区间不行),只看区间里的人就行了,所以区间不要去重。
#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 n,m,k,x,y;
ll ans[],pos;
int main()
{
while(scanf("%lld%lld%lld",&n,&m,&k)!=EOF)
{
ans[]=;
for(int i=;i<=n;i++)
{
scanf("%lld",&x);
ans[i]=ans[i-]+k-x;
}
pos=;
while(m--)
{
scanf("%lld%lld",&x,&y);
if((ans[y]-ans[x-])>) pos+=(ans[y]-ans[x-]);
}
printf("%lld\n",pos);
}
return ;
}
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
n<=10^4
序列的每个数小于10^9
Input
每组输入有一个正整数n,
随后一行n个正整数。
大量输入,使用cin的同学请关闭stdio同步
Output
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==?x:gcd(y,x%y);
}
int main()
{
ll n,a[],b[],t;
scanf("%lld",&t);
while(t--)
{
int m=;
scanf("%lld",&n);
for(int i=;i<n;i++)
scanf("%lld",&a[i]);
for(int i=;i<n;i++)
{
ll x=gcd(a[i],a[i-]);
if(x==)
{
puts("No");
goto k;
}
b[m++]=x;
}
sort(b,b+m);
for(int i=;i<m;i++)
{
if(b[i]%b[]!=)
{
puts("No");
goto k;
}
}
puts("Yes");
k:;
}
return ;
}
JXNU 新生选拔赛的更多相关文章
- JXNU暑期选拔赛
最小的数 Time Limit : 3000/1000ms (Java/Other) Memory Limit : 65535/32768K (Java/Other) Total Submissi ...
- 10.0.0.55_12-16训练赛部分writeup
0x1 - MISC MISC100 一张帅行的照片 目测是图片隐写,但是binwalk并没有出来,应该是对文件头进行了修改 010editor查看一下,发现在jpg文件尾之后还有大量的数据 而且在灰 ...
- Solve Equation gcd(x,y)=gcd(x+y,lcm(x,y)) gcd(x,y)=1 => gcd(x*y,x+y)=1
/** 题目:Solve Equation 链接:http://acm.hnust.edu.cn/JudgeOnline/problem.php?id=1643 //最终来源neu oj 2014新生 ...
- Codeforces 801 A.Vicious Keyboard & Jxnu Group Programming Ladder Tournament 2017江西师大新生赛 L1-2.叶神的字符串
A. Vicious Keyboard time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- 2019 年「计算机科学与工程学院」新生赛 暨ACM集训队选拔赛 # 1
T1 请问这还是纸牌游戏吗 https://scut.online/p/567 这道题正解据说是方根 这里先放着等以后填坑吧qwq 但是由于这道题数据是随机的 所以其实是有各种水法的(但是我比赛根本没 ...
- SCNU ACM 2016新生赛决赛 解题报告
新生初赛题目.解题思路.参考代码一览 A. 拒绝虐狗 Problem Description CZJ 去排队打饭的时候看到前面有几对情侣秀恩爱,作为单身狗的 CZJ 表示很难受. 现在给出一个字符串代 ...
- SCNU ACM 2016新生赛初赛 解题报告
新生初赛题目.解题思路.参考代码一览 1001. 无聊的日常 Problem Description 两位小朋友小A和小B无聊时玩了个游戏,在限定时间内说出一排数字,那边说出的数大就赢,你的工作是帮他 ...
- SCNU 2015ACM新生赛决赛【F. Oyk闯机关】解题报告
题目大意:一个$N$$\times$$N$的阵列,每个格子有$X_{ij}$个调和之音,若每次只能选择走右边或下边,从左上角出发走到右下角,问最多能收集到多少个调和之音? ...
- SCNU 2015ACM新生赛初赛【1007. ZLM的扑克牌】解题报告
题目链接详见SCNU 2015新生网络赛 1007. ZLM的扑克牌 . 其实我在想这题的时候,还想过要不要设置求最小的排列,并且对于回文数字的话,可以把扑克牌折起来( ...
随机推荐
- 关于Github Pages
迁移Github Pages 我稍微有一点强迫症,实在是忍受不了整洁的界面有一些推广的广告.正所谓博客平台不重要,重要的是要有干货,CSDN首页满屏的广告也就忍受了,但是自己的文章的页面有广告看着实在 ...
- Android视图载入到窗体的过程分析
上一篇博客Android中Handler原理在讲到Handler的时候谈到了android的Activity启动是怎样运行到onCreate方法的,这篇主要从onCreate方法里面我们必需要写的方法 ...
- git commit template
https://www.zhihu.com/question/27462267/answer/204658544 https://gist.github.com/adeekshith/cd4c95a0 ...
- net.sf.json Maven依赖配置
转自:https://blog.csdn.net/qq_36698956/article/details/80772984 今天搭框架开始实现前台的json了,于是逐个找适合的框架,发现要实现json ...
- eclipse启动Tomcat加载项目时报内存溢出错误解决办法
在eclipse中点击Window->Preferences打开全局属性设置对话框,如下图所示设置Tomcat运行时的JVM参数,添加这段JVM设置:-Xms256M -Xmx768M -XX: ...
- css3 文字溢出 换行实现方案
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 如何更改AD域安全策略-密码必须符合复杂性要求
通常我们在域系统-管理工具上面是找不到“域安全策略”的,我们只能找到“本地安全策略”,而更改“本地安全策略”是不会对域产生任何的作用的.下面这个步骤教你如何找到“域安全策略” 1.Start(开始)– ...
- 如何在Ubuntu14.04中创建Python虚拟环境
在Ubuntu14.04中安装Python相对比较容易些,最简单的安装方法就是apt-get安装了,具体的教程可以戳这篇文章:在Ubuntu14.04中如何安装Python3和切换py2和py3环境. ...
- 把书《CUDA By Example an Introduction to General Purpose GPU Programming》读薄
鉴于自己的毕设需要使用GPU CUDA这项技术,想找一本入门的教材,选择了Jason Sanders等所著的书<CUDA By Example an Introduction to Genera ...
- jQuery获取区间随机数
1.自定义函数 function getRandom(min,max){ //x上限,y下限 var x = max; var y = min; if(x<y){ ...