奖学金

模拟

开个struct排序即可 c++吼啊

 /*by SilverN*/
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;
const int mxn=;
int read(){
int x=,f=;char ch=getchar();
while(ch<'' || ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>='' && ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
struct stu{
int ch,ma,en;
int tot;
int id;
}s[];
int cmp(stu a,stu b){
if(a.tot!=b.tot)return a.tot>b.tot;
if(a.ch!=b.ch)return a.ch>b.ch;
return a.id<b.id;
}
int n;
int main(){
n=read();
int i,j;
for(i=;i<=n;i++){
s[i].ch=read();s[i].ma=read();s[i].en=read();
s[i].tot=s[i].ch+s[i].en+s[i].ma;
s[i].id=i;
}
sort(s+,s+n+,cmp);
for(i=;i<=;i++){
printf("%d %d\n",s[i].id,s[i].tot);
}
return ;
}

奖学金

纪念品分组

贪心

价值从小到大排序。每次把最大的和最小的组合在一起(如果不能组合,那么最大的单独成为一组)

 /*by SilverN*/
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;
const int mxn=;
int read(){
int x=,f=;char ch=getchar();
while(ch<'' || ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>='' && ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
int w,n;
int p[mxn];
int main(){
w=read();n=read();
int i,j;
for(i=;i<=n;i++) p[i]=read();
sort(p+,p+n+);
int hd=,tl=n;
int cnt=;
while(hd<=tl){
if(p[hd]+p[tl]<=w)cnt++,hd++,tl--;
else tl--,cnt++;
}
printf("%d\n",cnt);
return ;
}

纪念品分组

守望者的逃离

DP

能闪则闪。不能闪的时候,同时处理原地回蓝和一直跑两个状态,如果回蓝后闪烁比跑的距离更远,就更新距离。

 /*by SilverN*/
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;
const int mxn=;
int m,s,t;
int main(){
scanf("%d%d%d",&m,&s,&t);
int i,j;
int now=;
int tst=;
for(i=;i<=t;i++){
if(m>=){
tst+=;
m-=;
}
else m+=;
if(tst>now+)now=tst;
else now+=;
if(now>=s)break;
}
if(i>t)printf("No\n%d\n",now);
else printf("Yes\n%d\n",i);
return ;
}

守望者的逃离

Hanoi双塔问题

普通的汉诺塔方案数是f(n)=2^n-1

这里因为两个盘等价,方案数直接乘2变成2^(n+1)-2

一个高精乘单精就可以解决,之后末尾直接-2 (因为2的次方数,个位只能是2 4 6 8的一种,所以不需要借位)

 /*by SilverN*/
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;
const int mxn=;
int len=;
int a[mxn];
int main(){
int i,j,n;
scanf("%d",&n);
a[]=;
for(i=;i<=n;i++){
for(j=len;j;j--){
a[j]*=;
a[j+]+=a[j]/;
a[j]%=;
}
if(a[len+]) ++len;
}
a[]-=;
for(i=len;i;i--)printf("%d",a[i]);
printf("\n");
return ;
}

hanoi双塔

[NOIP2007] 普及组的更多相关文章

  1. C++算法代码——纪念品分组[NOIP2007 普及组]

    题目来自:http://218.5.5.242:9018/JudgeOnline/problem.php?id=1099 https://www.luogu.com.cn/problem/P1094 ...

  2. [洛谷P1095]NOIP2007 普及组T3 守望者的逃离

    问题描述 恶魔猎手尤迪安野心勃勃,他背叛了暗夜精灵,率领深藏在海底的娜迦族企图叛变.守望者在与尤迪安的交锋中遭遇了围杀,被困在一个荒芜的大岛上.为了杀死守望者,尤迪安开始对这个荒岛施咒,这座岛很快就会 ...

  3. NOIP2002-2017普及组题解

    虽然普及组一般都是暴力省一,但是有一些题目还是挺难的qwq个人觉得能进TG的题目会在前面打上'*' NOIP2002(clear) #include<bits/stdc++.h> usin ...

  4. NOIP2012 普及组 T3 摆花——S.B.S.

    题目描述 小明的花店新开张,为了吸引顾客,他想在花店的门口摆上一排花,共m盆.通过调查顾客的喜好,小明列出了顾客最喜欢的n种花,从1到n标号.为了在门口展出更多种花,规定第i种花不能超过ai盆,摆花时 ...

  5. NOIP2016普及组复赛解题报告

    提高组萌新,DAY1DAY2加起来骗分不到300,写写普及组的题目聊以自慰. (附:洛谷题目链接 T1:https://www.luogu.org/problem/show?pid=1909 T2:h ...

  6. 05:统计单词数【NOIP2011复赛普及组第二题】

    05:统计单词数 总时间限制:  1000ms 内存限制:  65536kB 描述 一般的文本编辑器都有查找单词的功能,该功能可以快速定位特定单词在文章中的位置,有的还能统计出特定单词在文章中出现的次 ...

  7. [题解]noip2016普及组题解和心得

    [前言] 感觉稍微有些滑稽吧,毕竟每次练的题都是提高组难度的,结果最后的主要任务是普及组抱一个一等奖回来.至于我的分数嘛..还是在你看完题解后写在[后记]里面.废话不多说,开始题解. 第一题可以说的内 ...

  8. NOIP2016普及组

    普及组.代码有空发. 第一题就是买铅笔.暴力模拟绝对可取. 第二题就是回文日期.从t1的年份到t2的年份枚举每一年.头尾要特判. 第三题就是海港.骗了40分. 第四题就是魔法阵.不太好优化. 完.

  9. [NOIP2013] 普及组

    计数问题 纯模拟 #include<cstdio> #include<iostream> using namespace std; int main(){ int n,x; c ...

随机推荐

  1. VS Code 设置取消打开文件目录的自动定位跟踪功能。

    文件-->首选项-->设置-->在搜索栏中搜索:explorer.autoReveal;    去掉勾选即可.

  2. java课程设计全程实录——第1天

    反思,总结昨天: IDE搭建完成: git远程配置失败,处理方式:放弃使用git 主要参考<疯狂java实战演义>中的图书进销存管理系统.但该项目是MySQL,无法直接套用,因为我们学的是 ...

  3. 微信“摇一摇&#183;周边”正式开放

    今日,在微信公开课第三季长沙站现场,微信团队宣布“摇一摇·周边”(以下简称“摇周边”)正式对外开放.拥有微信认证的公众帐号商户,均可通过摇周边的商户申请平台(https://zb.weixin.qq. ...

  4. volley的框架安装与使用

    最后一步非常重要   不然会报错: publish = project.has("release")   替换为: publish = project.hasProperty(&q ...

  5. jvm 脑图

  6. [翻译] API测试最佳实践 - 组织你的测试

    组织你的测试 适用级别:初学者 在最底层,一个测试步骤(Test Step)用来验证一个单独的操作.组合若干测试步骤到测试用例,允许你验证那些被分隔出来的一个一个的功能,这些功能是应用程序所需要的.接 ...

  7. VM virtualBox设置无缝全屏

    设置之前:

  8. iOS-UI控件之UITableView(一)

    UITableView 介绍 UITableView 是用来用列表的形式显示数据的UI控件 举例 QQ好友列表 通讯录 iPhone设置列表 tableView 常见属性 // 设置每一行cell的高 ...

  9. vue2.0 vue.set()

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. 类方法__setattr__,__delattr__,__getattr__

    __getattr__,_delattr_,_getattr_ class Foo: x = 1 def __init__(self, y): self.y = y def __getattr__(s ...