NOIP模拟7
期望得分:100+100+20=220
实际得分:100+95+20=215
T1 洛谷 P1306 斐波那契公约数
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long LL;
LL t[][],ans[][],r[][];
const int mod=1e8;
int gcd(int a,int b)
{
return !b ? a : gcd(b,a%b);
}
void mul(LL a[][],LL b[][])
{
memset(r,,sizeof(r));
for(int i=;i<;i++)
for(int j=;j<;j++)
for(int k=;k<;k++)
r[i][j]+=a[i][k]*b[k][j],r[i][j]%=mod;
for(int i=;i<;i++)
for(int j=;j<;j++)
a[i][j]=r[i][j];
}
int main()
{
int a,b;
scanf("%d%d",&a,&b);
int p=gcd(a,b);
t[][]=t[][]=t[][]=;;
ans[][]=ans[][]=;
if(p== || p==) { printf(""); return ; }
p-=;
while(p)
{
if(p&) mul(ans,t);
mul(t,t); p>>=;
}
printf("%lld",ans[][]);
}
T2 51nod 1431 快乐排队
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1431
贪心
每个点每往上一步-1,每往下一步+1
最上面肯定越大越好
假设所有的点都到最上面
按从大到小的顺序,取最大的作为第一个
然后所有的点每往下移一步就+1
所以从2开始枚举当前要放从上往下的第sum个,如果这个点+sum-1<=上一个,就放
#include<cstdio>
#include<algorithm>
#include<iostream>
#define N 200001
using namespace std;
void read(int &x)
{
x=; char c=getchar();
while(!isdigit(c)) c=getchar();
while(isdigit(c)) { x=x*+c-''; c=getchar(); }
}
int a[N];
int main()
{
int n;
read(n);
for(int i=;i<=n;i++) read(a[i]);
for(int i=;i<=n;i++) a[i]=i-n+a[i];
sort(a+,a+n+,greater<int>());
int last,sum=;
last=a[],sum++;
for(int i=;i<=n;i++)
if(a[i]+sum<=last) last=a[i]+sum,sum++;
if(sum==n) printf("Happy");
else printf("Sad");
}
std 做法:
a[i]+i,不变,排序去重
T3 51nod 1693 水群
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1693
x向i*x连边权为i的边
只需要连素数
经各种研究发现
在<=1e6时,退格操作最多有4个,且只会用到前5个素数
所以dp[i][0]表示 当前长度为i,上一步操作为退格
dp[i][1]表示当前长度为i,上一步可以是任何操作
#include<cstdio>
#include<algorithm>
#define N 1000001
using namespace std;
int p[]={,,,,};
int dp[N][];
int dfs(int x,int y)
{
if(x==) return ;
if(dp[x][y]) return dp[x][y];
dp[x][y]=N;
for(int i=;i<;i++)
if(!(x%p[i])) dp[x][y]=min(dp[x][y],dfs(x/p[i],)+p[i]);
if(!y) return dp[x][y];
// dp[x][0]=dp[x][1];
for(int i=;i<;i++) dp[x][y]=min(dp[x][y],dfs(x+i,)+i);
return dp[x][y];
}
int main()
{
int n;
scanf("%d",&n);
printf("%d",dfs(n,));
}
NOIP模拟7的更多相关文章
- NOIP模拟赛20161022
NOIP模拟赛2016-10-22 题目名 东风谷早苗 西行寺幽幽子 琪露诺 上白泽慧音 源文件 robot.cpp/c/pas spring.cpp/c/pas iceroad.cpp/c/pas ...
- contesthunter暑假NOIP模拟赛第一场题解
contesthunter暑假NOIP模拟赛#1题解: 第一题:杯具大派送 水题.枚举A,B的公约数即可. #include <algorithm> #include <cmath& ...
- NOIP模拟赛 by hzwer
2015年10月04日NOIP模拟赛 by hzwer (这是小奇=> 小奇挖矿2(mining) [题目背景] 小奇飞船的钻头开启了无限耐久+精准采集模式!这次它要将原矿运到泛光之源的矿 ...
- 大家AK杯 灰天飞雁NOIP模拟赛题解/数据/标程
数据 http://files.cnblogs.com/htfy/data.zip 简要题解 桌球碰撞 纯模拟,注意一开始就在袋口和v=0的情况.v和坐标可以是小数.为保险起见最好用extended/ ...
- 队爷的讲学计划 CH Round #59 - OrzCC杯NOIP模拟赛day1
题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的讲学计划 题解:刚开始理解题意理解了好半天,然后发 ...
- 队爷的Au Plan CH Round #59 - OrzCC杯NOIP模拟赛day1
题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的Au%20Plan 题解:看了题之后觉得肯定是DP ...
- 队爷的新书 CH Round #59 - OrzCC杯NOIP模拟赛day1
题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的新书 题解:看到这题就想到了 poetize 的封 ...
- CH Round #58 - OrzCC杯noip模拟赛day2
A:颜色问题 题目:http://ch.ezoj.tk/contest/CH%20Round%20%2358%20-%20OrzCC杯noip模拟赛day2/颜色问题 题解:算一下每个仆人到它的目的地 ...
- CH Round #52 - Thinking Bear #1 (NOIP模拟赛)
A.拆地毯 题目:http://www.contesthunter.org/contest/CH%20Round%20%2352%20-%20Thinking%20Bear%20%231%20(NOI ...
- CH Round #49 - Streaming #4 (NOIP模拟赛Day2)
A.二叉树的的根 题目:http://www.contesthunter.org/contest/CH%20Round%20%2349%20-%20Streaming%20%234%20(NOIP 模 ...
随机推荐
- Scrum立会报告+燃尽图(十月二十二日总第十三次)
此作业要求参见:https://edu.cnblogs.com/campus/nenu/2018fall/homework/2246 项目地址:https://git.coding.net/zhang ...
- 20172305 2018-2019-1 《Java软件结构与数据结构》第九周学习总结
20172305 2018-2019-1 <Java软件结构与数据结构>第九周学习总结 教材学习内容总结 本周内容主要为书第十五章内容: 图(结点和结点之间的连接构成) 顶点:结点 边:结 ...
- OpenCV学习笔记——疑问
vec3b:表示每一个Vec3b对象中,可以存储3个char(字符型)数据,比如可以用这样的对象,去存储RGB图像中的一个像素点.typedef Vec<uchar, 3> Vec3b; ...
- 团队开发——软件需求分析报告(Hello World 团队)
一. 项目名称 超级迷宫 二. 设计背景 随着生活节奏加快,游戏更新速度的加快,游戏大同小异缺少新颖度,同时为了满足多游戏的结合,充实人们的生活,同时增加知识,有协作模式增进友谊和感情,在闲暇 ...
- C#高级编程 (第六版) 学习 第五章:数组
第五章 数组 1,简单数组 声明:int[] myArray; 初始化:myArray = new int[4]; 为数组分配内存. 还可以用如下的方法: int[] myArray = new in ...
- java使用匿名类直接new接口
翻看Vector代码的时候,看到这么一段. /** * Returns an enumeration of the components of this vector. The * returned ...
- Week2-作业1 -阅读《构建之法》
第一章 在阅读第1.2.2节时,感受最深,记得开学初有老师就给我们分析过计算机专业和我们专业的区别,当时是给我们讲的是计算机科学注重的是理论,偏向于硬件方面,而软件工程则注重实践,偏向于软件方面.然很 ...
- sphinx配置 + php
1. 为什么要使用Sphinx 假设你现在运营着一个论坛,论坛数据已经超过100W,很多用户都反映论坛搜索的速度非常慢,那么这时你就可以考虑使用Sphinx了(当然其他的全文检索程序或方法也 ...
- IP地址转换32为长整型
Programming Question: Convert an IPv4 address in the format of null-terminated C string into a 32-bi ...
- linux下面Zookeeper的单机模式(standalone)
1.下载 zk下载地址 http://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/ 我用的是http://mirrors.tuna.tsinghua.e ...