貪食蛇2
user_3763047219
c_cpp
2 years ago
703 B
7
Indexable
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <stdio.h>//header standard Input/ouput #include<stdbool.h> #include<assert.h> #include<math.h> int main() { int num,n,n2; int x, y; scanf("%d", &num); n = sqrt(num); n2 = num - n * n; if (n2 == 0) { if (n % 2 == 0) { x = n; y = 1; } else { x = 1; y = n; } } else if ((n+1) % 2 == 0) { if (n2 >= n + 1) { x = n + 1; y = n + 1 - (n2 - (n + 1)); } else { y= n + 1; x = n2 ; } } else if ((n+1) % 2 != 0) { if (n2 >= n + 1) { x = n + 1 - (n2 - (n + 1)); y = n + 1; } else { x = n + 1; y = n2; } } printf("%d %d", x, y); }
Editor is loading...