这次比赛很顺利的出了3个题,rating上涨了98,菜菜的我后面的不会了。
A - Reverse a Substring
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
const int MOD=1e9+7;int main(){int n;scanf("%d\n",&n);string t;cin>>t;int l=0,r=0;for(int i=1;i<n;i++){if(t[i]<t[l]){r=i;break;}else l=i;}if(r!=0){printf("YES\n");printf("%d %d\n",l+1,r+1);}else{printf("NO\n");}return 0;
}
B - Game with Telephone Numbers
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
const int MOD=1e9+7;int main(){int n,cnt=0;scanf("%d\n",&n);string t;cin>>t;n=n-10;for(int i=0;i<n;i++){if(t[i]=='8') cnt++;}if(cnt>=(n+1)/2){printf("YES\n");}else{printf("NO\n");}return 0;
}
C - Alarm Clocks Everywhere
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
const int MOD=1e9+7;ll gcd(ll a,ll b){if(b==0) return a;return gcd(b,a%b);
}int main(){ll n,m;scanf("%lld%lld",&n,&m);ll x,p,a1,b1=-1,g,pre,b;scanf("%lld%lld",&a1,&b);g=b-a1;pre=b;for(ll i=3;i<=n;i++){scanf("%lld",&x);g=gcd(g,x-pre);pre=x;}for(ll i=1;i<=m;i++){scanf("%lld",&p);if(g%p==0) b1=i;}if(b1!=-1){printf("YES\n%lld %lld\n",a1,b1);}else{printf("NO\n");}return 0;
}