2017年浙江工业大学大学生程序设计迎新赛预赛
来源:互联网 发布:ubuntu 安装net tools 编辑:程序博客网 时间:2024/05/17 06:42
A - 栗酱的亦或和
nim游戏
#include <iostream>#include <string.h>#include <stdio.h>#include <algorithm>using namespace std;const int N = 1e5 + 10;int T,x,y,z,n,m;int a[N];int main(){ scanf("%d",&T); while(T--){ scanf("%d%d",&n,&m); int sum = 0; for(int i=0;i<n;i++){ scanf("%d",&a[i]); if(i==m-1) continue; if(i) sum ^= a[i]; else sum = a[i]; } if(sum==0) printf("Yes\n"); else{ if(sum<a[m-1]) printf("Yes\n"); else printf("No\n"); } } return 0;}
D - 简单的数据结构
模拟
#include <iostream>#include <string.h>#include <stdio.h>#include <algorithm>using namespace std;const int N = 1e6 + 10;bool cmp(int a,int b){ return a>b;}int n,m,a,ope,st[N],be=50000+10,ed=50000+9,re=0,num=0;int main(){ scanf("%d%d",&n,&m); for(int i=0;i<m;i++){ scanf("%d",&ope); if(ope==1||ope==3){ scanf("%d",&a); num++; if(ope==1){ if(re) st[++ed] = a; else st[--be] = a; }else{ if(!re) st[++ed] = a; else st[--be] = a; } }else{ if(!re){ switch(ope){ case 2:be++; num--; break; case 4:ed--; num--; break; case 5:re = !re; break; case 6: printf("%d\n",num); for(int i=be;i<=ed;i++) printf("%d%c",st[i],i==ed?'\n':' '); break; case 7:sort(st+be,st+ed+1); break; } }else{ switch(ope){ case 4:be++; num--; break; case 2:ed--; num--; break; case 5:re = !re; break; case 6: printf("%d\n",num); for(int i=ed;i>=be;i--) printf("%d%c",st[i],i==be?'\n':' '); break; case 7:sort(st+be,st+ed+1,cmp); break; } } } } return 0;}
I - 栗酱数数
暴力
#include <iostream>#include <string.h>#include <stdio.h>using namespace std;int main(){ int n; scanf("%d",&n); for(int i=1; i<=n; i++){ if(!(i%4)) continue; int now = i, flag = 0; while(now){ if(now%10==4) { flag = 1; break; } now /= 10; } if(flag) continue; printf("%d\n",i); } return 0;}
J - 裁缝大师
极坐标#include <iostream>#include <string.h>#include <stdio.h>#include <algorithm>#include <math.h>using namespace std;const int N = 1e5 + 10;const double PI = 4 * atan(1.0);int T;double x,y,z,n,m;int a[N];int main(){ scanf("%d",&T); while(T--){ scanf("%lf%lf%lf%lf",&x,&y,&z,&n); double ang1 = 2 * PI / n; double p = 0; double x0,y0; x0 = x+z; y0 = y; printf("%.2lf %.2lf\n",x0,y0); for(int i=1;i<n;i++){ p -= ang1; x0 = z*cos(p)+x; y0 = z*sin(p)+y; if(fabs(x0)<0.01) x0 = 0; if(fabs(y0)<0.01) y0 = 0; printf("%.2lf %.2lf\n",x0,y0); } } return 0;}
K - 栗酱的连通图
贪心
#include <iostream>#include <string.h>#include <stdio.h>#include <algorithm>using namespace std;const int N = 1e3 + 10;int T,x,y,z,n,m;int a[N];int main(){ scanf("%d",&T); while(T--){ int sum = 0, mx = 0; scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d",&a[i]); sum += a[i]/2; mx = max(mx, a[i]/2); } sum += (n-2) * mx; printf("%d\n",sum); } return 0;}
L - 取数游戏
#include <iostream>#include <string.h>#include <stdio.h>#include <algorithm>using namespace std;const int N = 1e2 + 10;int T,x,y,z,n,m;int a[N];int main(){ scanf("%d",&T); while(T--){ scanf("%d%d%d",&a[0],&a[1],&a[2]); sort(a,a+3); printf("%d%d%d\n",a[2],a[1],a[0]); } return 0;}
贪心
#include <iostream>#include <string.h>#include <stdio.h>#include <algorithm>using namespace std;const int N = 1e3 + 10;int T,x,y,z,n,m;int a[N];int main(){ scanf("%d",&T); while(T--){ scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d",&a[i]); } scanf("%d",&m); sort(a,a+n); x = y = z = -1; for(int i=0;i<n;i++){ if(x<=a[i]) x = a[i] + m; else if(y<=a[i]) y = a[i] + m; else if(z<=a[i]) z = a[i] + m; else { if(x<=y&&x<=z) x += m; else if(y<=x&&y<=z) y += m; else z += m; } } printf("%d\n",max(x,max(y,z))); } return 0;}
阅读全文
0 0
- 2017年浙江工业大学大学生程序设计迎新赛预赛
- 2017年浙江工业大学大学生程序设计迎新赛预赛
- nowcoder 2017年浙江工业大学大学生程序设计迎新赛预赛-栗酱的异或和
- 2017年浙江工业大学大学生程序设计迎新赛预赛-E:小咪买东西(思维)
- 2017年浙江工业大学大学生程序设计迎新赛预赛 J裁缝大师【简单几何】
- nowcoder 2017年浙江工业大学大学生程序设计迎新赛预赛-CC的神奇背包
- 2017年浙江工业大学大学生程序设计迎新赛预赛-K:栗酱的连通图(最大生成树)
- 2017年浙江工业大学大学生程序设计迎新赛预赛 D简单的数据结构【纯 stl -> List 的应用】
- 2017年浙江工业大学大学生程序设计迎新赛热身赛 部分题解
- 2017年浙江工业大学大学生程序设计迎新赛热身赛
- 2017年浙江工业大学大学生程序设计迎新赛决赛—网络同步赛
- 2017年浙江工业大学大学生程序设计迎新赛决赛—网络同步赛
- 2017年浙江工业大学大学生程序设计迎新赛热身赛 Iafter与迷宫 牛客
- 2017年浙江工业大学大学生程序设计迎新赛热身赛之cayun日常之赏月
- 2017年浙江工业大学大学生程序设计迎新赛热身赛-E:递推(矩阵快速幂)
- 2017年浙江工业大学大学生程序设计迎新赛决赛 F-栗酱的不等式 [KMP]
- 2017年浙江工业大学大学生程序设计迎新赛决赛 F栗酱的不等式
- 【2017年浙江工业大学大学生程序设计迎新赛决赛】E 栗酱的数列【思维转化+KMP】
- 思维导图 XMind 8 Pro 中文破解版免费安装激活(图文)教程附下载
- vb实验7-找出小于18000的最大素数
- 在阿里云主机下配置Aria2+WEBUI离线下载
- (十一)内部类和包以及垃圾分代回收
- 在网页中动态显示时间
- 2017年浙江工业大学大学生程序设计迎新赛预赛
- DL-损失函数与优化
- 浙工大程序设计迎新赛预赛
- 月下湿吻,游行,私会诺奖得主:斯坦福人都这么玩!
- bzoj1559 [JSOI2009]密码(AC自动机+状压DP)
- 【运维】略谈Raid级别
- dbimage中如何装载jpg文件 2015-02-27 20:44:15| 分类: 电脑 |举报|字号 订阅 下载LOFTER我的照片书 | dbimage中如何装载jpg文
- 设以带头结点的双向循环链表表示的线性表L=(a1,a2,……,an)。
- MongoDB,分组,聚合