T1:n<=1e6,求最小的区间包含(1,m)的所有数。

=>双指针扫一遍即可

#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
using namespace std;
#define rep(i,s,t) for(int i=s;i<=t;i++)
#define dwn(i,s,t) for(int i=s;i>=t;i--)
#define clr(x,c) memset(x,c,sizeof(x))
int read(){
int x=0;char c=getchar();
while(!isdigit(c)) c=getchar();
while(isdigit(c)) x=x*10+c-'0',c=getchar();
return x;
}
const int nmax=1e6+5;
const int maxn=2e3+5;
const int inf=0x7f7f7f7f;
int a[nmax],cnt[maxn];
int main(){
freopen("Exhibit.in","r",stdin);freopen("Exhibit.out","w",stdout);
int n=read(),m=read();rep(i,1,n) a[i]=read();
int r=1,sm=0,ans=inf,res;
rep(i,1,n){
while(sm<m&&r<=n) {
if(++cnt[a[r]]==1) ++sm;++r;
}--r;
//printf("(%d %d)\n",i,r);
if(sm==m){
if(ans>r-i+1) ans=r-i+1,res=i;
}
else break;
if(r==n) break;
if(!--cnt[a[i]]) --sm;++r;
}
printf("%d %d\n",res,res+ans-1);
fclose(stdin);fclose(stdout);
return 0;
}
/*
12 5
2 5 3 1 3 2 4 1 1 5 4 3
*/

T2:1000*1000的矩阵,求有多少个联通块。内存限制1M

=>懒得写暴力的了。。。正解似乎是并查集。我学的是ccz大爷的压位。就是压三位,其实多压几位也可以,char的范围是[-128,128],然后就可以省下了一大堆空间。。然后ccz大爷写的bfs很好看。。。学了%%%

#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
using namespace std;
#define rep(i,s,t) for(int i=s;i<=t;i++)
#define dwn(i,s,t) for(int i=s;i>=t;i--)
#define clr(x,c) memset(x,c,sizeof(x))
char s[126][1001];
short q[4096][2];
#define push(x,y) ++qr,q[qr&4095][0]=x,q[qr&4095][1]=y,s[x>>3][y]-=(1<<(x&7))
void bfs(int x,int y){
int ql=1,qr=1;q[1][0]=x;q[1][1]=y;
while(ql<=qr){
x=q[ql&4095][0],y=q[ql&4095][1];++ql;
if(s[(x-1)>>3][y]&(1<<((x-1)&7))) push(x-1,y);
if(s[(x+1)>>3][y]&(1<<((x+1)&7))) push(x+1,y);
if(s[x>>3][y+1]&(1<<(x&7))) push(x,y+1);
if(s[x>>3][y-1]&(1<<(x&7))) push(x,y-1);
}
}
int main(){
freopen("Part.in","r",stdin);freopen("Part.out","w",stdout);
int n,u,v,d,tmp,temp;scanf("%d",&n);
rep(i,1,n) rep(j,1,n) {
scanf("%d",&u),s[i>>3][j]|=(1-u)<<(i&7);
//printf("(%d %d):%d\n",i,j,s[i>>3][j]);
}
int ans=0;
rep(i,1,n) rep(j,1,n) if(s[i>>3][j]&(1<<(i&7))) bfs(i,j),++ans;
printf("%d\n",ans);
fclose(stdin);fclose(stdout);
return 0;
}
/*
5
1 0 0 1 0
0 0 0 0 1
0 1 0 1 0
1 0 1 0 1
0 0 0 0 0
*/

T3:给一个数n,将n分解成若干个数的和。求最大的最小公倍数。答案<=1e25;

=>不会写。。。正解是利用一个性质就是2*3>2+3 f[2*3]<f[2+3],所以每一个数必定只含有一个质因子。那么dp一下就可以了,然后再高精度。。

