csp刷题
title: csp刷题
date: 2018-12-13 16:41:33
tags:
Markdown
在第7个点挂了,,,不改了,,,太恶心了这种题QAQ,,,,
有谁想改的改完了告诉我一下,,,QAQ
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
string h1[] = { "<h1>" , "<h2>" , "<h3>" , "<h4>" , "<h5>" , "<h6>" };
string h2[] = { "</h1>" , "</h2>" , "</h3>" , "</h4>" , "</h5>" , "</h6>" };
void check(string s)
{
int pos = 0;
bool _ = false;
bool href = false;
while(s[pos] != '\0')
{
if(s[pos] == '_')
{
cout << "<em>";
int pos2 = pos + 1;
while(s[pos2] != '_')++pos2;
string t = s.substr(pos + 1 , pos2 - pos - 1);
check(t);
cout << "</em>";
pos = pos2 + 1;
}
else if(s[pos] == '[')
{
int a , b , c , d;
a = b = c = d = pos;
for(int i = pos; s[i] != '\0'; ++i)
{
if(s[i] == ']')
b = i;
if(s[i] == '(')
c = i;
if(s[i] == ')')
d = i;
}
if(b != pos && c != pos && d != pos)
{
cout << "<a href=\"";
string t = s.substr(c + 1 , d - c - 1);
check(t);
cout << "\">";
t = s.substr(a + 1 , b - a - 1);
check(t);
cout << "</a>";
pos = d + 1;
}
else
cout << s[pos++];
}
else
cout << s[pos++];
}
}
int main()
{
freopen("233.txt" , "r" , stdin);
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
string s;
bool flagul = false;
bool flagp = false;
while(getline(cin , s))
{
if(s[0] == '#')
{
if(flagul)
{
cout << "</ul>" << endl;
flagul = false;
}
if(flagp)
{
cout << "</p>" << endl;
flagp = false;
}
int i;int sum = 0;
for(i = 0; i <= 5; ++i)
{
if(s[i] == '#')
++sum;
else
break;
}
int pos = i;
while(s[pos] == ' ')++pos;
cout << h1[sum - 1];
string t = s.substr(pos , s.length() - pos);
check(t);
cout << h2[sum - 1] << endl;
}
else if(s[0] == '*')
{
if(flagp)
{
cout << "</p>" << endl;
flagp = false;
}
if(!flagul)
{
cout << "<ul>" << endl;
flagul = true;
}
int i;
int pos = 0;
for(int i = 0; s[i] != '\0'; ++i)
if(s[i] == ' ' || s[i] == '*')
++pos;
cout << "<li>";
while(s[pos] != '\0')
cout << s[pos++];
cout << "</li>" << endl;
}
else if(s.length() == 0)
{
if(flagp)
{
cout << "</p>" << endl;
flagp = false;
}
continue;
}
else
{
if(flagul)
{
cout << "</ul>" << endl;
flagul = false;
}
if(!flagp)
{
cout << "<p>";
flagp = true;
check(s);
continue;
}
cout << endl;
check(s);
}
}
if(flagp)
cout << "</p>";
if(flagul)
cout << "</ul>";
return 0;
}
线性递推式
暴力肯定超时,,,试了试杜教筛,,,然后wa2,,,emmmm有毒,,,不管了++
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int mod = 998244353;
typedef long long ll;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef pair<int,int> PII;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head
int _,n;
namespace linear_seq {
const int N=10010;
ll res[N],base[N],_c[N],_md[N];
vector<int> Md;
void mul(ll *a,ll *b,int k) {
rep(i,0,k+k) _c[i]=0;
rep(i,0,k) if (a[i]) rep(j,0,k) _c[i+j]=(_c[i+j]+a[i]*b[j])%mod;
for (int i=k+k-1;i>=k;i--) if (_c[i])
rep(j,0,SZ(Md)) _c[i-k+Md[j]]=(_c[i-k+Md[j]]-_c[i]*_md[Md[j]])%mod;
rep(i,0,k) a[i]=_c[i];
}
int solve(ll n,VI a,VI b) { // a 系数 b 初值 b[n+1]=a[0]*b[n]+...
// printf("%d\n",SZ(b));
ll ans=0,pnt=0;
int k=SZ(a);
assert(SZ(a)==SZ(b));
rep(i,0,k) _md[k-1-i]=-a[i];_md[k]=1;
Md.clear();
rep(i,0,k) if (_md[i]!=0) Md.push_back(i);
rep(i,0,k) res[i]=base[i]=0;
res[0]=1;
while ((1ll<<pnt)<=n) pnt++;
for (int p=pnt;p>=0;p--) {
mul(res,res,k);
if ((n>>p)&1) {
for (int i=k-1;i>=0;i--) res[i+1]=res[i];res[0]=0;
rep(j,0,SZ(Md)) res[Md[j]]=(res[Md[j]]-res[k]*_md[Md[j]])%mod;
}
}
rep(i,0,k) ans=(ans+res[i]*b[i])%mod;
if (ans<0) ans+=mod;
return ans;
}
VI BM(VI s) {
VI C(1,1),B(1,1);
int L=0,m=1,b=1;
rep(n,0,SZ(s)) {
ll d=0;
rep(i,0,L+1) d=(d+(ll)C[i]*s[n-i])%mod;
if (d==0) ++m;
else if (2*L<=n) {
VI T=C;
ll c=mod-d*powmod(b,mod-2)%mod;
while (SZ(C)<SZ(B)+m) C.pb(0);
rep(i,0,SZ(B)) C[i+m]=(C[i+m]+c*B[i])%mod;
L=n+1-L; B=T; b=d; m=1;
} else {
ll c=mod-d*powmod(b,mod-2)%mod;
while (SZ(C)<SZ(B)+m) C.pb(0);
rep(i,0,SZ(B)) C[i+m]=(C[i+m]+c*B[i])%mod;
++m;
}
}
return C;
}
int gao(VI a,ll n) {
VI c=BM(a);
c.erase(c.begin());
rep(i,0,SZ(c)) c[i]=(mod-c[i])%mod;
return solve(n,c,VI(a.begin(),a.begin()+SZ(c)));
}
};
int main()
{
//freopen("233.txt" , "r" , stdin);
ll a[maxn];
ll k[maxn];
ll m , l , r;
scanf("%lld%lld%lld" , &m , &l , &r);
{
for(ll i = 1; i <= m; ++i)
scanf("%lld" , &k[i]);
memset(a , (ll)0 , sizeof a);
a[0] = (ll)1;
if(r >= 20)
{
for(ll i = 1; i <= 30; ++i)
{
ll mi = min(i, m);
ll ma = (m <= i) ? m : i;
for(ll j = i, kk = 1; kk <= ma; --j, ++kk)
a[i] = (a[i] + (a[j - 1] * k[kk] % mod)) % mod;
}
vector<int> v;
for(ll i = 1; i <= 30; ++i)
v.push_back(a[i]);
for(ll i = l; i <= r; ++i)
printf("%lld\n", linear_seq::gao(v, i - 1));
}
else
{
for(ll i = 1; i <= r; ++i)
{
int mi = min(i, m);
int ma = (m <= i) ? m : i;
for(ll j = i, kk = 1; kk <= ma; --j, ++kk)
a[i] = (a[i] + (a[j - 1] * k[kk] % mod)) % mod;
}
for(int i = l; i <= r; ++i)
printf("%lld\n" , a[i]);
}
}
return 0;
}
通信网络
这题深搜就行了,,,代码丢了,,,
除法
这题给的时限是10s,,,一开始我还当一般的区间问题想,,,想着怎么用区间修改的线段树做,,,,然后发现时限很大,之后果断暴力更新区间的每个点,,,然后试了好多的线段树的板子都在第九个点t了,,,,换树状数组就没事,,emmmmm有毒++,,还有要判断这个数是不是已经比要除的数小,,,还有标记优化,,,这样才能过,,,,
代码没保存,,,emmmm不管了,,,,
csp刷题的更多相关文章
- NOIP&CSP PJ 难度刷题记录
前言 本来不想写前言的(>人<:) 这只是 mjl 给我们布置的作业,并不是我自己在刷题! 不保证所有代码的正确性,它们仅仅是通过了所有数据点而已. 1.模拟板块 整体难度:红~黄(模拟不 ...
- LeetCode刷题系列
LeetCode 我们工作面试和提高自身数据结构和算法能力的时候往往需要刷刷题,我选择LeetCode是通过一个留学论坛了解的.专业,覆盖语种全面. 提前说说刷题的心得: 尽量手写代码,少使用IDE的 ...
- ife任务刷题总结(一)-css reset与清除浮动
本文同时发布于本人的个人网站www.yaoxiaowen.com 百度创办的前端技术学院,是一个面向大学生的前端技术学习平台.虽然只有大学生才有资格报名,提交代码进行比赛排名.但是这并不妨碍我们这些初 ...
- 刷题ING...
我用codeVS刷题.. 努力准备!!
- XidianOJ 1020 ACMer去刷题吧
题目描述 刷题是每个ACMer必由之路,已知某oj上有n个题目,第i个题目小X能做对的概率为Pi(0<=Pi<=1,1<=i<=n) 求小X至少做对k道题的概率 输入 第一行输 ...
- 【BZOJ-4590】自动刷题机 二分 + 判定
4590: [Shoi2015]自动刷题机 Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 156 Solved: 63[Submit][Status ...
- NOI题库分治算法刷题记录
今天晚自习机房刷题,有一道题最终WA掉两组,极其不爽,晚上回家补完作业欣然搞定它,特意来写篇博文来记录下 (最想吐槽的是这个叫做分治的分类,里面的题目真的需要分治吗...) 先来说下分治法 分治法的设 ...
- NOI题库刷题日志 (贪心篇题解)
这段时间在NOI题库上刷了刷题,来写点心得和题解 一.寻找平面上的极大点 2704:寻找平面上的极大点 总时间限制: 1000ms 内存限制: 65536kB 描述 在一个平面上,如果有两个点( ...
- 用js刷题的一些坑
leecode可以用js刷题了,我大js越来越被认可了是吧.但是刷题中会因为忽略js的一些特性掉入坑里.我这里总结一下我掉过的坑. 坑1:js中数组对象是引用对象 js中除了object还有数组对象也 ...
随机推荐
- sqlite3数据库的简要应用
Sqlite3数据库升级方案的变化. 1, 若是讲要升级的数据库版本更高,则从低版本数据库中拷贝与新数据库相同字段的内容,其他字段按照默认值创建.A->B->C这样逐个版本升级,每个版本 ...
- SHOW_PAGE_TRACE
入口文件开启APP_DEBUG配置文件里添加了'SHOW_PAGE_TRACE' => true,控制器中显示模板在页面右下角也有trace图标但是鼠标放上面不显示手型光标,还是箭头,点不动但是 ...
- linux BASH shell下设置字体及背景颜色
BASH shell下设置字体及背景颜色 echo -e "\e[31mtest\e[41m" \e[30m 将字符的显示颜色改为黑色 \e[31m 将字符的显示颜色改为红色 \e ...
- 【CSS】定位层
html:定位层1.概念: >>.定位层是由html元素(标签)形成的一个特殊的box盒子. >>.其重点在于“定位”,而html元素(标签)的定位方式由CSS来控制. 通常情 ...
- duilib bkimage 属性
duilib bkimage 属性<Attribute name="bkimage" default="" type="STRING" ...
- Does Deep Learning Come from the Devil?
Does Deep Learning Come from the Devil? Deep learning has revolutionized computer vision and natural ...
- iOS手势UIGestureRecognizer的使用及手势冲突的解决办法【转】
转自:iOS开发中的手势体系——UIGestureRecognizer分析及其子类的使用 关于手势的一篇很好的帖子,转载过来免得丢失.你可能最感兴趣的是手势间的互斥处理,那么就搜索 4.手势间的互斥处 ...
- 第11月第8天 ffmpeg ffplay
static int ffplay_video_thread(void *arg) { FFPlayer *ffp = arg; VideoState *is = ffp->is; AVFram ...
- 洛谷 P1045 【麦森数】快速幂
不用快速幂,压位出奇迹! 本人是个蒟蒻,不太熟悉快速幂,这里给大家介绍一种压位大法. 让我们来分析一下题目,第一位是送分的,有一个专门求位数的函数:n*log10(2)+1. 然后题目中p<=3 ...
- CSS3设置内容超过一定长度后自动折行
在用编辑器保存的数据到数据库的时候经常是在我们的内容前后加一个P标签,但是出来之后是一行,有时候会超过边框的宽度,所以研究了如何折行,如下代码: <!DOCTYPE html> <h ...