Codeforces Round #136 (Div. 2)

CodeForces - 221A

A

Meaning of the questions: to find such a sequence, after the operation to make it function after the title, will become an increasing sequence.

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	scanf("%d",&n); 
	printf("%d ",n);
	for(int i=2;i<=n;++i) printf("%d ",i-1);
	return 0;
}

B

Meaning of the questions:

#include<bits/stdc++.h>
using namespace std;
string ss;
int main(){
	int n,ans=0;
	scanf("%d",&n);	
	ss=to_string(n);	
	for(int i=1;i<=sqrt(n);++i){
		if(n%i==0){
			if(ss.find_first_of(to_string(i))!=-1)++ans;
			if(n/i!=i&&ss.find_first_of(to_string(n/i))!=-1)++ans;
		}
	}
	cout<<ans<<endl;
}

C

#include<bits/stdc++.h>
using namespace std;
int ii[100005];
int a[100005];
int b[100005];
multimap<int,int>mp;
int main(){
	int n;	
	scanf("%d",&n);
	int x;
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		b[i]=a[i];
	} 
	sort(b+1,b+1+n);
	int i=0,cnt=0;
	bool flag=false;
	for(int i=1;i<=n;++i){
		if(a[i]!=b[i]){
			ii[cnt]=i;
			++cnt;
			if(cnt>2){
				puts("NO");
				return 0;
			}else if(cnt==2){
				if(a[ii[0]]==b[ii[1]]&&a[ii[1]]==b[ii[0]]) flag=true;
			}
		}
	}
	if(flag) puts("YES"); else if(cnt==0) puts("YES");else puts("NO");
	return 0;
}

 

Guess you like

Origin blog.csdn.net/weixin_42104573/article/details/88231639