=>然后高精度很少写operator<的时候一直弄错。。。而且100以内的质数表自己手写写错了T_T。。。maya

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
using namespace std;
#define rep(i,s,t) for(ll i=s;i<=t;i++)
#define dwn(i,s,t) for(int i=s;i>=t;i--)
#define clr(x,c) memset(x,c,sizeof(x))
#define ll long long
const int a[]={0,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
struct node{
int s[30],n;
node(int _n=0){
n=_n;clr(s,0);
}
node operator*(int k){
node res(n);
rep(i,1,n) res.s[i]=s[i]*k;
rep(i,1,res.n) if(res.s[i]>=10) res.s[i+1]+=res.s[i]/10,res.s[i]%=10;
if(res.s[n+1]) res.n++;
for(;res.s[res.n];++res.n) if(res.s[res.n]>=10) {
res.s[res.n+1]+=res.s[res.n]/10;
res.s[res.n]%=10;
}--res.n;
return res;
}
node operator=(int x){
for(n=0;x;x/=10) s[++n]=x%10;
return *this;
}
node operator=(const node&o){
n=o.n;
rep(i,1,n) s[i]=o.s[i];
return *this;
}
bool operator<(const node&o){
if(n<o.n) return 1;
if(n>o.n) return 0;
dwn(i,n,1){
if(s[i]<o.s[i]) return 1;
if(s[i]>o.s[i]) return 0;
}
return 0;
}
void write(){
dwn(i,n,1) printf("%d",s[i]);printf("\n");
}
};
node f[30][1200];
int main(){
freopen("Lcm.in","r",stdin);freopen("Lcm.out","w",stdout);
int n;scanf("%d",&n);
rep(i,0,n) f[0][i]=1;
rep(i,1,25){
rep(j,a[i],n){
f[i][j]=f[i-1][j];
for(int k=a[i];k<=j;k=k*a[i]) if(f[i][j]<f[i-1][j-k]*k){
f[i][j]=f[i-1][j-k]*k;
}
}
}
node ans=0;
rep(i,1,25) if(ans<f[i][n]) ans=f[i][n];
ans.write();
fclose(stdin);fclose(stdout);
return 0;
}
/*
30
2 2 3 5 7 11
*/

noip模拟赛#45的更多相关文章

  1. NOIP模拟赛20161022

    NOIP模拟赛2016-10-22 题目名 东风谷早苗 西行寺幽幽子 琪露诺 上白泽慧音 源文件 robot.cpp/c/pas spring.cpp/c/pas iceroad.cpp/c/pas ...

  2. contesthunter暑假NOIP模拟赛第一场题解

    contesthunter暑假NOIP模拟赛#1题解: 第一题:杯具大派送 水题.枚举A,B的公约数即可. #include <algorithm> #include <cmath& ...

  3. NOIP模拟赛 by hzwer

    2015年10月04日NOIP模拟赛 by hzwer    (这是小奇=> 小奇挖矿2(mining) [题目背景] 小奇飞船的钻头开启了无限耐久+精准采集模式!这次它要将原矿运到泛光之源的矿 ...

  4. 大家AK杯 灰天飞雁NOIP模拟赛题解/数据/标程

    数据 http://files.cnblogs.com/htfy/data.zip 简要题解 桌球碰撞 纯模拟,注意一开始就在袋口和v=0的情况.v和坐标可以是小数.为保险起见最好用extended/ ...

  5. 队爷的讲学计划 CH Round #59 - OrzCC杯NOIP模拟赛day1

    题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的讲学计划 题解:刚开始理解题意理解了好半天,然后发 ...

  6. 队爷的Au Plan CH Round #59 - OrzCC杯NOIP模拟赛day1

    题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的Au%20Plan 题解:看了题之后觉得肯定是DP ...

  7. 队爷的新书 CH Round #59 - OrzCC杯NOIP模拟赛day1

    题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的新书 题解:看到这题就想到了 poetize 的封 ...

  8. CH Round #58 - OrzCC杯noip模拟赛day2

    A:颜色问题 题目:http://ch.ezoj.tk/contest/CH%20Round%20%2358%20-%20OrzCC杯noip模拟赛day2/颜色问题 题解:算一下每个仆人到它的目的地 ...

  9. CH Round #52 - Thinking Bear #1 (NOIP模拟赛)

    A.拆地毯 题目:http://www.contesthunter.org/contest/CH%20Round%20%2352%20-%20Thinking%20Bear%20%231%20(NOI ...

随机推荐

  1. 1.5 webshell文件上传漏洞分析溯源(1~4)

    webshell文件上传漏洞分析溯源(第一题) 我们先来看基础页面: 先上传1.php ---->   ,好吧意料之中 上传1.png  ---->   我们查看页面元素 -----> ...

  2. Django 之验证码实现

    1. django-simple-captcha 模块 安装 django-simple-captcha pip install django-simple-captcha pip install P ...

  3. 根据xml文件自动生成xsd文件

    根据xml生成xsd文档 1. 找到vs自带的xsd.exe工具所在的文件夹位置: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin 注意 ...

  4. U3D Buildin shader

  5. UIPI VS与Win7 共舞:用户界面特权隔离

    http://tech.it168.com/a2009/0924/737/000000737968.shtml [IT168 专稿]在上文中,我们介绍了操作系统服务的Session 0隔离,通过Ses ...

  6. [转]监控常用TCODE

    1  系统监视 1.1 进程监视 SM66/SM50 进程查看 管理员需全天监看系统的进程.长时间运行的后台工作,有缺陷的报表程序,若不进行控制都将消耗掉大量的系统资源.管理员用这个事务码检查他们的环 ...

  7. Macbook 修复Office Excel 异常问题

    manbook 版本的office excel 在一次崩溃后,每次打开excel 文件都会弹出以下烦人的错误告警,并且每次都会重新打开很多过去保存过的excel 文件. “在应用程序意外退出之前,Ex ...

  8. js异步加载和按需加载

    function loadScript(url,callback){ var script = document.creatElement("script"); script.ty ...

  9. [Android]四大组件的运行状态

    Activity的主要作用是展示一个界面并和用户交互,它扮演的是一种前台界面的角色. Service是一种计算型组件,用于在后台执行一系列计算任务.Service有两种状态:启动状态和绑定状态.启动状 ...

  10. CSS——三种页面引入方法

    目的:为了把样式和内容分开,并且使网页元素更加丰富,引入了CSS CSS页面引入有三种方式: 1)内联式:比较不常用,因为内容和样式仍然在一起,不方便.示例: <!DOCTYPE html> ...