AtCoder Beginner Contest 307
A:
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<iostream> 5 #include<string> 6 #include<vector> 7 #include<stack> 8 #include<bitset> 9 #include<cstdlib> 10 #include<cmath> 11 #include<set> 12 #include<list> 13 #include<deque> 14 #include<map> 15 #include<queue> 16 #include <iomanip> 17 #include<ctime> 18 using namespace std; 19 #define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 20 #define TLE (double)clock()/CLOCKS_PER_SEC<=0.95 21 #define int long long 22 #define double long double 23 #define endl '\n' 24 #define inf LLONG_MAX 25 #define iinf INT_MAX 26 typedef pair<int,int> PII; 27 const double PI = acos(-1.0); 28 const double eps = 1e-6; 29 const int INF = 0x3f3f3f3f; 30 const int N = 20; 31 int n,a[N]; 32 signed main() 33 { 34 IOS; 35 cin>>n; 36 int sum=0; 37 for(int i=1;i<=7*n;i++) 38 { 39 cin>>a[i]; 40 sum+=a[i]; 41 if(i%7==0) 42 { 43 cout<<sum<<" "; 44 sum=0; 45 } 46 } 47 return 0; 48 }
B:
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<iostream> 5 #include<string> 6 #include<vector> 7 #include<stack> 8 #include<bitset> 9 #include<cstdlib> 10 #include<cmath> 11 #include<set> 12 #include<list> 13 #include<deque> 14 #include<map> 15 #include<queue> 16 #include <iomanip> 17 #include<ctime> 18 using namespace std; 19 #define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 20 #define TLE (double)clock()/CLOCKS_PER_SEC<=0.95 21 #define int long long 22 #define double long double 23 #define endl '\n' 24 #define inf LLONG_MAX 25 #define iinf INT_MAX 26 typedef pair<int,int> PII; 27 const double PI = acos(-1.0); 28 const double eps = 1e-6; 29 const int INF = 0x3f3f3f3f; 30 const int N = 1e2+10; 31 vector<string>v; 32 bool check(string s) 33 { 34 string tmp=s; 35 reverse(tmp.begin(),tmp.end()); 36 if(s==tmp) 37 { 38 // cout<<s<<endl; 39 return true; 40 } 41 else return false; 42 } 43 signed main() 44 { 45 IOS; 46 int n; 47 cin>>n; 48 string s; 49 for(int i=1;i<=n;i++) 50 { 51 cin>>s; 52 v.push_back(s); 53 } 54 bool flag=false; 55 for(int i=0;i<v.size();i++) 56 { 57 for(int j=0;j<v.size();j++) 58 { 59 if(i!=j) 60 { 61 string tmp=v[i]+v[j]; 62 if(check(tmp)) 63 { 64 cout<<"Yes"<<endl; 65 return 0; 66 } 67 } 68 } 69 } 70 cout<<"No"<<endl; 71 return 0; 72 }
C:太过毒瘤没写
D:常规括号匹配
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<iostream> 5 #include<string> 6 #include<vector> 7 #include<stack> 8 #include<bitset> 9 #include<cstdlib> 10 #include<cmath> 11 #include<set> 12 #include<list> 13 #include<deque> 14 #include<map> 15 #include<queue> 16 #include <iomanip> 17 #include<ctime> 18 using namespace std; 19 #define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 20 #define TLE (double)clock()/CLOCKS_PER_SEC<=0.95 21 #define int long long 22 #define double long double 23 #define endl '\n' 24 #define inf LLONG_MAX 25 #define iinf INT_MAX 26 typedef pair<int,int> PII; 27 const double PI = acos(-1.0); 28 const double eps = 1e-6; 29 const int INF = 0x3f3f3f3f; 30 const int N = 2e5+10; 31 int n; 32 string s; 33 signed main() 34 { 35 IOS; 36 cin>>n; 37 cin>>s; 38 int cnt=0; 39 stack<char>v; 40 for(int i=0;i<s.size();i++) 41 { 42 //cout<<s[i]; 43 if(s[i]=='(') 44 { 45 cnt++; 46 } 47 v.push(s[i]); 48 if(s[i]==')'&&cnt>0) 49 { 50 cnt--; 51 while(v.top()!='(') 52 { 53 // cout<<v.top(); 54 v.pop(); 55 } 56 v.pop(); 57 } 58 //cout<<flag<<endl; 59 } 60 string st=""; 61 while(!v.empty()) 62 { 63 st+=v.top(); 64 v.pop(); 65 } 66 reverse(st.begin(),st.end()); 67 cout<<st<<endl; 68 return 0; 69 }
E:给定一个环形,给其中每个位置标上数组0~n,问怎么填使得相邻两个位置的数字不同,共有多少种填法
这个我推荐去看看这个讲解:https://www.bilibili.com/video/BV1hh411N7Dd/?spm_id_from=333.999.0.0&vd_source=f42cbadda7759fe57af08969189b1479
代码就不放了
本文来自博客园,作者:江上舟摇,转载请注明原文链接:https://www.cnblogs.com/LQS-blog/p/17538779.html