Codeforces Round #519 by Botan Investments
Posted chunibyo
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round #519 by Botan Investments相关的知识,希望对你有一定的参考价值。
Codeforces Round #519 by Botan Investments
1 #include<bits/stdc++.h> 2 #include<iostream> 3 #include<cstdio> 4 #include<cstdlib> 5 #include<cstring> 6 #include<cmath> 7 #include<algorithm> 8 #include<queue> 9 #include<vector> 10 #include<map> 11 #define lson i<<1 12 #define rson i<<1|1 13 #define LS l,mid,lson 14 #define RS mid+1,r,rson 15 #define mem(a,x) memset(a,x,sizeof(a)) 16 #define gcd(a,b) __gcd(a,b) 17 #define ll long long 18 #define ull unsigned long long 19 #define lowbit(x) (x&-x) 20 #define pb(x) push_back(x) 21 #define enld endl 22 #define mian main 23 #define itn int 24 #define prinft printf 25 #define Max(a,b,c) max(a,max(b,c)) 26 #pragma GCC optimize(2) 27 //#pragma comment(linker, "/STACK:102400000,102400000") 28 29 const double PI = acos (-1.0); 30 const ll INF = 0x3f3f3f3f3f3f3f3f; 31 const int EXP = 1e-8; 32 const int N = 1e5 + 5; 33 const int MOD = 1e9 + 7; 34 const int MAXN = 1e5+15; 35 const int Mod = 1e9 + 7; 36 37 using namespace std; 38 39 int sum=0; 40 int temp; 41 int maxn=0; 42 int main() { 43 //std::ios::sync_with_stdio(false); 44 //cin.tie(NULL); 45 int n=0; 46 while(cin>>n) { 47 sum=0; 48 for(int i=1;i<=n;++i) { 49 cin>>temp; 50 sum+=temp; 51 maxn=max(temp,maxn); 52 } 53 for(int k=maxn;;++k) { 54 if(k*n-sum>sum) { 55 cout<<k<<endl; 56 break; 57 } 58 } 59 } 60 }
1 #include<bits/stdc++.h> 2 #include<iostream> 3 #include<cstdio> 4 #include<cstdlib> 5 #include<cstring> 6 #include<cmath> 7 #include<algorithm> 8 #include<queue> 9 #include<vector> 10 #include<map> 11 #define lson i<<1 12 #define rson i<<1|1 13 #define LS l,mid,lson 14 #define RS mid+1,r,rson 15 #define mem(a,x) memset(a,x,sizeof(a)) 16 #define gcd(a,b) __gcd(a,b) 17 #define ll long long 18 #define ull unsigned long long 19 #define lowbit(x) (x&-x) 20 #define pb(x) push_back(x) 21 #define enld endl 22 #define mian main 23 #define itn int 24 #define prinft printf 25 #define Max(a,b,c) max(a,max(b,c)) 26 #pragma GCC optimize(2) 27 //#pragma comment(linker, "/STACK:102400000,102400000") 28 29 const double PI = acos (-1.0); 30 const int INF = 0x3f3f3f3f; 31 const int EXP = 1e-8; 32 const int N = 1e5 + 5; 33 const int MOD = 1e9 + 7; 34 const int MAXN = 1e3+15; 35 const int Mod = 1e9 + 7; 36 37 using namespace std; 38 39 int n; 40 int a[MAXN]; 41 int ans[MAXN]; 42 43 bool check(int x) 44 { 45 for(int i=0;i+x<n;++i) { 46 if(a[i+1]-a[i]!=a[i+x+1]-a[i+x]) return false; 47 } 48 return true; 49 } 50 51 int main() { 52 //std::ios::sync_with_stdio(false); 53 //cin.tie(NULL); 54 cin>>n; 55 for(int i=1;i<=n;++i) cin>>a[i]; 56 int cnt=0; 57 a[0]=0; 58 for(int i=1;i<=n;++i) { 59 if(check(i)) ans[cnt++]=i; 60 } 61 cout<<cnt<<endl; 62 for(int i=0;i<cnt;++i ) { 63 if(i) cout<<‘ ‘; 64 cout<<ans[i]; 65 }cout<<endl; 66 }
1 //#include<bits/stdc++.h> 2 #include<iostream> 3 #include<cstdio> 4 #include<cstdlib> 5 #include<cstring> 6 #include<cmath> 7 #include<algorithm> 8 #include<queue> 9 #include<vector> 10 #include<map> 11 #define lson i<<1 12 #define rson i<<1|1 13 #define LS l,mid,lson 14 #define RS mid+1,r,rson 15 #define mem(a,x) memset(a,x,sizeof(a)) 16 #define gcd(a,b) __gcd(a,b) 17 #define ll long long 18 #define ull unsigned long long 19 #define lowbit(x) (x&-x) 20 #define pb(x) push_back(x) 21 #define enld endl 22 #define mian main 23 #define itn int 24 #define prinft printf 25 #define Max(a,b,c) max(a,max(b,c)) 26 #pragma GCC optimize(2) 27 //#pragma comment(linker, "/STACK:102400000,102400000") 28 29 const double PI = acos (-1.0); 30 const ll INF = 0x3f3f3f3f3f3f3f3f; 31 const int EXP = 1e-8; 32 const int N = 1e5 + 5; 33 const int MOD = 1e9 + 7; 34 const int MAXN = 1e5+15; 35 const int Mod = 1e9 + 7; 36 37 using namespace std; 38 39 string s; 40 int a[MAXN]; 41 42 int main() { 43 std::ios::sync_with_stdio(false); 44 cin.tie(NULL); 45 46 cin>>s; 47 48 if(s.size()==1) {cout<<1<<endl; return 0;} 49 50 mem(a,0); 51 for(int i=0;i<s.size()-1;++i) { 52 if(i)cout<<‘ ‘; 53 if(s[i]!=s[i+1]) cout<<1; 54 else cout<<0; 55 } 56 if(s[s.size()-1]==‘a‘) cout<<" 1"<<endl; 57 else cout<<" 0"<<endl; 58 }
1 #include<bits/stdc++.h> 2 #include<iostream> 3 #include<cstdio> 4 #include<cstdlib> 5 #include<cstring> 6 #include<cmath> 7 #include<algorithm> 8 #include<queue> 9 #include<vector> 10 #include<map> 11 #define lson i<<1 12 #define rson i<<1|1 13 #define LS l,mid,lson 14 #define RS mid+1,r,rson 15 #define mem(a,x) memset(a,x,sizeof(a)) 16 #define gcd(a,b) __gcd(a,b) 17 #define ll long long 18 #define ull unsigned long long 19 #define lowbit(x) (x&-x) 20 #define pb(x) push_back(x) 21 #define enld endl 22 #define mian main 23 #define itn int 24 #define prinft printf 25 #define Max(a,b,c) max(a,max(b,c)) 26 #pragma GCC optimize(2) 27 //#pragma comment(linker, "/STACK:102400000,102400000") 28 29 const double PI = acos (-1.0); 30 const ll INF = 0x3f3f3f3f3f3f3f3f; 31 const int EXP = 1e-8; 32 const int N = 1e5 + 5; 33 const int MOD = 1e9 + 7; 34 const int MAXN = 1e5+15; 35 const int Mod = 1e9 + 7; 36 37 using namespace std; 38 39 int n,m; 40 int a[12][MAXN]; 41 int pre[12][MAXN]; 42 ll ans[MAXN]; 43 ll q; 44 45 int main() { 46 std::ios::sync_with_stdio(false); 47 cin.tie(NULL); 48 49 cin>>n>>m; 50 mem(ans,0); 51 for(int i=1; i<=m; ++i) { 52 for(int j=1; j<=n; ++j) { 53 cin>>a[i][j]; 54 if(j-1==0) 55 pre[i][a[i][j]]=0; 56 else 57 pre[i][a[i][j]]=a[i][j-1]; 58 59 } 60 } 61 q=n; 62 for(int i=2; i<=n; ++i) { 63 ll cnt=0; 64 for(int j=1; j<m; ++j) { 65 if(pre[j][a[m][i]]==pre[m][a[m][i]]) 66 cerr<<++cnt<<endl; 67 //++cnt; 68 } 69 if(cnt==m-1) 70 ans[i]=ans[i-1]+1; 71 q+=ans[i]; 72 } 73 cout<<q<<endl; 74 75 }
以上是关于Codeforces Round #519 by Botan Investments的主要内容,如果未能解决你的问题,请参考以下文章
Codeforces Round #519 by Botan Investments
Codeforces Round #519 by Botan Investments翻车记
Codeforces Round #519 by Botan Investments F. Make It One