NOIP2014

来自Shadow Wiki
跳转至: 导航搜索

NOIP2014指信息奥赛联赛(2014)。小约今年仍然是普及组xD,下面是关于复赛的相关资讯。

题目

http://tieba.baidu.com/p/3398500410/

程序

NOIP2014复赛普及组源程序 http://www.cfcs.com.cn/archives/452.html

#1 Count (O(n^3))
/*
 * NOIP2014 Junior #1 Count (O(n^3))
 * By Joshua
 */
#include<cstdio>
 
using namespace std;
 
int main(void){
	int nNum, num[100], k, j, i, count = 0;
	freopen("count.in", "r", stdin);
	freopen("count.out", "w", stdout);
	scanf("%d", &nNum);
	for(k = 0; k < nNum; k++){
		scanf("%d", &num[k]);
	}
	for(k = 0; k < nNum; k++){
		for(j = 0; j < nNum; j++){
			for(i = 0; i < nNum; i++){
				count += k != j && j != i && k != i && num[k] + num[j] == num[i];
			}
		}
	}
	printf("%d", count / 2);
	return 0;
}
#2 Ratio
/*
 * NOIP2014 Junior #2 Ratio
 * By Joshua
 */
#include<cstdio>
 
using namespace std;
 
int getN(int a, int b){
	return !(a % b) ? b : getN(b, a % b);
}
 
int main(void){
	int numA, numB, limit, k;
	freopen("ratio.in", "r", stdin);
	freopen("ratio.out", "w", stdout);
	scanf("%d %d %d", &numA, &numB, &limit);
	k = getN(numA, numB);
	numA /= k;
	numB /= k;
	while(numA > limit || numB > limit){
		if(getN(numA + 1, numB) != 1){
			numA++;
		}else if(getN(numA, numB - 1) != 1){
			numB--;
		}else{
			numA++;
		}
		k = getN(numA, numB);
		numA /= k;
		numB /= k;
	}
	printf("%d %d", numA, numB);
	return 0;
}
#3 Matrix
/*
 * NOIP2014 Junior #3 Matrix
 * By Joshua
 */
#include<cstdio>
#include<algorithm>
 
using namespace std;
 
int main(void){
	int n, i, j, k, f, p = 4, s = 0;
	scanf("%d %d %d", &n, &i, &j);
	f = (n + 1) / 2;
	if(i == f && j == f){
		printf("%d", n * n);
	}else{
		for(k = 1; k <= f; k++){
			if(min(i, j) == k || max(i, j) == n - k + 1){
				f = k;
				break;
			}
		}
		if(i == f && j < n - f + 1) p = 1;
		if(j == n - f + 1 && i < n - f + 1) p = 2;
		if(i == n - f + 1 && j > f) p = 3;
		for(k = 2; k <= f; k++)
			s += 4 * (n - k + 1);
		s += (p - 1) * (n - 2 * f + 1);
		if(p == 1) s += j - f + 1;
		if(p == 2) s += i - f + 1;
		if(p == 3) s += n - j - f + 2;
		if(p == 4) s += n - i - f + 2;
		printf("%d", s);
	}
	return 0;
}

数据

等待添加。

关于以上程序

  • 第一题WA;因为重复计算了“一个数”。
  • 第二题WA;算法出错。
  • 第三题Juding……
  • 第四题WA;拿到5分的概率几乎等于我输出的那个0。
  • 反正今年死的惨。