tjut 4896
来源:互联网 发布:举报网络传奇赌博 编辑:程序博客网 时间:2024/06/05 14:09
#include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <string> #include <map> #define eps 1e-9 #define LL long long #define mod 2333333 using namespace std; map <int , int> ma; int pos[100]; int clo,p,ed; struct node { int x,y,w; }a[250000]; int f[500]; LL te[200]; int cmp(node a,node b) { return (a.w<b.w); } int getf(int x) { if (x==f[x]) return x; else return (f[x]=getf(f[x])); } int unite(int x,int y) { // printf("%d %d\n",x,y); if (getf(x)!=getf(y)) f[getf(x)]=getf(y); } LL kru() { LL ans=0; for (int i=1;i<=ed;i++) if (getf(a[i].x)!=getf(a[i].y)) { ans+=a[i].w; unite(a[i].x,a[i].y); } return ans; } int main() { LL n,seed; while (~scanf("%I64d%I64d",&n,&seed)) { ma.clear(); int cur=seed; int t=0; while (ma[cur]==0) { t++; pos[t]=cur; pos[0]=cur; ma[cur]=1; cur=cur*907%mod; } for (int k=1;k<=108;k++) { for (int i=1;i<=k;i++) f[i]=i; clo=ed=0; for (int i=1;i<=k;i++) { clo++; clo%=54; p=pos[clo]; for (int j=max(1,i-5);j<i;j++) { clo++; clo%=54; ed++; a[ed].x=i; a[ed].y=j; a[ed].w=pos[clo]^p; } } sort(a+1,a+1+ed,cmp); te[k]=kru();//暴力前108个结果 } // for (int i=1;i<=100;i++) // printf("%I64d ",te[i]); if (n<=108) printf("%I64d\n",te[n]); else printf("%I64d\n",te[54+n%54]+(n/54-1)*(te[108]-te[54])); } return 0; }
0 0
- tjut 4896
- tjut 5289
- tjut 5288
- tjut 5294
- tjut 2586
- tjut 5296
- tjut 5297
- tjut 5299
- tjut 5384
- tjut 5387
- tjut 5386
- tjut 5381
- tjut 5400
- tjut 5399
- tjut 5396
- tjut 5398
- tjut 5412
- tjut 5410
- alter table <修改表>
- 图形验证码的生成
- 石子合并(一)
- 进制转换 hd 2031
- Centos 配置eth0 提示Device does not seem to be present
- tjut 4896
- __nonnull or __nullable 区别
- 最长递增子序列
- Git的基本了解与使用、向github提交代码
- mysql Access denied for user \'root\'@\'localhost\'”解决办法
- 极限定理
- 图解手动全面检查管理本机端口
- 372. Super Pow
- 线段树 区间更新 区间求和以及最值