BestCoder Round #58 (div.2) A B C
来源:互联网 发布:mac装win10连不上wifi 编辑:程序博客网 时间:2024/04/25 16:10
Card Game
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 254 Accepted Submission(s): 197
First, they choose a number
The first line contains two integer
23 14 5 61 2 35 23 4 7 8 93 4 5 2 3
YESNO
水题。第一个人取最小,第二个人取最大,判断一下就好。
#include<bits/stdc++.h>using namespace std;int main(){ int t; scanf("%d",&t); while(t--) { int a[1005]; int b[1005]; int n,m; cin>>n>>m; for(int i=0; i<n; i++) cin>>a[i]; for(int i=0; i<n; i++) cin>>b[i]; sort(a,a+n); sort(b,b+n); int ans1=0; int ans2=0; for(int i=0; i<m; i++) ans1+=a[i]; for(int i=n-1; m>0; m--,i--) ans2+=b[i]; if(ans1>ans2) puts("YES"); else puts("NO"); } return 0;}
LCS
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 503 Accepted Submission(s): 272
The first line contains an integer
The sum of
231 2 33 2 161 5 3 2 6 43 6 2 4 5 1
24
求出环的个数,只要长度大于2 。n就减一
#include<bits/stdc++.h>#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>#include <cmath>using namespace std;#define inf 0x7f7f7fint a[100005];int b[100005];int c[100005];int vis[100005];int main(){ int t; scanf("%d",&t); while(t--) { int n; int i; scanf("%d",&n); memset(c,0,sizeof(c)); memset(vis,0,sizeof(vis)); for(i=0; i<n; i++) scanf("%d",&a[i]); for(i=0; i<n; i++) { scanf("%d",&b[i]); c[b[i]]=i; } int ans=0; for(i=0; i<n; i++) { if(!vis[i]) { int now=i; int len=0; while(!vis[now]) { vis[now]=1; now=c[a[now]]; len++; } if(len>1) ans++; } } printf("%d\n",n-ans); } return 0;}
Beauty of Sequence
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 550 Accepted Submission(s): 249
Problem Description
Sequence is beautiful and the beauty of an integer sequence is defined as follows: removes all but the first element from every consecutive group of equivalent elements of the sequence (i.e. unique function in C++ STL) and the summation of rest integers is the beauty of the sequence.
Now you are given a sequence
Note: In mathematics, a sub-sequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example
Input
There are multiple test cases. The first line of input contains an integer
The first line contains an integer
The sum of values
Output
For each test case, print the answer modulo
Sample Input
351 2 3 4 541 2 1 353 3 2 1 2
Sample Output
24054144
Source
BestCoder Round #58 (div.2)
Recommend
hujie | We have carefully selected several similar problems for you: 5498 5497 5490 5489 5488
考虑每个数字的贡献 ,显然是a[i]*2^(n-i)。
我们用sum记录前面的集合个数。
用mp[a[i]]]表示连续相同的数字对集合所产生的影响,即用sum-掉map[a[i]]]最终的子集的贡献。
#include<bits/stdc++.h>#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>#include <cmath>#include <map>using namespace std;#define inf 0x7f7f7ftypedef long long ll;const ll N=1e5+100;const ll mod=1e9+7;ll a[N];ll f[N];map<ll,ll>mp;int main(){ int i; int t; f[0]=1; for(i=1; i<N; i++) f[i]=f[i-1]*2%mod; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); for(i=1; i<=n; i++) scanf("%lld",&a[i]); ll ans=0; ll sum=1; mp.clear(); for(i=1; i<=n; i++) { ans=(ans+a[i]*(sum-mp[a[i]])%mod*f[n-i]%mod)%mod; sum=(sum+f[i-1])%mod; mp[a[i]]=(mp[a[i]]+f[i-1])%mod; } ans+=mod; printf("%lld\n",ans%mod); } return 0;}
- BestCoder Round #58 (div.2) A B C
- BestCoder Round #76 (div.2) A B C
- BestCoder Round #77 (div.2) A B C D
- BestCoder Round #81 (div.2) A,B,C
- BestCoder Round #78 (div.2) A B
- BestCoder Round #82 (div.2) A B
- BestCoder Round #7-A,B,C
- BestCoder Round #8 A,B,C
- BestCoder Round #29 A,B,C
- BestCoder Round #40 A B C
- BestCoder Round #41 A B C
- HDU 5671 5672 5673 BestCoder Round #81 (div.1) A B C
- BestCoder Round #58 (div.2)
- BestCoder Round #51 (div.2) A
- BestCoder Round #59 (div.2)A.SDOI
- BestCoder Round #77 (div.2)(A)
- BestCoder Round #76 (div.2)A
- BestCoder Round #81 (div.2)A
- 代理模式
- 查询数据
- on the way to c++
- 图解SSL/TLS协议
- leetcode290
- BestCoder Round #58 (div.2) A B C
- LRU策略的CachePool
- POJ 3368 Frequent values(区间频繁次数 RMQ)
- Lintcode 二叉树中序遍历
- ios--正则表达式
- Android studio中如何使用SVN进行版本控制?
- HDU 5497 Inversion
- 关于Objective-C中的init和self的一些问题
- 饼状图