奖学金

模拟

开个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. 417 Pacific Atlantic Water Flow 太平洋大西洋水流

    详见:https://leetcode.com/problems/pacific-atlantic-water-flow/description/ C++: class Solution { publ ...

  2. Codeforces Round #230 (Div. 1)

    A: 题意:给你一个半径为n的圆 求最少阻塞多少个点 才能使所以圆内及圆上的点 都不与外边的点相连  相连是距离为1 只算整数点 这题定住x,y依次递减 判断一下是否4-connect 这个意思就是 ...

  3. VS打包后生成快捷方式:目标指向错误、Icon图标分辨率有误问题解决方案

    1.目标指向错误: 在安装***.msi文件后,对快捷方式-->右键-->属性: 发现目标并非指exe文件. 于是我新建了一个快捷方式,将目标-->指向exe文件,位置Ctrl+v. ...

  4. Aspose.Word 的常见使用(2018-12-26 更新版)

    Aspose.Word 的常见使用 起因 因项目需要,而且使用html转Word的时候,样式不兼容问题,于是只能使用Aspose.Word通过代码生成.下面是通过DocumentBuilder来设计W ...

  5. (四)SpringIoc之Bean装配

    在pom.xml的依赖 <dependencies> <!--测试包--> <dependency> <groupId>junit</groupI ...

  6. poj3368 Frequent values

    思路: 转化为RMQ. 实现: #include <cstdio> #include <cstring> #include <algorithm> using na ...

  7. oracle 时间格式转化以及计算

    --A表中的日期字段 create_date   例如:2017-08-05  转化为2017年8月5日   oracle 在这里的双引号会忽略 select to_char(to_date(tt.c ...

  8. 面试题9-用两个栈来实现一个队列,完成队列的Push和Pop操作

    题目 用两个栈来实现一个队列,完成队列的Push和Pop操作. 队列中的元素为int类型. 思路: 一个栈压入元素,而另一个栈作为缓冲,将栈1的元素出栈后压入栈2中 代码 import java.ut ...

  9. (转) 淘淘商城系列——使用FastDFS-Client客户端进行上传图片的测试

    http://blog.csdn.net/yerenyuan_pku/article/details/72804018 不久之前,我们实现了商品的类目选择这个功能,但这只是万里长征的第一步,我们还有很 ...

  10. C#筆記--DataGridView使用

    1.databingcomplete 当数据源的内容更改时,或者当 DataSource.DataMember 或 BindingContext 属性的值更改时,会引发此事件. 例如,如果要基于内容更 ...