题意: In Berland each high school student is characterized by academic performance — integer value between 1 and 5. In high school 0xFF there are two groups of pupils: the group A and the group B. Each group consists of exactly nstudents. An academic p…
一次交换,会让Group A里面的某个数字的数量-1,另一个数字的数量+1:对Group B恰好相反. 于是答案就是xigma(i=1~5,numA[i]-numB[i]>0)(numA[i]-numB[i])/2,如果这个值无法被2整除,则无解,或者如果这个值不等于xigma(i=1~5,numA[i]-numB[i]<0)(-numA[i]+numB[i])/2的话,也无解. 或者如果某个值在两组中出现的总次数无法被2整除,也无解. #include<cstdio> using…
Codeforces Round #402 (Div. 2) A. Pupils Redistribution 模拟大法好.两个数列分别含有n个数x(1<=x<=5) .现在要求交换一些数使得两个数列含有某个数字的个数相同,求最少交换次数. int v1[N],v2[N]; int main() { int n; while(~scanf("%d",&n)) { int x; memset(v1,0,sizeof(v1)); memset(v2,0,sizeof(v…
Codeforces Round #402 (Div. 2) A. 日常沙比提 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> using namespace std; inline int read(){ ,f=; ; c=getchar();} +c-'; c=getchar();} return x*f; }…
A. Pupils Redistribution time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In Berland each high school student is characterized by academic performance — integer value between 1 and 5. In hig…
A. Pupils Redistribution time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In Berland each high school student is characterized by academic performance — integer value between 1 and 5. In hig…
2017.2.26 CF D2 402 这次状态还算能忍吧……一路不紧不慢切了前ABC(不紧不慢已经是在作死了),卡在D,然后跑去看E和F——卧槽怎么还有F,早知道前面做快点了…… F看了看,不会,弃 E看了看,不会,弃 D看了看,不会……没法再弃了.想了好久发现可以二分答案(浪费30min) 过了D以后去看F,发现果然还是不会(浪费20min) 之后看E,思路跑偏浪费20min+ 此时时间还剩大约20min,终于想到了E可能是正解的做法,开始拼手速,各种调试,终于调过了样例,而时间只剩10s了…
暴搜 #include<cstdio> #include<algorithm> using namespace std; int n,K,Div=1,a[21],m,ans=100; bool vis[21]; void calc(int now) { int t=0; bool flag=0; for(int i=m;i>=1;--i) if(!vis[i]) { if((!flag) && a[i]==0) return; t=t*10+a[i]; fla…
Problem A: 题目大意: 给定两个数列\(a,b\),一次操作可以交换分别\(a,b\)数列中的任意一对数.求最少的交换次数使得任意一个数都在两个序列中出现相同的次数. (\(1 \leq a_i,b_i \leq 5 , 1 \leq n \leq 100\)) 题解: 直觉告诉我这么搞就行了 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; typed…
Description In Berland each high school student is characterized by academic performance — integer value between 1 and 5. In high school 0xFF there are two groups of pupils: the group A and the group B. Each group consists of exactly n students. An a…