因为去年考原题了,所以再次开启了刷水之旅
#include<cstdio> #include<iostream> #include<cstring> #include<algorithm> using namespace std; char s[150]; int cnt[150],appear; inline bool is_prime(int x) { if(x<=1) return false; for(register int i=2;i*i<=x;++i) if(x%i==0) return false; return true; } inline bool cmp(int x,int y) { return x>y; } int main() { scanf("%s",s); int l=strlen(s); for(register int i=0;i<l;++i) { int tmp=s[i]-'a'+1; cnt[tmp]++; if(cnt[tmp]==1) appear++; } //sort(cnt+1,cnt+30,cmp); int minn=21000,maxn=0; for(register int i=1;i<=26;++i) { if(cnt[i]!=0) minn=min(cnt[i],minn); maxn=max(cnt[i],maxn); } if(is_prime((maxn-minn))) printf("Lucky Word %d",maxn-minn); else printf("No Answer 0"); return 0; }
#include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #define MAXN 1010 using namespace std; struct node { int st,ed; }; node a[MAXN]; int n,ans=0; inline bool cmp(node x,node y) { return x.ed<y.ed; } int main() { scanf("%d",&n); for(register int i=1;i<=n;++i) scanf("%d%d",&a[i].st,&a[i].ed); sort(a+1,a+n+1,cmp); int now=0; for(register int i=1;i<=n;++i) { if(a[i].st>=now) { ++ans; now=a[i].ed; } } printf("%d ",ans); return 0; }