QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#759862#9628. 骰子xyz#AC ✓0ms3708kbC++23738b2024-11-18 12:48:222024-11-18 12:48:22

Judging History

你现在查看的是最新测评结果

  • [2024-11-18 12:48:22]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3708kb
  • [2024-11-18 12:48:22]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

int get(int x, int y) {
	x = (x - 1) % 6;
	y = (y - 1) % 6;
	int p[7] = {0, 1, 2, 3, 4, 5, 6};
	for (int i = 1; i <= x; i++) {
		int a = p[1], b = p[3], c = p[6], d = p[4];
		p[1] = d, p[3] = a, p[6] = b, p[4] = c;
	}
	for (int j = 1; j <= y; j++) {
		int a = p[1], b = p[2], c = p[6], d = p[5];
		p[1] = d, p[2] = a, p[6] = b, p[5] = c;
	}
	return p[6];
}

int main() {
	int n, m;
	cin >> n >> m;
	int sum = 0;
	if (n < 2 || m < 2) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				//cout << "get(" << i << "," << j << ")=" << get(i, j) << endl;
				sum += get(i, j);
			}
		}
	} else {
		sum = 6 * n * m;
	}
	cout << sum << endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3708kb

input:

2 2

output:

24

result:

ok single line: '24'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

1000 1000

output:

6000000

result:

ok single line: '6000000'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

987 654

output:

3872988

result:

ok single line: '3872988'