Orz Hzwer……

  然而我想多了……

  理解以后感觉黄学长的递推好精妙啊

  顺便学到了一份高精度的板子= =233

  引用下题解:

f[i]=f[i-1]^n+1

ans=f[d]-f[d-1]

然后加个高精度。。。

话说这个数据范围是虚的吧。。。

极限数据根本不会做。。

 1 /**************************************************************
 2     Problem: 1089
 3     User: Tunix
 4     Language: C++
 5     Result: Accepted
 6     Time:0 ms
 7     Memory:1352 kb
 8 ****************************************************************/
 9  
10 //BZOJ 1089
11 #include<cstdio>
12 #include<cstring>
13 #include<cstdlib>
14 #include<iostream>
15 #include<algorithm>
16 #define rep(i,n) for(int i=0;i<n;++i)
17 #define F(i,j,n) for(int i=j;i<=n;++i)
18 #define D(i,j,n) for(int i=j;i>=n;--i)
19 #define pb push_back
20 using namespace std;
21 typedef long long LL;
22 inline int getint(){
23     int r=1,v=0; char ch=getchar();
24     for(;!isdigit(ch);ch=getchar()) if (ch=='-') r=-1;
25     for(; isdigit(ch);ch=getchar()) v=v*10-'0'+ch;
26     return r*v;
27 }
28 const int N=100010;
29 /*******************template********************/
30 struct bint{
31     int l,v[1010];
32     bint(){l=0;memset(v,0,sizeof v);}
33     int& operator [] (int x){return v[x];}
34 }f[20];
35 const int Limit=10000;
36 void print(bint a){
37     printf("%d",a[a.l]);
38     D(i,a.l-1,1) printf("%04d",a[i]);
39     puts("");
40 }
41 bint operator * (bint a,bint b){
42     bint c;
43     F(i,1,a.l+b.l) c[i]=0;
44     F(i,1,a.l) F(j,1,b.l)
45         c[i+j-1]+=a[i]*b[j];
46     c.l=a.l+b.l;
47     F(i,1,c.l)
48         if (c[i]>=Limit){
49             if (i==c.l){
50                 c.l++;
51                 c[i+1]=c[i]/Limit;
52             }else c[i+1]+=c[i]/Limit;
53             c[i]%=Limit;
54         }
55     while(c.l>1 && !c[c.l]) c.l--;
56     return c;
57 }
58 bint operator + (bint a,int p){
59     a[1]+=p;
60     int now=1;
61     while(a[now]>=Limit){
62         a[now+1]+=a[now]/Limit;
63         a[now]%=Limit;
64         now++;
65         a.l=max(a.l,now);
66     }
67     return a;
68 }
69 bint operator - (bint a,bint b){
70     F(i,1,a.l){
71         a[i]-=b[i];
72         if (a[i]<0){
73             a[i]+=Limit;
74             a[i+1]--;
75         }
76     }
77     while(a.l>1 && !a[a.l]) a.l--;
78     return a;
79 }
80 bint operator ^ (bint a,int b){
81     bint r; r[r.l=1]=1;
82     for(;b;b>>=1,a=a*a)
83         if (b&1) r=r*a;
84     return r;
85 }
86 int main(){
87 #ifndef ONLINE_JUDGE
88     freopen("1089.in","r",stdin);
89     freopen("1089.out","w",stdout);
90 #endif
91     int n=getint(),d=getint();
92     f[0][f[0].l=1]=1;
93     F(i,1,d) f[i]=(f[i-1]^n)+1;
94     print(f[d]-f[d-1]);
95     return 0;
96 }
View Code

相关文章:

  • 2022-12-23
  • 2022-01-26
  • 2022-12-23
  • 2022-01-26
  • 2022-12-23
  • 2021-06-10
  • 2021-09-12
猜你喜欢
  • 2021-06-02
  • 2021-08-31
  • 2021-05-23
  • 2022-02-06
  • 2021-08-12
  • 2022-12-23
  • 2022-02-25
相关资源
相似解决方案