A
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
string str;
cin>>str;
int s,e,l;
l=str.length();
for(int i=0;i<str.length();i++)
{
if(str[i]=='F') s=i+1;
if(str[i]=='S') e=i+1;
}
int n,a;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a;
if(s+a>l)
{
s=2*l-(a+s);
}
else s+=a;
if(s == e) {
cout << "true";
return 0;
}
}
cout<<"false";
return 0;
}
B
#include<bits/stdc++.h>
using namespace std;
int main()
{
char s[1000];
cin >>s;
int l;
l=strlen(s);
int i;
for(i=0;i<l;i++)
{
if(s[i]!='.')
{
printf("%c",s[i]);
}
else
{
printf(" ");
}
}
}
C
#include <bits/stdc++.h>
#define dx i + dir[k]
#define dy j + dir[k + 1]
using namespace std;
int dir[] = {0, -1, 0, 1, 0};
int a[105][105];
int main() {
int n;
cin >> n;
for(int i = 0; i < n; ++i) {
for(int j = 0; j < n; ++j) {
cin >> a[i][j];
}
}
int sum = 0;
for(int i = 0; i < n; ++i) {
for(int j = 0; j < n; ++j) {
if(a[i][j]) {
sum += 4 * a[i][j] + 2;
for(int k = 0; k < 4; ++k) {
if(dx >= 0 && dx < n && dy >= 0 && dy < n) {
sum -= min(a[dx][dy], a[i][j]);
}
}
}
}
}
cout << sum;
return 0;
}
D
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int a[100005]={0};
int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
sort(a,a+n,[&](int a,int b){
return a<b;
});
for(int i=0;i<n;i++)
{
if(i!=0) cout<<" ";
cout<<a[i];
}
return 0;
}
E
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long n,sum=10,l,t=1; int cnt;
scanf("%lld",&n);
while(sum>=10)
{
sum=0;
while(t!=0)
{
l=n%10;
t=n/10;
n=n/10;
sum=sum+l;
}
n=sum;
t=1;
}
cout<<sum;
return 0;
}
E
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin >> n;
if(n < 10) cout << n;
else if(n % 9) cout << n % 9;
else cout << 9;
return 0;
}
F
#include<iostream>
using namespace std;
int main(){
int t,x,y;
cin>>t;
for(int i=0;i<t;i++){
cin>>x>>y;
if(x==0) cout<<y+1<<endl;
else if(x==1) cout<<y+2<<endl;
else if(x==2) cout<<2*y+3<<endl;
else if(x==3) cout<<(1<<(y+3))-3<<endl;
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int A(int m,int n) {
if(n==0&&m!=0) return A(m-1,1);
else if(m==0)return n+1;
else if(m==1) return n+2;
else if(m==2) return 2*n+3;
// else if(m==3)return A(m,n-1)*2+3;
else if(m==3) return (1<<n+3)-3;
}
int main() {
// freopen("test1.in","r",stdin);
// freopen("test1.out","w",stdout);
int t;
cin >> t;
for(int j=1; j<=t; ++j) {
int m,n;
cin >> m >> n;
cout << A(m,n) << endl;
}
return 0;
}
G
#include<bits/stdc++.h>
using namespace std;
int missingNumber(int nums[],int n) {
int res = 0;
// 先和新补的索引异或?下
res ^= n;
// 和其他的元素、索引做异或
for (int i = 0; i < n; i++)
res ^= i ^ nums[i];
return res;
}
int a[1000005];
int main() {
// freopen("1.in","r",stdin);
int n;
cin >> n;
for(int i=0;i<n;++i){
cin >> a[i];
}
cout << missingNumber(a,n);
return 0;
}