A:
把每七天内走的步数加起来输出
1 #include<bits/stdc++.h> 2 using namespace std; 3 4 int main() 5 { 6 int n; 7 scanf("%d",&n); 8 while(n--){ 9 int sum=0; 10 for(int i=1;i<=7;i++){ 11 int a; 12 scanf("%d",&a); 13 sum+=a; 14 } 15 cout<<sum<<' '; 16 } 17 }View Code
B:
取两个字符串,看能不能拼起来变成回文字符串
1 #include<bits/stdc++.h> 2 using namespace std; 3 const int mxn=110; 4 string s[mxn]; 5 int n; 6 7 8 int main() 9 { 10 std::ios::sync_with_stdio(false); 11 cin.tie(0),cout.tie(0); 12 13 cin>>n; 14 for(int i=1;i<=n;i++)cin>>s[i]; 15 16 for(int i=1;i<=n;i++){ 17 18 for(int j=1;j<=n;j++){ 19 if(i==j)continue; 20 string t=s[i]+s[j]; 21 string res=""; 22 for(int k=t.length()-1;k>=0;k--)res+=t[k]; 23 if(t==res){cout<<"Yes\n";return 0;} 24 } 25 } 26 cout<<"No\n"; 27 }View Code
D:
把括号里的东西删掉
1 #include <bits/stdc++.h> 2 using namespace std; 3 const int N = 2e5+10; 4 #define int long long 5 6 int n,m; 7 int a[N]; 8 //string s[N]; 9 signed main(){ 10 cin.tie(0);cout.tie(0);ios::sync_with_stdio(0); 11 cin>>n; 12 string s; 13 cin>>s; 14 stack<char> st; 15 string res; 16 for(int i=0;i<s.size();i++) 17 { 18 if(s[i]!=')'&&s[i]!='(') 19 { 20 res.push_back(s[i]); continue; 21 } 22 if(st.empty()) st.push(s[i]),res.push_back(s[i]); 23 else{ 24 if(st.size()&&st.top()=='('&&s[i]==')') 25 { 26 while(res.size()&&res.back()!='(') res.pop_back(); 27 res.pop_back(); 28 st.pop(); 29 continue; 30 } 31 else st.push(s[i]),res.push_back(s[i]); 32 } 33 } 34 cout<<res; 35 }View Code
E:
给n个人和m个数字,不能用一样的数字站在一起
1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 const ll mxn=1e6+6,mod=998244353; 5 6 ll n,m; 7 ll dp[mxn][2]; 8 9 10 int main() 11 { 12 std::ios::sync_with_stdio(false); 13 cin.tie(0),cout.tie(0); 14 cin>>n>>m; 15 dp[1][1]=m; 16 for(int i=2;i<=n;i++){ 17 dp[i][0]=(dp[i-1][0]*(m-2)+dp[i-1][1]*(m-1))%mod; 18 dp[i][1]=dp[i-1][0]; 19 } 20 cout<<dp[n][0]<<'\n'; 21 22 }View Code
标签:std,10,cout,int,cin,307,tie From: https://www.cnblogs.com/cancanneed/p/17621330.html