山西省选...这个省...不算强吧...然而就是这么腊鸡题目还是wa得一无是处...怎么办啊怎么办啊...无处拯救青春和未来啊...
T1:
POI2004原题 BZOJ1524
n<=16.这不是一眼 撞鸭吗...然而我怎么打炸了呢...看了一眼标算跟我枚举的方式有点不一样不过感觉更靠谱的样子...然而第一眼看一句话居然看不懂...
连枚举子集都忘了QAQ
for x = S; x ;x = S&(x-1);
T2:
打表找规律= =...
没取模!!!!!!日!!!!!!!!!
/*================================= # Created time: 2016-04-21 10:09 # Filename: sequence.cpp # Description: =================================*/ #define me AcrossTheSky&HalfSummer11 #include <cstdio> #include <cmath> #include <ctime> #include <string> #include <cstring> #include <cstdlib> #include <iostream> #include <algorithm> #include <set> #include <stack> #include <queue> #include <vector> #define lowbit(x) (x)&(-x) #define Abs(x) ((x) > 0 ? (x) : (-(x))) #define FOR(i,a,b) for((i)=(a);(i)<=(b);(i)++) #define FORP(i,a,b) for(int i=(a);i<=(b);i++) #define FORM(i,a,b) for(int i=(a);i>=(b);i--) #define ls(a,b) (((a)+(b)) << 1) #define rs(a,b) (((a)+(b)) >> 1) #define getlc(a) ch[(a)][0] #define getrc(a) ch[(a)][1] #define maxn 300005 #define maxm 2000005 #define INF 1070000000 #define mod 1000000007 using namespace std; typedef long long ll; typedef unsigned long long ull; template<class T> inline void read(T& num){ num = 0; bool f = true;char ch = getchar(); while(ch < '0' || ch > '9') { if(ch == '-') f = false;ch = getchar();} while(ch >= '0' && ch <= '9') {num = num * 10 + ch - '0';ch = getchar();} num = f ? num: -num; } int outs[100]; template<class T> inline void write(T x){ if (x==0) {putchar('0'); puts(""); return;} if (x<0) {putchar('-'); x=-x;} int num=0; while (x){ outs[num++]=(x%10); x=x/10;} FORM(i,num-1,0) putchar(outs[i]+'0'); puts(""); } /*==================split line==================*/ ll n; struct Matrix{ ll s[2][2]; void clear(){memset(s,0,sizeof(s));} }f,a; Matrix operator *(Matrix a,Matrix b){ Matrix c; c.clear(); for (int i=0;i<2;i++) for (int j=0;j<2;j++) for (int k=0;k<2;k++) c.s[i][j]+=((a.s[k][j]%mod)*(b.s[i][k]%mod))%mod,c.s[i][j]%=mod; return c; } int main(){ freopen("sequence.in","r",stdin); freopen("sequence.out","w",stdout); f.s[0][0]=1,f.s[0][1]=0,f.s[1][0]=0,f.s[1][1]=0; a.s[0][0]=2,a.s[0][1]=1,a.s[1][0]=1,a.s[1][1]=0; read(n); if (n==0){ write(0); return 0; } n--; for(;n;n>>=1,a=a*a) if(n&1) f=f*a; write(f.s[0][0]); }
T3:
显然新加串是原串一个前缀,搞一棵Trie,hash一下....然而为什么我BZ上过了考试的时候没过呢...
/*================================= # Created time: 2016-04-21 10:09 # Filename: sequence.cpp # Description: =================================*/ #define me AcrossTheSky&HalfSummer11 #include <cstdio> #include <cmath> #include <ctime> #include <string> #include <cstring> #include <cstdlib> #include <iostream> #include <algorithm> #include <set> #include <stack> #include <queue> #include <vector> #define lowbit(x) (x)&(-x) #define Abs(x) ((x) > 0 ? (x) : (-(x))) #define FOR(i,a,b) for((i)=(a);(i)<=(b);(i)++) #define FORP(i,a,b) for(int i=(a);i<=(b);i++) #define FORM(i,a,b) for(int i=(a);i>=(b);i--) #define pb push_back #define ls(a,b) (((a)+(b)) << 1) #define rs(a,b) (((a)+(b)) >> 1) #define getlc(a) ch[(a)][0] #define getrc(a) ch[(a)][1] #define maxn 2000005 #define maxm 100005 #define INF 1070000000 using namespace std; typedef long long ll; typedef unsigned long long ull; template<class T> inline void read(T& num){ num = 0; bool f = true;char ch = getchar(); while(ch < '0' || ch > '9') { if(ch == '-') f = false;ch = getchar();} while(ch >= '0' && ch <= '9') {num = num * 10 + ch - '0';ch = getchar();} num = f ? num: -num; } int outs[100]; template<class T> inline void write(T x){ if (x==0) {putchar('0'); puts(""); return;} if (x<0) {putchar('-'); x=-x;} int num=0; while (x){ outs[num++]=(x%10); x=x/10;} FORM(i,num-1,0) putchar(outs[i]+'0'); puts(""); } /*==================split line==================*/ const ll base=17; int n,cnt=1,now; ll tmp; int len[maxn],sum[maxn],ord[maxn],ch[maxn][26]; ull hash[maxn],p[maxn]; vector<char> s[maxn]; void insert(int x){ if (!ch[now][x]) ch[now][x]=++cnt; now=ch[now][x]; tmp=tmp*base+x+1; } int main(){ freopen("string.in","r",stdin); freopen("string.out","w",stdout); p[0]=1; FORP (i,1,2000003) p[i]=p[i-1]*base;//,write(p[i]); read(n); FORP(i,1,n){ char c; read(len[i]); FORP(j,0,len[i]-1) s[i].pb(getchar()); now=1,tmp=0; FORP(j,0,len[i]-1) insert(s[i][j]-'a'); sum[now]++;ord[now]=i;hash[i]=tmp; } ll ans=0; FORP(i,1,n){ now=1; FORP(j,0,len[i]-1){ int x=s[i][j]-'a'; now=ch[now][x]; if (sum[now] && hash[ord[now]]*p[len[i]]+hash[i]== hash[i]*p[len[ord[now]]]+hash[ord[now]]) ans+=sum[now]; } } ans=ans*2-n; write(ans); return 0; }
T4:
打了个暴力这次暴力居然没出错...正解还没去看挖个坑>_<...Orz分块过的大神犇