Submission #22272

#TimeUsernameProblemLanguageResultExecution timeMemory
22272↓우리보다잘하는팀 (#40)Window Xor (KRIII5_WX)C++98
7 / 7
423 ms1896 KiB
#include<cstdio>
int n, m;
long long int q;
int x[100100];
int y[100100];
long long int gcd(long long int a, long long int b) {
	if (a == 0)return b;
	return gcd(b%a, a);
}
void shift(long long int d) {
	int s = gcd(d, n);
	int p = n / s;
	int sm = m % (2 * p);
	for (int i = 0; i < s; i++) {
		int res = 0;
		int front = i;
		int back = i;
		for (int j = 0; j < sm; j++) {
			res ^= x[front];
			front = (front + d) % n;
		}
		for (int j = 0; j < p; j++) {
			y[back] = res;
			res ^= x[front];
			front = (front + d) % n;
			res ^= x[back];
			back = (back + d) % n;
		}
	}
	for (int i = 0; i < n; i++) {
		x[i] = y[i];
	}
}
int main() {
	scanf("%d%d%lld", &n, &m, &q);
	for (int i = 0; i < n; i++) {
		scanf("%d", &x[i]);
	}
	for (int i = 0; i < 61; i++) {
		if (q&(1LL << i)) {
			shift(1LL << i);
		}
	}
	for (int i = 0; i < n; i++) {
		printf("%d ", x[i]);
	}
	return 0;
}

Compilation message (stderr)

WX.cpp: In function 'int main()':
WX.cpp:35:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%lld", &n, &m, &q);
                               ^
WX.cpp:37:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x[i]);
                     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...