Codeforces Round #364 (Div. 2)【A,C】
来源:互联网 发布:非典真实死亡人数知乎 编辑:程序博客网 时间:2024/04/28 01:42
啊啊啊啊啊啊啊啊啊,目睹A->CⅠA全过,最终fstwaA,C;23333333
A题:
题意:
就是分成相等的m堆,每堆有两个位置上的值相加。
思路:
fst在sum可能不是偶数,先*2/n;。。。。。。。。。。。。。。哭死。。
code:
#include <bits/stdc++.h>using namespace std;typedef long long LL;typedef unsigned long long ULL;const double eps=1e-6;const double pi=acos(-1.0);const int mod=998244353;const int INF=0x3f3f3f3f;const int N=1e2+10;int a[N];bool vis[N];int n;int main(){ cin>>n; int sum=0; for(int i=1;i<=n;i++) { scanf("%d",&a[i]); sum+=a[i]; } memset(vis,0,sizeof(vis)); int x=sum*2/n; for(int i=1;i<=n;i++){ if(!vis[i]) { printf("%d ",i); vis[i]=1; for(int j=1;j<=n;j++) { if(!vis[j]){ if((a[i]+a[j])==x) { printf("%d\n",j); vis[j]=1; break; } } } } }}
C题:
题意就是求一个最短连续区间长度包含给定字符串的所有种类。
思路:写挫了。。。。
code:
#include <bits/stdc++.h>using namespace std;typedef long long LL;typedef unsigned long long ULL;const double eps=1e-6;const double pi=acos(-1.0);const int mod=998244353;const int INF=0x3f3f3f3f;const int N=1e5+10;char s[N];bool v1[N];int v2[N];int p1,p2;int main(){ int len; scanf("%d",&len); scanf("%s",s); int sum; int x; sum=0; memset(v1,0,sizeof(v1)); for(int i=0;i<len;i++){ x=s[i]; if(!v1[x]){ sum++; v1[x]=1; } } memset(v2,0,sizeof(v2)); int ans=INF; int num=0; int flag=0; p1=p2=0; num=0; while(1) { flag=0; while(num<sum){ if(p2==len) break; x=s[p2]; if(!v2[x]) num++; v2[x]++; p2++; flag=1; // printf("p2=%d\n",p2); } while(num==sum){ ans=min(ans,p2-p1); x=s[p1]; v2[x]--; if(!v2[x]) num--; p1++; flag=1; // printf("p1=%d\n",p1); } if(!flag) break; } printf("%d\n",ans); return 0;}
0 0
- Codeforces Round #364 (Div. 2)【A,C】
- Codeforces Round #219 (Div. 2) A-C
- Codeforces Round #220 (Div. 2)A-C
- Codeforces Round #241 (Div. 2) A~C
- Codeforces Round #244 (Div. 2) A~C
- Codeforces Round #260 (Div. 2) A ~ C
- Codeforces Round #301 (Div. 2) A、C
- Codeforces Round #365 (Div. 2) A~C
- Codeforces Round #368 (Div. 2) A C
- Codeforces Round #393 (Div. 2) A---C
- Codeforces Round #452 (Div. 2) A-C
- Codeforces Round #453 (Div. 2) A-C
- Codeforces Round #364 (Div. 2)(A,B,C,D) 题解
- Codeforces Round #364 (Div. 2)(A,B,C,D)
- Codeforces Round #230 (Div. 2) C / (Div. 1) A
- Codeforces Round #364 (Div. 2) A. Cards
- Codeforces Round #364 (Div. 2)(A ~ D)
- Codeforces Round #364 (Div. 2) A
- jquery实现两种轮播效果
- CSU-ACM2016暑假集训比赛1
- 强大的grep命令
- 58.View the Exhibit and examine the parameters.
- 单例模式
- Codeforces Round #364 (Div. 2)【A,C】
- 本地简单json解析Demo
- php7 mongoDB 简单封装
- C语言中浮点数的运算
- 面向对象的几个基本关键字(二)
- c 语言头文件和源文件
- 几个重要的注意点
- 59.In your database, the current status of a PL/SQL procedure has become INVALID. Which action woul
- UITableView 到达顶部或底部的判断