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. VMware S/4 HANA OP 1511虚拟机下载,64G内存限制解决方案

    http://www.itpub.net/thread-2057212-1-1.html S4 HANA OP 1511 Scale Out

  2. ACM-ICPC2018焦作网络赛 Mathematical Curse(dp)

    Mathematical Curse 22.25% 1000ms 65536K   A prince of the Science Continent was imprisoned in a cast ...

  3. AJAX 入门教程

    一.前言 AJAX 是我们教程用到的请求数据的技术,在这里我就给自己做一个小结. 二.案例 我使用的是 JQuery 的 AJAX 来实践.后端服务我使用的是 c# 的mvc. 后端代码: using ...

  4. Swoole 多协议 多端口 的应用

    目录 概述 网络通信协议设计 多端口监听的使用 小结 概述 这是关于 Swoole 学习的第五篇文章:Swoole 多协议 多端口 的应用. 第四篇:Swoole HTTP 的应用 第三篇:Swool ...

  5. Unity 5.6 beta版本新特性

    http://manew.com/thread-98549-1-1.html 最新发布的beta版改进了编辑器和2D功能,图形性能更佳,加入新的视频播放器,并添加了对Facebook Gameroom ...

  6. hdu1166(线段树单点更新&区间求和模板)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1166 题意:中文题诶- 思路:线段树单点更新,区间求和模板 代码: #include <iost ...

  7. 洛谷P2169 正则表达式

    题目背景 小\(Z\)童鞋一日意外的看到小\(X\)写了一个正则表达式的高级程序,这个正则表达式程序仅仅由字符"\(0\)","\(1\)","\(. ...

  8. 新的JSON / YAML插件:在JMeter中使用YAML

    在JMS插件从jmeter-plugins.org捐赠给核心JMeter之后,JSON插件在Apache JMeter™版本4中被弃用.现在,我已更新此插件以支持新功能和新功能.在这个新版本中,两个插 ...

  9. POJ1830(异或高斯消元)

    对于某个开关,都有n个选项可能影响它的结果,如果会影响,则系数为1,否则系数为0:最后得到自由元的个数,自由元可选0也可选1. #include <cstdio> #include < ...

  10. Exploring refit, an automatic type-safe REST library for .NET Standard

    自动类型安全的.NET标准REST库refit   在SCOTT HANSELMAN 博客上看到一个好东西<Exploring refit, an automatic type-safe RES ...