cpp
复制代码
#include<bits/stdc++.h>
using namespace std;
void solve(){
string s;
cin>>s;
if(s.length()<=1)cout<<"yukari";
else cout<<"kou"<<endl;
}
int main(){
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int t;
// cin>>t;
t=1;
while(t--)solve();
return 0;
}
cpp
复制代码
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1e9+7;
void solve(){
int n;
cin>>n;
vector<int>a(n+1);
for(int i=1;i<=n;i++)cin>>a[i];
string s;
cin>>s;
int j=1,ans=0;
for(auto i:s){
if(i=='R'&&j<n)ans=(ans+a[++j])%mod;
else if(i=='L'&&j>1)ans=(ans+a[--j])%mod;
else ans=(ans+a[j])%mod;
}
cout<<ans%mod<<endl;
}
signed main(){
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int t;
// cin>>t;
t=1;
while(t--)solve();
return 0;
}
cpp
复制代码
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e7+10;
set<int>st;
void solve(){
int n;
cin>>n;
vector<int>a(n+1);
for(int i=1;i<=n;i++)cin>>a[i];
sort(a.begin(),a.end());
int i=1;
if(n&1){
st.insert(a[n]);
n--;
}
for(i=1;i<=n/2;i++)st.insert(a[i]*a[n-i+1]);
if(st.size()!=1)cout<<abs(*prev(st.end())-*st.begin())<<endl;
else cout<<0<<endl;
}
signed main(){
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int t;
// cin>>t;
t=1;
while(t--)solve();
return 0;
}
cpp
复制代码
#include<bits/stdc++.h>
using namespace std;
vector<vector<int>>E;
vector<bool>vis;
int ans=0,f=1;
int dfs(int u,int fa){
vis[u]=1;
int len=1;
for(auto v:E[u]){
if(!vis[v]){
int lenc=dfs(v,u);
len+=lenc;
}
}
if(len%2==0&&u!=1)ans++;
return len;
}
void solve(){
int n;
cin>>n;
E.resize(n+1);
vis.resize(n+1,false);
for(int i=1;i<n;i++){
int x,y;
cin>>x>>y;
E[x].push_back(y);
E[y].push_back(x);
}
if(n&1){cout<<-1<<endl;return ;}
dfs(1,0);
cout<<ans<<endl;
}
int main(){
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int t;
// cin>>t;
t=1;
while(t--)solve();
return 0;
}