标签:return 组合 个人感受 ret 个人 重复 pop als com
个人感受:这次分数是50+40+0,也就是说两天分数相加是340分,是达不了标的,这次第一题打好以后,想了许久第二题,发现了有重复元素的排列
但是两个元素,就是求一个组合(这个没想到,就算会Lucas也没什么用),╮(╯▽╰)╭,然后第三题,暴力都写不出什么,拿了个0分。
gemo.cpp
1 #include<cstdio> 2 #include<algorithm> 3 #include<iostream> 4 #include<cmath> 5 #include<cstring> 6 7 using namespace std; 8 9 int n,m,p; 10 int a[100007],b[100007]; 11 12 int main() 13 { 14 freopen("gemo.in","r",stdin); 15 freopen("gemo.out","w",stdout); 16 17 scanf("%d%d%d",&n,&m,&p); 18 for (int i=1;i<=m;i++) 19 scanf("%d%d",&a[i],&b[i]); 20 printf("%d",n-1-1-p); 21 }
liqi.cpp
1 #include<cstdio> 2 #include<algorithm> 3 #include<iostream> 4 #include<cmath> 5 #include<cstring> 6 #include<queue> 7 #define LL long long 8 #define NN 100007 9 #define fzy pair<LL,LL> 10 11 using namespace std; 12 13 int n,m; 14 LL len; 15 struct Node 16 { 17 LL l,r; 18 }a[NN]; 19 20 bool solve(int num) 21 { 22 priority_queue<fzy,vector<fzy>,greater<fzy> >q; 23 for (int i=1;i<=num;i++) q.push(make_pair(a[i].l,a[i].r)); 24 LL res=0,mx=0; 25 while (!q.empty()) 26 { 27 fzy now=q.top(); 28 q.pop(); 29 if (now.first>mx+1) 30 { 31 int t=now.first-1-mx; 32 if (t%len==0) res+=t/len; 33 else 34 { 35 res=res+t/len+1; 36 t=(len-t%len)+now.first-1; 37 if (t>now.second) 38 q.push(make_pair(now.first,t)); 39 mx=t; 40 } 41 mx=max(mx,now.second); 42 } 43 else mx=max(mx,now.second); 44 } 45 int t; 46 if (mx<n) 47 { 48 if ((n-mx)%len==0) res+=(n-mx)/len; 49 else res+=(n-mx)/len+1; 50 } 51 if (res<=num) return true; 52 else return false; 53 } 54 int main() 55 { 56 freopen("liqi.in","r",stdin); 57 freopen("liqi.out","w",stdout); 58 59 scanf("%d%d%lld",&n,&m,&len); 60 for (int i=1;i<=m;i++) 61 scanf("%lld%lld",&a[i].l,&a[i].r); 62 63 int l=1,r=m; 64 while (l<r) 65 { 66 int mid=(l+r)>>1; 67 if (solve(mid)) r=mid; 68 else l=mid+1; 69 } 70 71 printf("%d\n",l); 72 }
zhexue.cpp
1 #include<cstdio> 2 #include<iostream> 3 #include<cmath> 4 #include<cstring> 5 #include<algorithm> 6 #define mod 1000003 7 #define NN 5007 8 9 using namespace std; 10 11 int n,m,p; 12 int f[NN][NN]; 13 long long q[100007]; 14 15 long long ksm(long long a,int b) 16 { 17 long long ans=1; 18 while (b) 19 { 20 if (b&1) ans=ans*a%mod; 21 a=(a*a)%mod; 22 b=b>>1; 23 } 24 return ans; 25 } 26 void solve() 27 { 28 n++,m++; 29 if (n>m) 30 { 31 printf("0\n"); 32 return; 33 } 34 if (n==m) 35 { 36 printf("1\n"); 37 return; 38 } 39 q[1]=1; 40 for (int i=2;i<=m;i++) 41 q[i]=q[i-1]*i%mod; 42 long long x=q[m-1],y=q[n-1]*q[m-n]%mod; 43 y=ksm(y,mod-2); 44 long long ans=(x*y)%mod; 45 printf("%lld\n",ans); 46 } 47 int main() 48 { 49 freopen("zhexue.in","r",stdin); 50 freopen("zhexue.out","w",stdout); 51 52 scanf("%d%d%d",&n,&m,&p); 53 if (n<=5000&&m<=5000) 54 { 55 int x,y; 56 for (int i=1;i<=p;i++) 57 { 58 scanf("%d%d",&x,&y); 59 f[x][y]=-1; 60 } 61 for (int i=1;i<=m;i++) 62 f[1][i]=f[1][i-1]+1; 63 for (int i=2;i<=n;i++) 64 for (int j=i;j<=m;j++) 65 if (f[i][j]!=-1) f[i][j]=(f[i][j-1]+f[i-1][j-1])%mod; 66 else f[i][j]=f[i][j-1]; 67 printf("%d\n",f[n][m]); 68 } 69 else if (p==0) solve(); 70 }
标签:return 组合 个人感受 ret 个人 重复 pop als com
原文地址:http://www.cnblogs.com/fengzhiyuan/p/7522639.html