noip2016普及组 题解
T1
- #include <algorithm>
- #include <cstdio>
- using namespace std;
- int main() {
- freopen("pencil.in","r",stdin);
- freopen("pencil.out","w",stdout);
- int n,Min = 0x7fffffff;
- scanf("%d",&n);
- ;i <= ;i++) {
- int number,money,count;
- scanf("%d%d",&number,&money);
- count = n/number;
- if (n%number) count++; //count为需要买的包数
- Min = min(Min,count*money); //取最小的
- }
- printf("%d",Min);
- ;
- }
T2
上考场代码
- #include <cstdio>
- ,,,,,,,,,,,,};
- inline bool check(int date) { //判断是否回文
- ];
- t[] = ;
- while (date) {
- t[++t[]] = date%;
- date /= ;
- }
- ;i <= ;i++)
- -i+]) return false;
- return true;
- }
- inline int next(int i) { //生成下一个日期
- int year,month,day;
- day = (i%)+((i/%)*); //取出日
- i /= ;
- month = (i%)+((i/%)*); //取出月
- i /= ;
- year = (i%)+((i/%)*)+((i/%)*)+i/*; //取出年
- ) && year%) || !(year%)) m[] = ; //判断是否为闰年
- day++; //下一天
- ) { //若到了月底,则变到下一月
- day = ;
- month++;
- }
- ) { //若到了年底,则变到下一年
- month = ;
- year++;
- }
- +year*; //把年月日变成8位数字
- }
- int main() {
- freopen("date.in","r",stdin);
- freopen("date.out","w",stdout);
- ;
- scanf("%d%d",&date1,&date2);
- for (int i = date1;i <= date2;i = next(i)) //生成date1到date2的所有日期
- if (check(i)) ans++; //判断是否回文
- printf("%d",ans);
- ;
- }
T3
70分考场代码
- #include <cstring>
- #include <cstdio>
- #include <map>
- using namespace std;
- ],k[];
- ];
- map<];
- int main() {
- freopen("port.in","r",stdin);
- freopen("port.out","w",stdout);
- scanf("%d",&n);
- ;i <= n;i++) {
- scanf("%d%d",&t[i],&k[i]);
- ;j <= k[i];j++) scanf("%d",&x[i][j]);
- ,R = i,pos = i;
- while (L <= R) {
- ;
- ) {
- pos = mid;
- R = mid-;
- } ;
- }
- ;
- memset(tmp,false,sizeof(tmp));
- for (int j = pos;j <= i;j++)
- ;l <= k[j];l++)
- if (!tmp[x[j][l]]) {
- ans++;
- tmp[x[j][l]] = true;
- }
- printf("%d\n",ans);
- }
- ;
- }
- #include <cstdio>
- #include <queue>
- #include <map>
- using namespace std;
- ,vis[];
- struct Queue { int t,x; };
- queue<Queue> Q;
- inline int read(int &x) { //读入优化
- char ch;
- ');
- x = ch-';
- +ch-';
- }
- int main() {
- freopen("port.in","r",stdin);
- freopen("port.out","w",stdout);
- read(n);
- ;i <= n;i++) {
- int t,k;
- read(t),read(k);
- ,x;i <= k;i++) {
- read(x);
- if (!vis[x]) ans++; //若这个乘客是其他国籍,则统计
- vis[x]++; //统计
- Q.push((Queue){t,x}); //加入队列
- }
- while (true) { //把86400以外的排除
- Queue head = Q.front();
- + <= head.t && head.t <= t) break;
- else {
- vis[head.x]--;
- if (!vis[head.x]) ans--;
- Q.pop();
- }
- }
- printf("%d\n",ans);
- }
- ;
- }
T4
- #include <cstdio>
- int main() {
- ],ans[][];
- scanf("%d%d",&n,&m);
- ;i <= m;i++) scanf("%d",&x[i]);
- ;a <= m;a++)
- ;b <= m;b++)
- if (a != b)
- ;c <= m;c++)
- if (c != a && c != b && (double)x[b]-(double)x[a] < (double)((double)x[c]-(double)x[b])/3.0)
- ;d <= m;d++)
- *(x[d]-x[c])) {
- ans[a][]++;
- ans[b][]++;
- ans[c][]++;
- ans[d][]++;
- }
- ;i <= m;i++) printf(],ans[i][],ans[i][],ans[i][]);
- ;
- }
4重循环是用不到n的,没有白给的条件,没有没用的数据!!!
- #include <cstdio>
- ],vis[],a[],b[],c[],d[];
- int main() {
- freopen("magic.in","r",stdin);
- freopen("magic.out","w",stdout);
- scanf("%d%d",&n,&m);
- ;i <= m;i++) {
- scanf("%d",&x[i]);
- vis[x[i]]++; //把所有数记在数轴上
- }
- ;i <= n/;i++) { //枚举CD的长度
- ;
- +;j <= n;j++) {
- sum += vis[j-(*i+)]*vis[j-(*i+)+*i];
- d[j] += sum*vis[j-i];
- c[j-i] += sum*vis[j];
- }
- sum = ;
- *i+);j >= ;j--) { //枚举CD两点,确定AB的个数
- sum += vis[j+(*i+)]*vis[j+(*i+)-i];
- a[j] += sum*vis[j+*i];
- b[j+*i] += sum*vis[j];
- }
- }
- ;i <= m;i++) printf("%d %d %d %d\n",a[x[i]],b[x[i]],c[x[i]],d[x[i]]);
- ;
- }
noip2016普及组 题解的更多相关文章
- [题解]noip2016普及组题解和心得
[前言] 感觉稍微有些滑稽吧,毕竟每次练的题都是提高组难度的,结果最后的主要任务是普及组抱一个一等奖回来.至于我的分数嘛..还是在你看完题解后写在[后记]里面.废话不多说,开始题解. 第一题可以说的内 ...
- noip2016普及组题解和心得
前言 感觉稍微有些滑稽吧,毕竟每次练的题都是提高组难度的,结果最后的主要任务是普及组抱一个一等奖回来.至于我的分数嘛..还是在你看完题解后写在[后记]里面.废话不多说,开始题解. (其实这篇博客只有题 ...
- NOIP2016普及组解题报告
概述 \(NOIP2016\)普及组的前三题都比较简单,第四题也有很多的暴力分,相信参加了的各位\(OIer\)在\(2016\)年都取得了很好的成绩. 那么,我将会分析\(NOIP2016\)普及组 ...
- NOIP2008普及组题解
NOIP2008普及组题解 从我在其他站的博客直接搬过来的 posted @ 2016-04-16 01:11 然后我又搬回博客园了233333 posted @ 2016-06-05 19:19 T ...
- NOIP2016普及组复赛解题报告
提高组萌新,DAY1DAY2加起来骗分不到300,写写普及组的题目聊以自慰. (附:洛谷题目链接 T1:https://www.luogu.org/problem/show?pid=1909 T2:h ...
- NOIP2002-2017普及组题解
虽然普及组一般都是暴力省一,但是有一些题目还是挺难的qwq个人觉得能进TG的题目会在前面打上'*' NOIP2002(clear) #include<bits/stdc++.h> usin ...
- 【做题记录】[NOIP2016 普及组] 魔法阵
P2119 魔法阵 2016年普及组T4 题意: 给定一系列元素 \(\{X_i\}\) ,求满足以下不等式的每一个元素作为 \(a,b,c,d\) 的出现次数 . \[\begin{cases}X_ ...
- NOIP2016普及组
普及组.代码有空发. 第一题就是买铅笔.暴力模拟绝对可取. 第二题就是回文日期.从t1的年份到t2的年份枚举每一年.头尾要特判. 第三题就是海港.骗了40分. 第四题就是魔法阵.不太好优化. 完.
- NOIP2008普及组 题解 -SilverN
T1 ISBN号码 题目描述 每一本正式出版的图书都有一个ISBN号码与之对应,ISBN码包括9位数字.1位识别码和3位分隔符, 其规定格式如“x-xxx-xxxxx-x”,其中符号“-”就是分隔符( ...
随机推荐
- VBS基本语法
一.初识VBS Vbs 是一种变量无关.解释性执行的脚本语言.vbs语言中不区分大小写.语句以换行结束. dim 声明变量:批量名称声明,多个变量之间用逗号分隔: set ...
- mysql5.6 无法使用64odbc连接
win10 64位,mysql5.6 无法使用64 连接odbc,处理:装32位odbc, 使用C:\Windows\SysWOW64\odbcad32.exe 配置.
- updateByPrimaryKey和updateByPrimaryKeySelective insert和insertSelective
这两个update都是使用generator生成的mapper.xml文件中,对dao层的更新操作 updateByPrimaryKey对你注入的字段全部更新(不判断是否为Null) updateBy ...
- Spring Security4实例(Java config 版) —— Remember-Me
本文源码请看这里 相关文章: Spring Security4实例(Java config版)--ajax登录,自定义验证 Spring Security提供了两种remember-me的实现,一种是 ...
- 如何在python脚本里面连续执行adb shell后面的各种命令
如何在python脚本里面连续执行adb shell后面的各种命令 adb shell "cd /data/local && mkdir tmp" adb shel ...
- Akka(14): 持久化模式:PersistentActor
Akka程序的特点之一就是高弹性或者强韧性(resilient)的,因为Actor具有自我修复的能力.当Actor模式的程序出现中断情况如:系统崩溃.人为终结等,系统在重启后有关Actor可以恢复之前 ...
- Oozie时出现org.apache.oozie.service.ServiceException: E0103: Could not load service classes, Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
不多说,直接上干货! 问题详情 查看你的$OOZIE_HOME/logs 我的是/home/hadoop/app/oozie-4.1.0-cdh5.5.4/logs/oozie.log文件 [hado ...
- oracle-sql入门练习及答案
1,通过命令行方式打开sqlplus2,执行登录命令sqlplus scott/scott@192.168.248.129/orcl3进行sqlplus命令测试Set time onSet pages ...
- Apache FtpServer 实现文件的上传和下载
1 下载需要的jar包 Ftp服务器实现文件的上传和下载,主要依赖jar包为: 2 搭建ftp服务器 参考Windows 上搭建Apache FtpServer,搭建ftp服务器 3 主要代码 在ec ...
- 查看ubuntu的内核版本&获取roo…
1.查看内核版本命令 [root@AY130616190837708391Z ~]# cd .. (管理员权限) [root@AY130616190837708391Z /]# cd proc [ro ...