#include <stdio.h>
#include <stdbool.h>
#include <math.h>
#include <stdlib.h>
bool Rose(int Q, int A) {
int *t = malloc(3 * sizeof(int));;
t[0] = ((int)pow(3 + Q - A, 1) % 3 + (int)pow(3 - Q + A, 1)) % 3;
t[1] = ((int)pow(3 + Q - A, 2) % 3 + (int)pow(3 - Q + A, 2)) % 3;
t[2] = ((int)pow(3 + Q - A, 3) % 3 + (int)pow(3 - Q + A, 3)) % 3;
int result = (t[0] + t[1] + t[2]);
free(t);
return result != A;
}
int Go(int Q) {
int J = 0; // ← 必須(未初期化のまま使うと未定義動作)
while (Rose(Q, J)) {
J++;
}
return J;
}
int main() {
int G=0;
printf("%d!", Go(2));
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: