jls的自闭场
1001 BPM136 差点首杀结果发现漏乘了一个系数还爆了ll,回来首杀就没了QAQQQ
1 /* *********************************************** 2 Author :BPM136 3 Created Time :2018/8/20 12:19:25 4 File Name :1001.cpp 5 ************************************************ */ 6 7 #include<iostream> 8 #include<cstdio> 9 #include<algorithm> 10 #include<cstdlib> 11 #include<cmath> 12 #include<cstring> 13 #include<iomanip> 14 #include<bitset> 15 #include<queue> 16 #include<ctime> 17 #include<set> 18 #include<map> 19 #include<list> 20 #include<vector> 21 #include<cassert> 22 #include<functional> 23 #define pb push_back 24 #define popb pop_back 25 #define MID ((l+r)>>1) 26 #define LSON (k<<1) 27 #define RSON (k<<1|1) 28 #define get(a,i) ((a)&(1<<(i-1))) 29 #define PAU putchar(32) 30 #define ENT putchar(10) 31 #define all(x) ((int) (x).size()) 32 #define clr(a,b) memset(a,b,sizeof(a)) 33 #define rep(_i,_a,_b) for(int _i=(_a);_i<=(_b);_i++) 34 #define down(_i,_a,_b) for(int _i=(_a);_i>=(_b);_i--) 35 #define FOR(_i,_b) for(int _i=1;_i<=(_b);_i++) 36 #define efo(_i,_a) for(int _i=last[(_a)];_i!=0;_i=e[_i].next) 37 #define Remax(a,b) if(b>a) a=b; 38 #define Remin(a,b) if(b<a) a=b; 39 #define SZ(x) ((int)(x).size()) 40 #define filein(x) freopen(#x".in","r",stdin) 41 #define fileout(x) freopen(#x".out","w",stdout) 42 #define file(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout); 43 #define mkd(x) freopen(#x".in","w",stdout); 44 #define setlargestack(x) int _SIZE=x<<20;char *_PPP=(char*)malloc(_SIZE)+_SIZE;__asm__("movl %0, %%esp " :: "r"(_PPP)); 45 #define END system("pause") 46 #define read2(a,b) read(a),read(b) 47 #define read3(a,b,c) read(a),read(b),read(c) 48 #define readg(_x1,_y1,_x2,_y2) read(_x1),read(_y1),read(_x2),read(_y2) 49 using namespace std; 50 51 typedef long long ll; 52 typedef double DB; 53 typedef long double LD; 54 typedef unsigned int UI; 55 typedef unsigned long long ULL; 56 typedef vector<int> VI; 57 typedef set<int> SI; 58 typedef set<int , greater<int> > SIG; 59 typedef map<int, int > MII; 60 typedef map<int, int, greater<int> > MIIG; 61 62 const int N = 81; 63 64 ll f[N*N][N][N]; 65 int n,m,MOD; 66 67 int main() { 68 int T; 69 scanf("%d",&T); 70 while(T--) { 71 scanf("%d%d%d",&n,&m,&MOD); 72 clr(f,0); 73 74 f[1][1][1]=n*m; 75 rep(i,1,n*m-1) rep(j,1,min(i,n)) rep(k,1,min(i,m)) if(i<=j*k) { 76 int leaf=j*k-i; 77 if(leaf) f[i+1][j][k]=(f[i+1][j][k]+f[i][j][k]*leaf%MOD)%MOD; 78 79 //col 80 f[i+1][j][k+1]=(f[i+1][j][k+1]+f[i][j][k]*(m-k)*j%MOD)%MOD; 81 //row 82 f[i+1][j+1][k]=(f[i+1][j+1][k]+f[i][j][k]*(n-j)*k%MOD)%MOD; 83 } 84 cout<<f[n*m][n][m]<<endl; 85 } 86 return 0; 87 }
1002 BPM136 打了几个不同的版本然后不断用自己的暴力把自己疯狂hack,改了几次还是过了嘿嘿嘿( 然后愉快的自闭10
1 /* *********************************************** 2 Author :BPM136 3 Created Time :2018/8/20 13:20:47 4 File Name :1002.cpp 5 ************************************************ */ 6 7 #include<iostream> 8 #include<cstdio> 9 #include<algorithm> 10 #include<cstdlib> 11 #include<cmath> 12 #include<cstring> 13 #include<iomanip> 14 #include<bitset> 15 #include<queue> 16 #include<ctime> 17 #include<set> 18 #include<map> 19 #include<list> 20 #include<vector> 21 #include<cassert> 22 #include<functional> 23 #define pb push_back 24 #define popb pop_back 25 #define MID ((l+r)>>1) 26 #define LSON (k<<1) 27 #define RSON (k<<1|1) 28 #define get(a,i) ((a)&(1<<(i-1))) 29 #define PAU putchar(32) 30 #define ENT putchar(10) 31 #define all(x) ((int) (x).size()) 32 #define clr(a,b) memset(a,b,sizeof(a)) 33 #define rep(_i,_a,_b) for(int _i=(_a);_i<=(_b);_i++) 34 #define down(_i,_a,_b) for(int _i=(_a);_i>=(_b);_i--) 35 #define FOR(_i,_b) for(int _i=1;_i<=(_b);_i++) 36 #define efo(_i,_a) for(int _i=last[(_a)];_i!=0;_i=e[_i].next) 37 #define Remax(a,b) if(b>a) a=b; 38 #define Remin(a,b) if(b<a) a=b; 39 #define SZ(x) ((int)(x).size()) 40 #define filein(x) freopen(#x".in","r",stdin) 41 #define fileout(x) freopen(#x".out","w",stdout) 42 #define file(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout); 43 #define mkd(x) freopen(#x".in","w",stdout); 44 #define setlargestack(x) int _SIZE=x<<20;char *_PPP=(char*)malloc(_SIZE)+_SIZE;__asm__("movl %0, %%esp " :: "r"(_PPP)); 45 #define END system("pause") 46 #define read2(a,b) read(a),read(b) 47 #define read3(a,b,c) read(a),read(b),read(c) 48 #define readg(_x1,_y1,_x2,_y2) read(_x1),read(_y1),read(_x2),read(_y2) 49 using namespace std; 50 51 typedef long long ll; 52 typedef double DB; 53 typedef long double LD; 54 typedef unsigned int UI; 55 typedef unsigned long long ULL; 56 typedef vector<int> VI; 57 typedef set<int> SI; 58 typedef set<int , greater<int> > SIG; 59 typedef map<int, int > MII; 60 typedef map<int, int, greater<int> > MIIG; 61 62 const int N = 2005; 63 const int MOD = 998244353; 64 65 int f[N][N]; 66 int n,m,K; 67 68 int a[N][N]; 69 70 char s[N]; 71 ll sta_ans; 72 int sta_l,sta_r; 73 74 int add[N][N]; 75 int minu[N][N]; 76 77 int main() { 78 int T; 79 scanf("%d",&T); 80 while(T--) { 81 scanf("%d%d%d",&n,&m,&K); 82 rep(i,1,n) { 83 scanf("%s",s+1); 84 rep(j,1,m) if(s[j]=='1') a[i][j]=1; else a[i][j]=0; 85 a[i][0]=-1; 86 } 87 88 89 clr(f,0); clr(add,0); clr(minu,0); 90 rep(i,1,m) f[1][i]=1; 91 rep(i,2,n) { 92 sta_l=1,sta_r=0; 93 sta_ans=0; 94 rep(j,1,m) { 95 while(sta_r<m && sta_r<j+K) { 96 sta_r++; 97 if(a[i-1][sta_r]!=a[i-1][sta_r-1]) { 98 sta_ans=sta_ans+f[i-1][sta_r]; 99 add[i][j]+=f[i-1][sta_r]; 100 if(sta_ans>MOD) sta_ans-=MOD; 101 if(add[i][j]>MOD) add[i][j]-=MOD; 102 } else { 103 sta_ans+=add[i-1][sta_r]; 104 add[i][j]+=add[i-1][sta_r]; 105 if(sta_ans>MOD) sta_ans-=MOD; 106 if(add[i][j]>MOD) add[i][j]-=MOD; 107 } 108 } 109 while(sta_l<sta_r && sta_l<j-K) { 110 sta_l++; 111 if(a[i-1][sta_l]!=a[i-1][sta_l-1]) { 112 sta_ans-=f[i-1][sta_l-1]; 113 minu[i][j]+=f[i-1][sta_l-1]; 114 if(sta_ans<0) sta_ans+=MOD; 115 if(minu[i][j]>MOD) minu[i][j]-=MOD; 116 } else { 117 sta_ans-=minu[i-1][sta_l]; 118 minu[i][j]+=minu[i-1][sta_l]; 119 if(sta_ans<0) sta_ans+=MOD; 120 if(minu[i][j]>MOD) minu[i][j]-=MOD; 121 } 122 } 123 f[i][j]=sta_ans; 124 } 125 } 126 ll ans=0; 127 rep(i,1,m) if(a[n][i]!=a[n][i-1]) { 128 ans+=f[n][i]; 129 if(ans>MOD) ans-=MOD; 130 } else { 131 ans+=add[n][i]; 132 if(ans>MOD) ans-=MOD; 133 } 134 cout<<ans<<endl; 135 } 136 return 0; 137 }
1004 小洛洛 小甜甜 智障题然而大家一开始都不会QAQ
1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <cmath> 5 #include <vector> 6 #include <queue> 7 #include <set> 8 #include <map> 9 #include <string> 10 #include <string.h> 11 #include <stdlib.h> 12 #include <time.h> 13 #include <climits> 14 15 using namespace std; 16 17 void work(){ 18 long long a,b,c,aa,bb,cc; 19 scanf("%lld%lld%lld",&a,&b,&c); 20 scanf("%lld%lld%lld",&aa,&bb,&cc); 21 22 long long down=(a+b+c); 23 long long up=0; 24 25 up+=aa*(c-b); 26 up+=bb*(a-c); 27 up+=cc*(b-a); 28 29 long long g=__gcd(up,down); 30 g=abs(g); 31 up/=g; 32 down/=g; 33 34 if (down==1) printf("%lld ",up); 35 else printf("%lld/%lld ",up,down); 36 } 37 38 int main(){ 39 int T; 40 scanf("%d",&T); 41 while (T--) work(); 42 return 0; 43 }
1010 有没有人告诉我为什么能直接取两个log啊? 我们数分老师告诉我们不可以啊? 取一个的话可以证明可以,但是两个的话绕不过一个e^(clnb)次方啊? 是不是什么地方姿势不是很对啊。。。。
1011 小甜甜
1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <cmath> 5 #include <vector> 6 #include <queue> 7 #include <set> 8 #include <map> 9 #include <string> 10 #include <string.h> 11 #include <stdlib.h> 12 #include <time.h> 13 #include <climits> 14 15 using namespace std; 16 17 const int maxN=1e7+7; 18 const int mod=998244353; 19 20 long long fact[maxN],invf[maxN]; 21 long long base[maxN]; 22 23 long long poww(long long x,long long k){ 24 long long ret=1; 25 while (k){ 26 if (k&1) ret=ret*x%mod; 27 k>>=1; 28 x=x*x%mod; 29 } 30 return ret; 31 } 32 33 void work(){ 34 int a,b,c,d; 35 scanf("%d%d%d%d",&a,&b,&c,&d); 36 37 long long ans=0; 38 39 long long B=1; 40 if (b>=1) B+=b; 41 ans+=B*base[c]; 42 ans%=mod; 43 44 ans+=base[b]-B; 45 ans%=mod; 46 47 if (d>=1) { 48 ans+=base[c]*d; 49 ans%=mod; 50 } 51 52 ans=ans*base[a]%mod; 53 54 printf("%lld ",ans); 55 } 56 57 int main(){ 58 fact[0]=invf[0]=1; 59 base[0]=1; 60 for (int i=1;i<maxN;i++) fact[i]=fact[i-1]*i%mod,base[i]=base[i-1]*2%mod; 61 invf[maxN-1]=poww(fact[maxN-1],mod-2); 62 for (int i=maxN-2;i>0;i--) invf[i]=invf[i+1]*(i+1)%mod; 63 64 int T; 65 scanf("%d",&T); 66 while (T--) work(); 67 return 0; 68 }