#include <bits/stdc++.h>
using namespace std;
int n,k;
int main(){
cin>>n>>k;
vector<int>a(n,0);
for(int i=0;i<n;i++)
cin>>a[i];
if( k>n || k<2 )
cout<<"-1\n";
else{
for(int i=0; i+1 < k; i++){
swap(a[i],a[i+1]);
}
for(int i=0;i<n;i++){
cout<<a[i]<<" \n"[i==n-1];
}
}
return 0;
}
cout<<a[i]<< " \n"[i==n-1];
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int main() {
cin>>s;
string t=s;
if(s.size()==1) {
int tmp=s.back()-'0'; //stoi(s);
if(tmp % 4 == 0) cout<<0<<'\n';
else cout<<-1<<'\n';
} else {
int cnt=0;
int tmp=(s[s.size()-2]-'0')*10+s.back()-'0';
if(tmp % 4 == 0) {
cout<<cnt;
return 0;
}
for(int i=0; i<s.size(); i++) {
cnt++;
t.push_back(s[i]);
int tmp = (t[t.size()-2]-'0')*10+t.back()-'0';
if(tmp%4==0) {
cout<<cnt;
return 0;
}
}
cout<<-1;
}
return 0;
}
标签:tmp,周赛,cout,int,namespace,41,牛客,main
From: https://www.cnblogs.com/ltphy-/p/18175930