-
个人简介
煜虽无意逐鹿
filein=open(".in","r") fileout=open(".out","w")
int 2147483647
矩阵快速幂
#include<bits/stdc++.h> using namespace std; long long mod; long long n,m; struct jz{ long long f[101][101]; }; jz e,p,ans; jz cheng(jz a,jz b){ jz hh; for(int i=1;i<=n;i++) for(int j=1;j<=n;j++){ hh.f[i][j]=0; for(int k=1;k<=n;k++){ hh.f[i][j]+=a.f[i][k]*b.f[k][j]; hh.f[i][j]%=mod; } } return hh; } jz qpow(jz a,long long b){ jz hh=p; while(b>0){ if(b&1) hh=cheng(hh,a); a=cheng(a,a); b>>=1; } return hh; } int main(){ scanf("%lld%lld%lld",&n,&m,&mod);//n*n矩阵,m次幂 for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) scanf("%d",&e.f[i][j]); for(int i=1;i<=n;i++) for(int i=1;i<=n;i++) p.f[i][i]=1; if(mod==1) printf("0"); if(n==0) printf("1"); ans=qpow(e,m); for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++) printf("%lld ",ans.f[i][j]); printf("\n"); } return 0; }
快速幂
long long mypow(long long a,long long b){ if(!b) return 1; long long f=mypow(a,b/2); if(b%2) return f*f%k*a%k; else return f*f%k; }
stable_sort()//稳定快排
while(cin>>ws,!cin.eof())//读入直到文件末尾
ios::sync_with_stdio(false);//优化输出时间,使cin cout时间与scanf printf相差无几
map<string,int>a; map<string,int>::iterator it;
freopen(".in","r",stdin); freopen(".out","w",stdout);
int mkbk(string s){//将字符串转为整数 int ls=s.length(); int m[ls],tot=0; for(int i=0;i<ls;i++){ tot*=10; m[ls-i-1]=s[i]-'0'; tot+=m[ls-i-1]; } return tot; }
string add(string s1,string s2){ long long a[10010]={},b[10010]={},c[10010]={}; long long la=s1.length(),lb=s2.length(),lc=max(la,lb),x=0; string ans=""; for(int i=0;i<la;i++)a[i]=s1[la-i-1]-'0'; for(int i=0;i<lb;i++)b[i]=s2[lb-i-1]-'0'; for(int i=0;i<lc;i++){ c[i]=a[i]+b[i]+x; x=c[i]/10; c[i]=c[i]%10; } if(x)c[lc++]=1; for(int i=lc-1;i>=0;i--)ans+=(c[i]+'0'); return ans; }
string sub(string s1,string s2){ long long a[10010]={},b[10010]={},c[10010]={}; long long la=s1.length(),lb=s2.length(),lc=max(la,lb),x=0,f=0; string ans=""; if((s1<s2&&s1.length()==s2.length())||s1.length()<s2.length()){ f=1; string t=s1; s1=s2; s2=t; swap(la,lb); cout<<'-'; } for(int i=0;i<la;i++)a[i]=s1[la-i-1]-'0'; for(int i=0;i<lb;i++)b[i]=s2[lb-i-1]-'0'; for(int i=0;i<lc;i++){ c[i]=a[i]-b[i]-x; if(c[i]<0){ x=1; c[i]+=10; }else x=0; } while(c[lc-1]==0&&lc>1)lc--; for(int i=lc-1;i>=0;i--)ans+=(c[i]+'0'); return ans; }
string mul(string s1,string s2){ long long a[10010]={},b[10010]={},c[20010]={}; long long la=s1.length(); long long lb=s2.length(); long long lc=la+lb; string ans=""; for(int i=0;i<la;i++) a[i]=s1[la-1-i]-'0'; for(int i=0;i<lb;i++) b[i]=s2[lb-1-i]-'0'; for(int i=0;i<la;i++){ for(int j=0;j<lb;j++){ c[i+j]+=a[i]*b[j]; c[i+j+1]+=c[i+j]/10; c[i+j]%=10; } } while(c[lc-1]==0&&lc>1) lc--; for(int i=lc-1;i>=0;i--) ans+=(c[i]+'0'); return ans; }
string div(string s,int b){ int n,a[10100],c[10100],la,lc; la=s.length(),lc=0; for(int i=0;i<la;i++)a[i]=s[i]-'0'; long long x=0; string ans=""; for(int i=0;i<la;i++){ c[i]=(x*10+a[i])/b; x=(x*10+a[i])%b; } while(c[lc]==0&&lc+1<la) lc++; for(int i=lc;i<la;i++)ans+=(c[i]+'0'); return ans; }
骗分过样例,暴力出奇迹,暴搜挂着机,打表出省一(>.<)
-
通过的题目
- P01
- P02
- P03
- P04
- P05
- P12
- P13
- P20
- P26
- P30
- P35
- P36
- P44
- P49
- P72
- P103
- P106
- P107
- P110
- P111
- P112
- P115
- P118
- P119
- P131
- P134
- P136
- P138
- P139
- P140
- P142
- P146
- P147
- P151
- P152
- P155
- P156
- P159
- P163
- P164
- P169
- P171
- P172
- P179
- P183
- P187
- P192
- P197
- P199
- P204
- P205
- P207
- P214
- P217
- P221
- P227
- P228
- P231
- P234
- P247
- P253
- P257
- P261
- P267
- P301
- P302
- P303
- P304
- P305
- P306
- P307
- P308
- P309
- P310
- P311
- P312
- P313
- P314
- P315
- P316
- P317
- P318
- P319
- P320
- P321
- P322
- P323
- P324
- P325
- P326
- P327
- P328
- P329
- P330
- P331
- P332
- P333
- P334
- P335
- P336
- P337
- P338
- P339
- P340
- P341
- P342
- P343
- P344
- P345
- P346
- P347
- P348
- P349
- P350
- P352
- P353
- P354
- P355
- P356
- P357
- P358
- P359
- P360
- P361
- P362
- P363
- P364
- P365
- P366
- P367
- P368
- P369
- P370
- P371
- P372
- P373
- P374
- P375
- P376
- P377
- P378
- P379
- P380
- P381
- P382
- P383
- P384
- P385
- P386
- P387
- P388
- P389
- P390
- P391
- P392
- P393
- P394
- P395
- P396
- P397
- P398
- P399
- P400
- P401
- P402
- P403
- P404
- P405
- P406
- P407
- P408
- P409
- P410
- P411
- P412
- P413
- P414
- P415
- P416
- P418
- P419
- P420
- P421
- P422
- P423
- P424
- P425
- P426
- P427
- P428
- P429
- P431
- P432
- P433
- P434
- P435
- P436
- P437
- P438
- P439
- P440
- P441
- P442
- P443
- P444
- P445
- P446
- P447
- P448
- P449
- P450
- P451
- P452
- P461
- P462
- P463
- P464
- P465
- P466
- P468
- P470
- P471
- P472
- P473
- P474
- P476
- P477
- P478
- P479
- P480
- P481
- P482
- P483
- P484
- P488
- P489
- P490
- P491
- P492
- P493
- P494
- P495
- P496
- P497
- P498
- P499
- P500
- P501
- P502
- P518
- P519
- P520
- P521
- P527
- P529
- P530
- P531
- P532
- P536
- P542
- P543
- P551
- P552
- P555
- P558
- P574
- P576
- P577
- P590
- P623
- P688
- P690
- P691
- P695
- P700
- P806
- P843
- P884
- P950
- P953
- P988
- P1005
- P1200
- P1221
- P1222
- P1223
- P1225
- P1243
- P1257
- P1259
- P1312
- P1316
- P1318
- P1326
- P1328
- P1329
- P1330
- P1332
- P1349
- P1498
- P1505
- P1549
- P1550
- P1551
- P1552
- P1555
- P1557
- P351
- P1576
- P1602
- P1604
- P1626
- P1633
- P1634
- P1638
- P1639
- P1688
- P1735
- P1753
- P1760
- P1761
- P1793
- P1799
- P2069
- P2090
- P2091
- P2092
- P2093
- P2094
- P2095
- P2096
- P2099
- P2102
- P2103
- P2108
- P2109
- P2110
- P2111
- P2112
- P2113
- P2115
- P2117
- P2118
- P2119
- P2121
- P2122
- P2123
- P2125
- P2126
- P2127
- P2128
- P2129
- P2131
- P2132
- P2133
- P2134
- P2135
- P2136
- P2138
- P2140
- P2141
- P2142
- P2143
- P2144
- P2145
- P2161
- P2165
- P2174
- P2194
- P2195
- P2197
- P2214
- P2224
- P2229
- P2233
- P2234
- P2238
- P2239
- P2244
- P2248
- P2271
- P2272
- P2273
- P2274
- P2275
- P2286
- P2288
- P2299
- P2312
- P2332
- P2334
-
最近活动
-
最近编写的题解
题目标签
- 基础算法
- 85
- 动态规划
- 63
- 课课通
- 52
- 模拟
- 37
- 其他
- 31
- 普及组
- 30
- 提高组
- 26
- 贪心
- 25
- 数组
- 23
- 排序
- 17
- 字符串
- 16
- 搜索
- 16
- 高精度
- 14
- USACO
- 13
- 分治
- 13
- 递推
- 13
- 省赛
- 13
- 江苏
- 13
- LIS
- 11
- 背包
- 11