Rumah > Artikel > hujung hadapan web > Codeforces Round#263(Div.2)_html/css_WEB-ITnose
462 A 题意读懂后就好做了,就是与一个方块上下左右相邻的‘o’的个数,如果是偶数,yes,否则,no。
#include<map>#include<cmath>#include<queue>#include<vector>#include<cstdio>#include<string>#include<cstring>#include<iostream>#include<algorithm>#define pi acos(-1.0)#define inf 0xfffffff#define maxn 5000using namespace std;char str[maxn][maxn];int a[maxn],b[maxn];int main(){ int n; scanf("%d",&n); for(int i=0;i<n scanf for i="0;i<n;i++)" j="0;j<n;j++)" int flag="0;" if>0) { if(str[i-1][j]=='o') flag++; } if(i<n-1 if flag>0) { if(str[i][j-1]=='o') flag++; } if(j<n-1 if flag cout return printf> <br> 462B 按照字母出现的次数排序,sum就取决于每一个字母的最大个数与k的大小关系。 <p></p> <p></p> <pre name="code" class="sycode">#include<map>#include<cmath>#include<queue>#include<vector>#include<cstdio>#include<string>#include<cstring>#include<iostream>#include<algorithm>#define pi acos(-1.0)#define inf 0xfffffff#define maxn 500000using namespace std;char str[maxn];__int64 a[30];__int64 n,k;bool cmp(__int64 u,__int64 v){ return u>v;}int main(){ scanf("%I64d%I64d",&n,&k); memset(a,0,sizeof(a)); scanf("%s",str); for(int i=0;str[i]!='\0';i++) { int m=(int)(str[i]-'A'); a[m]++; } sort(a,a+27,cmp); __int64 t=0; __int64 sum=0; while(k>0) { if(k>=a[t]) { sum+=a[t]*a[t]; k-=a[t]; t++; } else { sum+=k*k; k=0; } } printf("%I64d\n",sum); return 0;}</algorithm></iostream></cstring></string></cstdio></vector></queue></cmath></map>
#include<map>#include<cmath>#include<queue>#include<vector>#include<cstdio>#include<string>#include<cstring>#include<iostream>#include<algorithm>#define pi acos(-1.0)#define inf 0xfffffff#define maxn 500000using namespace std;__int64 a[maxn],b[maxn];__int64 sum=0;bool cmp(__int64 a,__int64 b){ return a>b;}int main(){ int n; scanf("%d",&n); for(int i=0;i<n scanf sort b for i="0;i<n-1;i++)" cout>0;i--) sum+=b[i]; for(int i=0;i<n sum cout return> <br> <p></p> </n></n></algorithm></iostream></cstring></string></cstdio></vector></queue></cmath></map>