You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
#include <iostream>
|
|
|
|
|
using namespace std;
|
|
|
|
|
typedef long long LL;
|
|
|
|
|
|
|
|
|
|
//最大公约数,辗转相除法
|
|
|
|
|
int gcd(int a, int b) {
|
|
|
|
|
return b ? gcd(b, a % b) : a;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//快读
|
|
|
|
|
int read() {
|
|
|
|
|
int x = 0, f = 1;
|
|
|
|
|
char ch = getchar();
|
|
|
|
|
while (ch < '0' || ch > '9') {
|
|
|
|
|
if (ch == '-') f = -1;
|
|
|
|
|
ch = getchar();
|
|
|
|
|
}
|
|
|
|
|
while (ch >= '0' && ch <= '9') {
|
|
|
|
|
x = (x << 3) + (x << 1) + (ch ^ 48);
|
|
|
|
|
ch = getchar();
|
|
|
|
|
}
|
|
|
|
|
return x * f;
|
|
|
|
|
}
|
|
|
|
|
const int N = 2010;
|
|
|
|
|
int n, m, a[N][N];
|
|
|
|
|
|
|
|
|
|
void init() {
|
|
|
|
|
for (int i = 1; i <= 1000; i++) //互质,赋值为1
|
|
|
|
|
for (int j = 1; j <= 1000; j++)
|
|
|
|
|
if (gcd(i, j) == 1) a[i][j] = 1;
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i <= 1000; i++) //二维前缀和
|
|
|
|
|
for (int j = 1; j <= 1000; j++)
|
|
|
|
|
a[i][j] += a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
init();
|
|
|
|
|
int m = read();
|
|
|
|
|
for (int i = 1; i <= m; i++) {
|
|
|
|
|
n = read();
|
|
|
|
|
printf("%d %d %d\n", i, n, a[n][n] + 2); //加上(1,0),(0,1)两个点
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|