⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2363.cpp

📁 这是哈尔滨工业大学acmOJ的源代码
💻 CPP
字号:
/* This Code is Submitted by wywcgs for Problem 2363 on 2006-09-22 at 17:08:19 */
#include <cstdio>
#include <cctype>
#include <algorithm>
using namespace std;

const int N = 10240;

int dn[10];

void num(int);

int main()
{
	int T, e[N];
	char line[1024];
	
	scanf("%d\n", &T);
	for(int t = 0; t < T; t++) {
		memset(e, 0, sizeof(e)); memset(dn, 0, sizeof(dn));
		puts(gets(line));
		int n; scanf("%d\n", &n);
		for(int i = 0; i < n; i++) {
			gets(line);
			if(isdigit(line[0])) {
				int a; sscanf(line, "%d", &a);
				if(e[a] != -1) e[a] = 1;
			} else {
				char c; int a, b, d;
				sscanf(line, "%c %d %d %d", &c, &a, &b, &d);
				for(int j = a; j <= b; j += d)
					if(c == '-') e[j] = -1;
					else if(e[j] != -1) e[j] = 1;
			}
		}
		int total = 0, tn = 0;
		for(int i = 0; i < N; i++)
			if(e[i] == 1) { num(i); tn++; }
		for(int i = 0; i < 10; i++)
			if(dn[i] != 0) total += dn[i];
		printf("%d %s\n", tn, tn == 1 ? "address" : "addresses");
		for(int i = 0; i < 10; i++) printf("Make %d digit %d\n", dn[i], i);
		printf("In total %d %s\n", total, total == 1 ? "digit" : "digits");
	}
	
	return 0;
}

void num(int k)
{
	do {
		dn[k%10]++; k /= 10;
	} while(k != 0);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -