text
stringlengths 49
983k
|
|---|
#include <bits/stdc++.h>
using namespace std;
const int MAX = 10;
int k;
int tabla[MAX][MAX];
char digitos[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
string cambiarBase(int aux) {
string resultado = "";
while (aux >= k) {
resultado = digitos[aux % k] + resultado;
aux = aux / k;
}
resultado = digitos[aux] + resultado;
return resultado;
}
void calcular() {
for (int i = 0; i < k - 1; i++) {
for (int j = 0; j < k - 1; j++) {
if (i == 0) {
tabla[i][j] = j + 1;
} else {
tabla[i][j] = tabla[i - 1][j] + j + 1;
}
}
}
}
int main() {
cin >> k;
calcular();
for (int i = 0; i < k - 1; i++) {
for (int j = 0; j < k - 1; j++) {
cout << cambiarBase(tabla[i][j]) << " ";
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
int main() {
int k;
scanf("%d", &k);
int q = 0;
for (int i = 1; i < k; i++) {
for (int j = 1; j < k; j++) {
if ((q % 10) + i >= k)
q += 10 + i - k;
else
q += i;
printf("%d ", q);
}
printf("\n");
q = 0;
}
return 0;
}
|
#include <bits/stdc++.h>
int zhuan(int m, int k) {
int ans[100], an = 0, sum, i;
while (m) {
ans[an++] = m % k;
m = m / k;
}
sum = 0;
for (i = an - 1; i >= 0; i--) sum = sum * 10 + ans[i];
return sum;
}
int main() {
int k;
scanf("%d", &k);
for (int i = 1; i <= k - 1; i++) {
for (int j = 1; j <= k - 1; j++) {
if (j != k - 1)
printf("%d ", zhuan(i * j, k));
else
printf("%d\n", zhuan(i * j, k));
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
for (int i = 1; i < n; i++, cout << endl)
for (int j = 1; j < n; j++) {
if (i * j >= n) cout << (i * j) / n;
cout << (i * j) % n << ' ';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int mabna(int a, int x) {
string s;
while (a >= x) {
s += (char)(a % x) + '0';
a /= x;
}
if (a != 0) {
s += (char)a + '0';
}
int numb;
reverse(s.begin(), s.end());
istringstream(s) >> numb;
return numb;
}
int main() {
int n;
cin >> n;
int a[10][10];
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
a[i][j] = (i + 1) * (j + 1);
}
}
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - 1; j++) {
cout << mabna(a[i][j], n) << " ";
}
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, i, j;
cin >> n;
for (i = 1; i < n; i++) {
for (j = 1; j < n; j++) {
if (j == 1)
cout << i;
else if (i * j / n == 0)
cout << " " << i * j % n;
else
cout << " " << i * j / n << i * j % n;
}
cout << endl;
}
}
|
#include <bits/stdc++.h>
int k;
void print(int n) {
int a = n / k;
int b = n % k;
if (a) printf("%d", a);
printf("%d", b);
}
int main() {
scanf("%d", &k);
for (int a = 1; a < k; a++) {
for (int b = 1; b < k; b++) {
print(a * b);
printf(" ");
}
printf("\n");
}
printf("\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long da[15], a[15][15], n;
int main() {
scanf("%lld", &n);
for (int i = 1; i < n; i++)
for (int j = 1; j < n; j++) {
a[i][j] = i * j;
memset(da, 0, sizeof da);
long long now = a[i][j], ans = 0, num = 0;
while (now >= 1) {
da[++num] = now % n;
now = now / n;
}
for (int j = i; j >= 1; j--) ans = ans * 10 + da[j];
a[i][j] = ans;
}
for (int i = 1; i < n; i++) {
for (int j = 1; j < n; j++) printf("%lld ", a[i][j]);
printf("\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
string to(int n, int r) {
string k = "";
while (n != 0) {
k = (char)((n % r) + 48) + k;
n /= r;
}
return k;
}
int main() {
int k;
cin >> k;
for (int i = 1; i <= k - 1; i++) {
for (int j = 1; j <= k - 1; j++) cout << to(i * j, k) << " ";
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int turn(int src, int n) { return src % n + src / n * 10; }
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i < n; i++) {
for (int j = 1; j < n; j++) {
printf(" %2d", turn(i * j, n));
}
printf("\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:16777216")
int k;
int main() {
cin >> k;
for (int i = 1; i < k; ++i) {
for (int j = 1; j < k; ++j) {
if (j > 1) cout << " ";
string s = "";
int first = i * j;
while (first) {
s = (char)(first % k + '0') + s;
first /= k;
}
cout << s;
}
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int k, a[105][105];
void bang() {
for (int i = (1); i <= (k - 1); i++)
for (int j = (1); j <= (k - 1); j++) a[i][j] = i * j;
}
int chuyen(int i, int j) { return (i * j / k) * 10 + (i * j % k); }
void doi() {
if (k == 10) return;
for (int i = (1); i <= (k - 1); i++)
for (int j = (1); j <= (k - 1); j++)
if (a[i][j] >= k) a[i][j] = chuyen(i, j);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie();
cout.tie();
cin >> k;
bang();
doi();
for (int i = (1); i <= (k - 1); i++) {
for (int j = (1); j <= (k - 1); j++) cout << a[i][j] << " ";
cout << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
int conv(int num, int base);
int main() {
int k, i, j, num;
while (scanf("%d", &k) != EOF) {
for (i = 1; i < k; i++) {
for (j = 1; j < k; j++) {
num = conv(i * j, k);
if (j == 1)
printf("%d", num);
else
printf(" %d", num);
}
printf("\n");
}
}
return 0;
}
int conv(int num, int base) {
int temp = 0, ans = 0, i;
for (i = 0;; i++) {
temp = num % base;
num = num / base;
ans = (temp * pow(10, i)) + ans;
if (num == 0) break;
}
return ans;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int k;
cin >> k;
for (int i = 0; i < k - 1; ++i) {
for (int j = 0; j < k - 1; ++j) {
int cur = (i + 1) * (j + 1);
string ts = "";
while (cur) ts = (char)(cur % k + '0') + ts, cur /= k;
cout << ts << " ";
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int k;
int main() {
scanf("%d", &k);
for (int i = 1; i < k; ++i) {
for (int j = 1; j < k; ++j) {
int a = i * j;
if (a / k > 0) printf("%d", a / k);
printf("%d", a % k);
printf(" ");
}
printf("\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
string ko(int k, int y) {
string g = "";
while (y > 0) {
g = char(y % k + 48) + g;
y = y / k;
}
return g;
}
int main() {
int k;
cin >> k;
int i, j;
for (i = 1; i <= k - 1; i++) {
for (j = 1; j <= k - 1; j++) {
cout << ko(k, i * j) << " ";
}
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int n, out[11][11] = {
{0},
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
{0, 2, 4, 6, 8, 10, 12, 14, 16, 18},
{0, 3, 6, 9, 12, 15, 18, 21, 24, 27},
{0, 4, 8, 12, 16, 20, 24, 28, 32, 36},
{0, 5, 10, 15, 20, 25, 30, 35, 40, 45},
{0, 6, 12, 18, 24, 30, 36, 42, 48, 54},
{0, 7, 14, 21, 28, 35, 42, 49, 56, 63},
{0, 8, 16, 24, 32, 40, 48, 56, 64, 72},
{0, 9, 18, 27, 36, 45, 54, 63, 72, 81},
};
void Bs(int x) {
if (x < n)
cout << x << " ";
else {
cout << x / n;
Bs(x % n);
}
return;
}
int main() {
cin >> n;
for (int i = 1; i < n; i++) {
for (int j = 1; j < n; j++) Bs(out[i][j]);
cout << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int num[100];
int main() {
int k;
while (~scanf("%d", &k)) {
for (int i = 1; i < k; i++) {
for (int j = 1; j < k; j++) {
int x = i * j;
int cnt = 0;
while (x) {
num[++cnt] = x % k;
x /= k;
}
for (int i = cnt; i >= 1; i--) {
printf("%d", num[i]);
}
if (j == k - 1)
putchar('\n');
else
putchar(' ');
}
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-8;
const long long INF = 1e18 + 7;
const int inf = 2139062143;
int n;
string work(int x) {
string res;
res.clear();
while (x) {
res += char(x % n + 48);
x /= n;
}
reverse(res.begin(), res.end());
return res;
}
int main() {
scanf("%d", &n);
int i, j;
for (i = 1; i < n; i++) {
for (j = 1; j < n; j++) {
printf("%s ", work(i * j).c_str());
}
putchar(10);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long int base(long long int n, long long int k) {
string res = "";
long long int temp = 0, i;
while (n >= k) {
res += to_string(n % k);
n /= k;
}
res += to_string(n);
reverse(res.begin(), res.end());
for (i = 0; i < res.length(); i++) {
temp = temp * 10 + (res[i] - '0');
}
return temp;
}
int main() {
long long int n, i, j, flag = 0;
cin >> n;
flag = 9;
for (i = 1; i <= n - 1; i++) {
for (j = 1; j <= n - 1; j++) {
cout << base(i * j, n) << " ";
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
const long long MOD = 1000000007;
const long long MAX = 11;
long long a[MAX][MAX];
int ts(int n, int m) {
int i = 1;
int r[3];
while (n) {
r[i++] = n % m;
n /= m;
}
i--;
int re = 0;
while (i) {
re *= 10;
re += r[i];
i--;
}
return re;
}
int main() {
int i, j, k;
int T, n, m;
for (i = 0; i < MAX; i++) {
for (j = 0; j < MAX; j++) a[i][j] = 0;
}
scanf("%d", &n);
for (i = 1; i < n; i++) {
for (j = 1; j < n; j++) {
printf("%d", ts(i * j, n));
if (j != n - 1) {
printf(" ");
} else {
printf("\n");
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int k;
int main() {
cin >> k;
for (int i = 1; i < k; i++) {
cout << i;
for (int j = 2; j < k; j++) {
if (i * j < k)
cout << " " << i * j % k;
else
cout << setw(2) << i * j / k << i * j % k;
}
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
int rt(int s) {
int d[11];
int len = 0;
while (s) {
d[len++] = s % n;
s /= n;
}
int ans = 0;
int t = 1;
for (int i = 0; i < len; i++) {
ans += d[i] * t;
t *= 10;
}
return ans;
}
int main() {
int i, j;
cin >> n;
for (i = 1; i < n; i++) {
for (j = 1; j < n; j++) printf("%d ", rt(i * j));
printf("\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int i, j, n;
cin >> n;
for (i = 1; i < n; i++) {
for (j = 1; j < n; j++) cout << (i * j / n) * 10 + ((i * j) % n) << " ";
cout << "\n";
}
}
|
#include <bits/stdc++.h>
int b;
void turn(int a) {
int p[100];
int m = 0;
while (a != 0) {
p[m++] = a % b;
a = a / b;
}
int i;
for (i = m - 1; i >= 0; i--) printf("%d", p[i]);
printf(" ");
}
int main() {
int i, j;
scanf("%d", &b);
for (i = 1; i < b; i++) {
for (j = 1; j < b; j++) {
turn(i * j);
}
printf("\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int k = 0;
int last;
cin >> k;
int *pos = new int[k * k];
pos[0] = 0;
for (int i = 1; i < k * k; i++) {
last = pos[i - 1] + 1;
if (((last) % 10) >= k)
pos[i] = ((last) / 10 + 1) * 10 + ((last) % 10 - k);
else
pos[i] = last;
}
for (int i = 1; i < k; i++) {
{
for (int j = 1; j < k; j++) cout << pos[i * j] << " ";
}
cout << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void input() {}
void base(long long int a, long long int n) {
if (a / n > 0) cout << a / n;
cout << a % n << " ";
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
input();
long long int n;
cin >> n;
long long int arr[n][n];
for (long long int i = 1; i < n; i++) {
for (long long int j = 1; j < n; j++) {
base(i * j, n);
}
cout << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
char b;
string hagia(int n, int l, string a) {
while (n > 0) {
b = n % l + '0';
a = b + a;
n /= l;
}
return a;
}
int main() {
int l;
string a = "";
cin >> l;
for (int i = 1; i < l; i++) {
for (int j = 0; j < l; j++) {
int num = i * j;
cout << hagia(i * j, l, a) << " ";
a = "";
}
cout << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a = 0;
cin >> n;
for (int i = 1; i < n; i++) {
for (int j = 1; j < n; j++) {
a = (i * j) / n;
a *= 10;
a += (i * j) % n;
cout << a << " ";
}
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int k;
string get(int x) {
string s;
while (x) {
s += char(x % k + '0');
x /= k;
}
reverse(s.begin(), s.end());
return s;
}
int main() {
cin >> k;
for (int i = 1; i < k; i++) {
for (int j = 1; j < k; j++) {
cout << get(i * j) << " ";
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
string get(int n, int radix) {
string s = "";
if (n == 0) {
s += '0';
}
while (n > 0) {
int dig = n % radix;
s += dig + '0';
n /= radix;
}
reverse(s.begin(), s.end());
return s;
}
int main() {
int k;
scanf("%d", &k);
for (int i = 1; i < k; ++i) {
for (int j = 1; j < k; ++j) {
printf("%s%c", get(i * j, k).c_str(), (j == k - 1) ? '\n' : ' ');
}
}
return (0);
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
void transformar(int numero) {
if (numero >= n) transformar(numero / n);
printf("%d", numero % n);
}
int main() {
scanf("%d", &n);
printf("1");
for (int i = 2; i < n; i++) printf(" %d", i);
printf("\n");
for (int i = 2; i < n; i++) {
printf("%d", i);
for (int j = 2; j < n; j++) {
printf(" ");
transformar(i * j);
}
if (i + 1 < n) printf("\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int a[10][10] = {};
void output(int base, int num) {
int i = 1, j;
while (i <= num) i *= base;
i /= base;
while (i != 0) {
j = num / i;
cout << j;
num %= i;
i /= base;
}
cout << ' ';
return;
}
int main() {
int k;
cin >> k;
for (int i = 1; i < k; i++)
for (int j = 1; j < k; j++) a[i][j] = i * j;
for (int i = 1; i < k; i++) {
for (int j = 1; j < k; j++) output(k, a[i][j]);
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)3e5 + 10;
const int inf = (int)1e9 + 5;
const long long llinf = (long long)1e18 + 5;
int a[1060][1060];
string b[1009][1000];
int q, w, e, k, s, d, n, m, t;
string can(int x) {
string r = "";
while (x > 0) {
r = char(x % k + '0') + r;
x /= k;
}
return r;
}
int main() {
cin >> k;
for (int i = 1; i < k; i++)
for (int j = 1; j < k; j++) a[i][j] = i * j;
for (int i = 1; i < k; i++)
for (int j = 1; j < k; j++) {
q = a[i][j];
b[i][j] = can(q);
}
for (int i = 1; i < k; i++) {
for (int j = 1; j < k; j++) {
cout << b[i][j] << ' ';
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int k, f = 1;
cin >> k;
for (int t = 1; t < k; t++) {
cout << t << " ";
}
cout << endl;
for (int t = 2; t < k; t++) {
f++;
cout << f << " ";
for (int i = 2; i < k; i++) {
int n = t * i;
bool b = 0;
string s = "";
while (b == 0) {
if (n <= 1) {
b = 1;
}
if (n % k == 0) {
s = '0' + s;
}
if (n % k == 1) {
s = '1' + s;
}
if (n % k == 2) {
s = '2' + s;
}
if (n % k == 3) {
s = '3' + s;
}
if (n % k == 4) {
s = '4' + s;
}
if (n % k == 5) {
s = '5' + s;
}
if (n % k == 6) {
s = '6' + s;
}
if (n % k == 7) {
s = '7' + s;
}
if (n % k == 8) {
s = '8' + s;
}
if (n % k == 9) {
s = '9' + s;
}
n /= k;
}
if (s[0] == '0') {
s.erase(0, 1);
}
cout << s << " ";
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void go(int x, int k) {
if (x == 0)
cout << 0;
else {
int nxt = x / k;
if (nxt != 0) {
go(nxt, k);
}
cout << x % k;
}
}
int main() {
ios_base::sync_with_stdio(0);
int k;
cin >> k;
for (int i = 1; i < k; i++) {
for (int j = 1; j < k; j++) {
go(i * j, k);
cout << " ";
}
cout << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int k;
void base(int x) {
int s = 0, i = 1;
while (x != 0) {
s = s + i * (x % k);
x = x / k;
i *= 10;
}
cout << s;
}
int main() {
cin >> k;
for (int i = 1; i <= k - 1; ++i) {
for (int j = 1; j <= k - 1; ++j) {
base(i * j);
cout << " ";
}
cout << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int n, a[101];
void print(int m) {
int cnt = 0;
while (m) a[cnt++] = m % n, m /= n;
reverse(a, a + cnt);
for (int i = 0; i < cnt; i++) printf("%d", a[i]);
printf(" ");
}
int main() {
scanf("%d", &n);
for (int i = 1; i < n; i++) {
for (int j = 1; j < n; j++) print(i * j);
puts("");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
string table[12][12];
int k;
int main() {
scanf("%d", &k);
for (int i = 1; i < k; i++)
for (int j = 1; j < k; j++) {
int val = i * j;
string s;
while (val) {
s += (val % k) + '0';
val /= k;
}
reverse(s.begin(), s.end());
table[i][j] = s;
}
for (int i = 1; i < k; i++) {
for (int j = 1; j < k; j++) {
cout << table[i][j];
if (j == k - 1)
printf("\n");
else
printf(" ");
}
}
}
|
#include <bits/stdc++.h>
int convert(int input, int radix) {
int output = 0;
int pow = 1;
output += input % radix;
input = (input - input % radix) / radix;
output += 10 * input;
return output;
}
void print(int n) {
if (n < 10)
printf(" %d", n);
else
printf("%d", n);
}
int main() {
int radix;
scanf("%d", &radix);
for (int i = 1; i < radix; i++) {
for (int j = 1; j < radix; j++) {
if (j == 1)
printf("%d ", convert(i * j, radix));
else {
print(convert(i * j, radix));
if (j < radix - 1) printf(" ");
}
}
printf("\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int k;
string convert(int x) {
string s = "";
while (x) s += to_string(x % k), x /= k;
reverse(s.begin(), s.end());
return s;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> k;
for (int i = 1; i < k; i++)
for (int j = 1; j < k; j++) cout << convert(i * j) << " \n"[j == k - 1];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
string trans(int x) {
string s = "";
while (x) {
s += char(x % n + '0');
x /= n;
}
reverse(s.begin(), s.end());
return s;
}
int main() {
cin >> n;
for (int i = 1; i < n; i++) {
for (int j = 1; j < n; j++) {
cout << trans(i * j) << " ";
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int k;
cin >> k;
for (int i = 1; i < k; i++) {
for (int j = 1; j < k; j++) {
if ((i * j) / k != 0) cout << i * j / k;
cout << (i * j) % k << " ";
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int base(int a, int x) {
int cnt = 0, zz = 1;
while (a) {
cnt += (a % x) * zz;
zz *= 10;
a /= x;
}
return cnt;
}
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n - 1; i++) {
for (int j = 1; j <= n - 1; j++) printf("%d ", base(i * j, n));
printf("\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long int m, n, c, d, j, k, l, r, x, t, y, u, a, b, z, i, e, f;
vector<long long int> v;
int main() {
cin >> n;
for (i = 1; i < n; i++) {
for (j = 1; j < n; j++) {
cout << i * j / n * 10 + ((i * j) % n) << " ";
}
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
void bas(int number, int base) {
int final[99];
double remainder;
int i = 0;
while (number != 0) {
remainder = (number % base);
final[i] = remainder;
i++;
number = number / base;
}
for (i--; i > -1; i--) {
if (final[i] < 10)
cout << final[i];
else
cout << char(final[i] - 10 + 'a');
}
}
int main() {
int base;
cin >> base;
int a[base][base], i, j;
for (i = 1; i < base; i++) {
for (j = 1; j < base; j++) {
bas(i * j, base);
if (j < base - 1) cout << " ";
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin >> n;
for (int i = 1; i < n; i++) {
cout << i;
for (int j = 2; j < n; j++) {
int t = i * j;
string s;
while (t) {
s += char('0' + (t % n));
t /= n;
}
reverse(s.begin(), s.end());
cout << " " << s;
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
scanf("%d", &n);
for (int i = 1; i < n; i++) {
for (int j = 1; j < n; j++) {
int x = i * j;
stack<int> st;
while (x) {
st.push(x % n);
x /= n;
}
while (!st.empty()) {
printf("%d", st.top());
st.pop();
}
printf(" ");
}
printf("\n");
}
}
|
#include <bits/stdc++.h>
using namespace std;
int IsPrime(int k) {
for (int u = 2; u * u <= k; u++)
if (k % u == 0) return false;
return (k != 1);
}
int printnum(int num, int base) {
int curr = 0, ans[10];
while (num != 0) {
ans[curr++] = num % base;
num /= base;
}
for (int x = curr - 1; x >= 0; x--) cout << ans[x];
cout << " ";
return 0;
}
int i, n, ans[1000000], a[1000000];
int x, y, z, x2, y2, z2, dx, dy, dz;
int main() {
cin >> n;
for (i = 1; i < n; i++) {
for (int j = 1; j < n; j++) printnum(i * j, n);
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long ans, x;
long long fac(long long x) {
if (x == 4)
return 322;
else if (x == 6)
return 53;
else if (x == 8)
return 7222;
else if (x == 9)
return 7332;
else
return x;
}
int main() {
vector<int> v;
vector<int> v2;
cin >> x;
for (int i = 0; i < x; i++) {
v.push_back(i);
}
int ct = x;
for (int i = 1; ct < 100; i++, ct++) {
int q = v[i] * 10;
for (int j = 0; j < x; j++) v.push_back(q + j);
}
for (int i = 1; i < x; i++) {
for (int j = 1; j < x; j++) {
int a = i * j, b = 0;
cout << v[i * j];
cout << " ";
}
cout << "\n";
}
cout << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int k, a[100][100], i, j, s[1000], z, m, n, h;
while (cin >> k) {
for (i = 1; i < k; i++) {
for (j = 1; j < k; j++) {
a[i][j] = i * j;
}
}
for (i = 1; i < k; i++) {
for (j = 1; j < k; j++) {
z = a[i][j];
m = 0;
if (j != 1) cout << " ";
while (z) {
n = z % k;
s[m++] = n;
z = z / k;
}
if (z != 0) s[m++] = z;
for (h = m - 1; h >= 0; h--) cout << s[h];
memset(s, 0, sizeof(h));
}
cout << endl;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void print(int x, int base) {
if (x == 0) return;
print(x / base, base);
printf("%d", x % base);
}
int main() {
int n;
scanf("%d", &n);
n--;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
print(i * j, n + 1);
printf(" ");
}
printf("\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 20;
int k;
int a[N][N];
void out(int x) {
int dig[10];
int tot = 0;
while (x) {
dig[tot++] = x % k;
x /= k;
}
for (int i = tot - 1; i >= 0; --i) {
printf("%d", dig[i]);
}
}
int main() {
scanf("%d", &k);
for (int i = 1; i < k; ++i) {
for (int j = 1; j < k; ++j) {
a[i][j] = i * j;
}
}
for (int i = 1; i < k; ++i) {
for (int j = 1; j < k; ++j) {
out(a[i][j]);
putchar((j == k - 1) ? '\n' : ' ');
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int radix(int n, int k) {
int m = n, sum[100], b, a, q;
q = 0;
a = 1;
memset(sum, 0, sizeof sum);
b = 0;
while (m >= k) {
sum[b] = m % k;
m /= k;
b++;
}
sum[b] = m;
for (int i = 0; i <= b; i++) {
q += a * sum[i];
a *= 10;
}
return q;
}
int main() {
int mat[11][11];
int k;
for (int i = 0; i < 9; i++) mat[0][i] = i + 1;
for (int i = 1; i < 9; i++)
for (int j = 0; j < 9; j++) mat[i][j] = mat[0][j] * (i + 1);
while (cin >> k) {
if (k < 10) {
for (int i = 0; i < k - 1; i++) {
for (int j = 0; j < k - 1; j++) {
if (j == 0) {
if (mat[i][j] < k)
cout << mat[i][j];
else
cout << radix(mat[i][j], k);
} else {
if (mat[i][j] < k)
printf("%2d", mat[i][j]);
else
printf("%2d", radix(mat[i][j], k));
}
cout << " ";
}
cout << endl;
}
} else {
for (int i = 0; i < k - 1; i++) {
for (int j = 0; j < k - 1; j++) {
if (j == 0)
cout << mat[i][j];
else
printf("%2d", mat[i][j]);
cout << " ";
}
cout << endl;
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using namespace chrono;
void _print(long long t) { cerr << t; }
void _print(int t) { cerr << t; }
void _print(string t) { cerr << t; }
void _print(char t) { cerr << t; }
void _print(long double t) { cerr << t; }
void _print(double t) { cerr << t; }
void _print(unsigned long long t) { cerr << t; }
template <class T, class V>
void _print(pair<T, V> p);
template <class T>
void _print(vector<T> v);
template <class T>
void _print(set<T> v);
template <class T, class V>
void _print(map<T, V> v);
template <class T>
void _print(multiset<T> v);
template <class T, class V>
void _print(pair<T, V> p) {
cerr << "{";
_print(p.first);
cerr << ",";
_print(p.second);
cerr << "}";
}
template <class T>
void _print(vector<T> v) {
cerr << "[ ";
for (T i : v) {
_print(i);
cerr << " ";
}
cerr << "]";
}
template <class T>
void _print(set<T> v) {
cerr << "[ ";
for (T i : v) {
_print(i);
cerr << " ";
}
cerr << "]";
}
template <class T>
void _print(multiset<T> v) {
cerr << "[ ";
for (T i : v) {
_print(i);
cerr << " ";
}
cerr << "]";
}
template <class T, class V>
void _print(map<T, V> v) {
cerr << "[ ";
for (auto i : v) {
_print(i);
cerr << " ";
}
cerr << "]";
}
int begtime = clock();
const long long mod = 1e9 + 7;
const long long INF = 1e18;
const int N = 100001;
void solve() {
int k;
cin >> k;
for (int i = 1; i < k; i++) {
for (int j = 1; j < k; j++) {
long long x = i * j * 1LL / k * 10 + (i * j) % k;
cout << x << ' ';
}
cout << endl;
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
{ solve(); }
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void converter(int n, int b) {
if (n < b) {
cout << n;
return;
} else {
converter(n / b, b);
cout << n % b;
}
}
int main() {
int k;
cin >> k;
for (int i = 1; i < k; i++) {
for (int j = 1; j < k; j++) {
converter(i * j, k);
cout << ' ';
}
cout << endl;
}
}
|
#include <bits/stdc++.h>
int main() {
int x;
scanf("%d", &x);
for (long r = 1; r < x; r++) {
for (long c = 1; c < x; c++) {
long mul = r * c;
if (mul >= x) {
mul = 10 * (mul / x) + (mul % x);
}
printf("%ld ", mul);
}
puts("");
}
return 0;
}
|
#include <bits/stdc++.h>
int main() {
int k;
scanf("%d", &k);
for (long row = 1; row < k; row++) {
for (long col = 1; col < k; col++) {
long prod = row * col;
if (prod >= k) {
prod = 10 * (prod / k) + (prod % k);
}
printf("%ld ", prod);
}
puts("");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int ans[1010];
int main() {
int k;
scanf("%d", &k);
for (int i = 1; i < k; i++) {
for (int j = 1; j < k; j++) {
int x = i * j, num = 0;
while (x) {
ans[num++] = x % k;
x /= k;
}
for (int ii = num - 1; ii >= 0; ii--) printf("%d", ans[ii]);
printf(" ");
}
printf("\n");
}
return 0;
}
|
#include <bits/stdc++.h>
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
using namespace std;
long long gcd(long long a, long long b) {
while (b) b ^= a ^= b ^= a %= b;
return a;
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
long long bigmod(long long b, long long p, long long m) {
long long ans = 1;
b %= m;
if (!b) return 0;
while (p) {
if (p & 1) ans = (ans * b) % m;
p >>= 1;
b = (b * b) % m;
}
return ans;
}
void recur() {}
void solve() {
long long n;
cin >> n;
for (long long i = 1; i < n; i++) {
for (long long j = 1; j < n; j++) {
long long t = i * j;
string s = "";
while (t) {
s += char('0' + t % n);
t /= n;
}
reverse(s.begin(), s.end());
cout << s;
cout << ' ';
}
cout << endl;
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long t = 1;
while (t--) solve();
}
|
#include <bits/stdc++.h>
using namespace std;
vector<int> t;
vector<int> tosystem(int x, int sys) {
t.clear();
while (x) {
t.push_back(x % sys);
x /= sys;
}
return t;
}
void out(vector<int> x) {
reverse(x.begin(), x.end());
for (int i = 0; i < x.size(); i++) {
printf("%d", x[i]);
}
}
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n - 1; i++) {
for (int j = 1; j <= n - 1; j++) {
if (j != 1) printf(" ");
out(tosystem(i * j, n));
}
printf("\n");
}
}
|
#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int main() {
int n, sz;
cin >> n;
for (int a = 1; a < n; a++) {
while (a >= n) {
v.push_back(a % n);
a /= n;
}
v.push_back(a);
for (int i = 1; i < 4 - v.size(); i++) cout << " ";
for (int i = v.size() - 1; i >= 0; i--) {
if (v[i] < 10)
cout << v[i];
else
cout << char('A' + v[i] - 10);
}
sz = v.size() - 1;
for (int i = sz; i >= 0; i--) {
v.pop_back();
}
}
cout << endl;
int a;
for (int a1 = 2; a1 < n; a1++) {
for (int a2 = 1; a2 < n; a2++) {
a = a1 * a2;
while (a >= n) {
v.push_back(a % n);
a /= n;
}
v.push_back(a);
for (int i = 0; i < 3 - v.size(); i++) cout << " ";
for (int i = v.size() - 1; i >= 0; i--) {
if (v[i] < 10)
cout << v[i];
else
cout << char('A' + v[i] - 10);
}
sz = v.size() - 1;
for (int i = sz; i >= 0; i--) {
v.pop_back();
}
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
int ans[10][10];
int check(int a) { return a == 0 ? 0 : check(a / (n + 1)) * 10 + a % (n + 1); }
int main() {
cin >> n;
n--;
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++) {
ans[i][j] = check((i + 1) * (j + 1));
cout << ans[i][j];
cout << " ";
if (j == n - 1) puts("");
}
return 0;
}
|
#include <bits/stdc++.h>
int a[10], n, x, cur;
int main() {
scanf("%d", &n);
for (int i = 1; i < n; i++) {
for (int j = 1; j < n; j++) {
x = i * j;
cur = 0;
while (x) {
a[cur++] = x % n;
x /= n;
}
while (cur--) printf("%d", a[cur]);
printf(" ");
}
puts("");
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a = 0, n = 0;
scanf("%d", &n);
for (int i = 1; i < n; i++) {
printf("%d ", i);
for (int j = 2; j < n; j++) {
a = (i * j) / n;
a = a * 10;
a += (i * j) % n;
printf("%d ", a);
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
string f(int a) {
string ans = "";
while (a > 0) {
char x = (a % n) + '0';
ans += x;
a /= n;
}
reverse(ans.begin(), ans.end());
return ans;
}
int main() {
cin >> n;
for (int i = 1; i < n; i++) {
for (int j = 1; j < n; j++) cout << f(i * j) << " ";
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, i, j, t, p;
void cg(int x) {
t = 0;
p = 1;
while (x > 0) {
t = t + x % n * p;
x /= n;
p *= 10;
}
printf("%d ", t);
return;
}
int main() {
scanf("%d", &n);
for (i = 1; i < n; ++i) {
for (j = 1; j < n; ++j) cg(i * j);
printf("\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
void check(int x) {
int mps[100005], k = 0;
while (x != 0) {
mps[++k] = x % n;
x /= n;
}
for (int i = k; i >= 1; i--) {
cout << mps[i];
}
cout << " ";
}
int main() {
cin >> n;
for (int i = 1; i <= n - 1; i++) {
for (int j = 1; j <= n - 1; j++) {
check(i * j);
}
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int k;
int read() {
static int res;
static char op;
do op = getchar();
while (op > '9' || op < '0');
for (res = 0; op >= '0' && op <= '9'; op = getchar())
res = res * 10 + (op ^ 48);
return res;
}
int calc(int x) {
static int sta[11], top, res;
for (top = 0; x; x /= k) sta[++top] = x % k;
for (res = 0; top; --top) res = res * 10 + sta[top];
return res;
}
signed main(int argc, char **argv) {
k = read();
for (int i = 1; i < k; ++i) printf("%d ", i);
for (int i = 2, j; i < k; ++i) {
printf("\n%d", i);
for (j = 2; j < k; ++j) printf(" %d", calc(i * j));
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int a[1000], n;
int calc(int num) {
int cnt = 0;
while (num != 0) {
a[++cnt] = num % n;
num /= n;
}
int res = 0;
for (int k = cnt; k >= 1; k--) res = res * 10 + a[k];
return res;
}
int main() {
cin >> n;
for (int i = 1; i < n; i++) {
for (int j = 1; j < n; j++) {
cout << calc(i * j) << " ";
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
string base(int n, int b) {
string r;
for (; n; n /= b) r = char((n % b) + '0') + r;
return r;
}
int main() {
int k;
cin >> k;
for (int i = 1; i < k; i++, cout << endl)
for (int j = 1; j < k; j++) cout << base(i * j, k) << " ";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
string convert(int k, int mult) {
string str = "";
string str1;
int rem;
while (mult != 0) {
rem = mult % k;
str1 = to_string(rem);
str.append(str1);
mult /= k;
}
reverse(str.begin(), str.end());
return str;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int mult, k;
string z;
cin >> k;
for (int i = 0; i < (k - 1); i++) {
for (int j = 0; j < (k - 1); j++) {
mult = (i + 1) * (j + 1);
z = convert(k, mult);
cout << z << " ";
}
cout << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
string toBase(int n, int b) {
string ret = "";
char buf[200];
int q = 100, r;
while (q != 0) {
q = n / b;
r = n % b;
sprintf(buf, "%d", r);
ret = buf + ret;
n = q;
}
sprintf(buf, "%d", q);
if (q != 0)
return buf + ret;
else
return ret;
}
int main() {
int n;
scanf("%d", &n);
string mt[15][15];
string ret;
for (int r = 1; r <= (n - 1); ++r) {
for (int c = 1; c <= (n - 1); ++c) {
ret = toBase(r * c, n);
printf("%s", ret.c_str());
if (c != (n - 1)) printf(" ");
}
if (r != (n - 1)) printf("\n");
}
return 0;
}
|
#include <bits/stdc++.h>
int main() {
int n;
scanf("%d", &n);
if (n == 2) {
printf("1\n");
}
if (n == 3) {
printf("1 2\n");
printf("2 11\n");
}
if (n == 4) {
printf("1 2 3\n");
printf("2 10 12\n");
printf("3 12 21\n");
}
if (n == 5) {
printf("1 2 3 4\n");
printf("2 4 11 13\n");
printf("3 11 14 22\n");
printf("4 13 22 31\n");
}
if (n == 6) {
printf("1 2 3 4 5\n");
printf("2 4 10 12 14\n");
printf("3 10 13 20 23\n");
printf("4 12 20 24 32\n");
printf("5 14 23 32 41\n");
}
if (n == 7) {
printf("1 2 3 4 5 6\n");
printf("2 4 6 11 13 15\n");
printf("3 6 12 15 21 24\n");
printf("4 11 15 22 26 33\n");
printf("5 13 21 26 34 42\n");
printf("6 15 24 33 42 51\n");
}
if (n == 8) {
printf("1 2 3 4 5 6 7\n");
printf("2 4 6 10 12 14 16\n");
printf("3 6 11 14 17 22 25\n");
printf("4 10 14 20 24 30 34\n");
printf("5 12 17 24 31 36 43\n");
printf("6 14 22 30 36 44 52\n");
printf("7 16 25 34 43 52 61\n");
}
if (n == 9) {
printf("1 2 3 4 5 6 7 8\n");
printf("2 4 6 8 11 13 15 17\n");
printf("3 6 10 13 16 20 23 26\n");
printf("4 8 13 17 22 26 31 35\n");
printf("5 11 16 22 27 33 38 44\n");
printf("6 13 20 26 33 40 46 53\n");
printf("7 15 23 31 38 46 54 62\n");
printf("8 17 26 35 44 53 62 71\n");
}
if (n == 10) {
printf("1 2 3 4 5 6 7 8 9\n");
printf("2 4 6 8 10 12 14 16 18\n");
printf("3 6 9 12 15 18 21 24 27\n");
printf("4 8 12 16 20 24 28 32 36\n");
printf("5 10 15 20 25 30 35 40 45\n");
printf("6 12 18 24 30 36 42 48 54\n");
printf("7 14 21 28 35 42 49 56 63\n");
printf("8 16 24 32 40 48 56 64 72\n");
printf("9 18 27 36 45 54 63 72 81\n");
}
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
return os << "(" << p.first << " " << p.second << ")";
};
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
os << "VECTOR: ";
for (auto ele : vec) os << ele << " ";
return os;
};
const int MAXN = 1e5;
const int mod = 1e9 + 7;
vector<vector<int>> table(10, vector<int>(10));
string toRadix(int n, int k) {
string res;
while (n > 0) {
res = (char)(n % k + '0') + res;
n /= k;
}
return res;
}
void prepare() {
for (int i = 1; i < 10; i++) {
for (int j = 1; j < 10; j++) {
table[i][j] = i * j;
}
}
}
void solution() {
int k;
cin >> k;
for (int i = 1; i < k; i++) {
for (int j = 1; j < k; j++) {
if (j == k - 1)
cout << toRadix(table[i][j], k);
else
cout << toRadix(table[i][j], k) << " ";
}
cout << '\n';
}
}
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
cout.tie(0);
;
prepare();
int test = 1;
while (test--) solution();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
inline int turn(int x) {
int tot = 0, res = 0, w[10];
while (x >= 1) w[++tot] = x % n, x /= n;
for (int i = tot; i >= 1; i--) res = res * 10 + w[i];
return res;
}
int main() {
cin >> n;
for (int i = 1; i < n; i++) {
for (int j = 1; j < n; j++) cout << turn(i * j) << ' ';
puts("");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
string base(int x, int b) {
string out = "";
while (x) {
out += (char)(x % b + '0');
x /= b;
}
reverse(out.begin(), out.end());
return out;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
int n, i, j;
cin >> n;
for (i = 1; i < n; i++) {
for (j = i; j < n * i; j += i) cout << base(j, n) << ' ';
cout << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long k, p;
long long mult(long long x, long long y) {
long long r = x * y;
vector<long long> g;
while (r) {
g.push_back(r % k);
r /= k;
}
for (int i = g.size() - 1; i >= 0; i--) {
r = r * 10 + g[i];
}
return r;
}
int main() {
cin >> k;
for (int i = 1; i < k; i++)
for (int j = 1; j < k; j++)
if (j == k - 1)
cout << mult(i, j) << endl;
else
cout << mult(i, j) << " ";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, i, j, k;
char s[4];
int toBaseN(int x) {
memset(s, '0', sizeof(s));
k = 2;
while (x / n) {
s[k--] = '0' + x % n;
x /= n;
}
s[k] = '0' + x % n;
s[3] = '\0';
return atoi(s);
}
int main() {
scanf("%d", &n);
for (i = 1; i < n; ++i) {
for (j = 1; j < n; ++j) {
printf("%4d", toBaseN(i * j));
}
printf("\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 103;
int main() {
int k;
scanf("%d", &k);
for (int i = 0; i < (int)(k); i++)
if (i) {
for (int j = 0; j < (int)(k); j++)
if (j) {
char s[20];
int n = 0, x = i * j;
while (!n || x) s[n++] = x % k, x /= k;
while (n--) printf("%d", s[n]);
printf(" ");
}
puts("");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int k;
cin >> k;
for (int i = 1; i < k; i++) {
for (int j = 1; j < k; j++) {
int ans;
ans = i * j;
int A[7], top = 0;
int ans2 = ans;
while (ans2 != 0) {
A[top] = ans2 % k;
top++;
ans2 = ans2 / k;
}
for (int l = top - 1; l >= 0; l--) cout << A[l];
cout << " ";
}
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int work(int n, int k) {
int ans = 0, p = 0;
while (n) {
ans += (n % k) * pow(10, p);
n /= k;
p++;
}
return ans;
}
int k;
int main() {
cin >> k;
for (int i = 1; i < k; i++) {
for (int j = 1; j < k; j++) {
cout << work(i * j, k) << " ";
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int k;
cin >> k;
for (int i = 1; i < k; ++i) {
for (int j = 1; j < k; ++j) {
if (i * j < k)
cout << i * j << " ";
else {
int tmp = 0;
int cnt = 0;
int t = i * j;
while (t > 0) {
tmp += pow(10, cnt++) * (t % k);
t /= k;
}
cout << tmp << " ";
}
}
cout << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
string c(int base, int x) {
int a[4], l = 0;
string ans;
while (x > 0) a[++l] = x % base, x /= base;
for (int i = l; i >= 1; i--) ans += (char)(a[i] + '0');
return ans;
}
int main() {
int base;
cin >> base;
for (int i = 1; i < base; i++)
for (int j = 1; j < base; j++)
cout << c(base, i * j) << (j < base - 1 ? ' ' : '\n');
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int k;
cin >> k;
for (int i = 1; i < k; ++i) {
for (int j = 1; j < k; ++j) {
int x = i * j, d = 1, t = 0;
while (x) {
t += d * (x % k);
x /= k;
d *= 10;
}
cout << t << " ";
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
string f(int x, int b) {
string s = "";
while (x) {
s += x % b + '0';
x /= b;
}
reverse(s.begin(), s.end());
return s;
}
int main() {
int k;
cin >> k;
for (int i = 1; i < k; i++) {
for (int j = 1; j < k; j++) cout << f(i * j, k) << ' ';
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
std::string output(int what, int base) {
int i;
std::string lemur;
std::vector<int> answer;
while (what > 0) {
answer.push_back(what % base);
what /= base;
}
for (i = answer.size() - 1; i >= 0; --i) {
lemur += (char)('0' + answer[i]);
}
return lemur;
}
int main(void) {
int i, j, k;
std::cin >> k;
for (i = 1; i < k; ++i) {
for (j = 1; j < k; ++j) {
std::cout << output(i * j, k) << " ";
}
std::cout << std::endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, f, g, h;
cin >> n;
for (int i = 1; i < n; i++) {
for (int j = 1; j < n; j++) {
h = i * j;
string s;
while (h > 0) {
s += (char)(h % n + 48);
h /= n;
}
reverse(s.begin(), s.end());
cout << s << " ";
}
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
void dfs(int x) {
if (x == 0) return;
dfs(x / n);
cout << x % n;
}
int main() {
cin >> n;
for (int i = 1; i < n; i++) {
for (int j = 1; j < n; j++) {
dfs(i * j);
cout << " ";
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
int main(void) {
int n;
scanf("%d", &n);
for (int i = 1; i < n; i++) {
for (int j = 1; j < n; j++) {
printf("%d ", (i * j / n) * 10 + (i * j % n));
}
printf("\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
char c[10];
string fac(int x) {
string s = "";
while (x) {
s = c[x % n] + s;
x /= n;
}
return s;
}
int main() {
for (int i = 0; i < 10; i++) c[i] = '0' + i;
scanf("%d", &n);
for (int i = 1; i < n; i++) {
for (int j = 1; j < n; j++) {
cout << fac(i * j) << " ";
}
printf("\n");
}
}
|
#include <bits/stdc++.h>
using namespace std;
int k;
void f(int x) {
string s;
while (x > 0) {
char c = '0';
c += x % k;
s = c + s;
x /= k;
}
cout << s << " ";
}
int main() {
cin >> k;
for (int i = 1; i < k; i++) {
for (int j = 1; j < k; j++) {
f(i * j);
}
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
string mabna(int x, int k) {
string ans;
while (x != 0) {
int z = x % k;
ans += char(z + '0');
x /= k;
}
string ans2;
for (int i = ans.size() - 1; i >= 0; i--) ans2 += ans[i];
return ans2;
}
int main() {
int n;
cin >> n;
for (int i = 1; i < n; i++) {
for (int j = 1; j < n; j++) cout << mabna(i * j, n) << " ";
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n;
char ch[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
string print(int x) {
string a = "";
while (x) {
a = ch[x % n] + a;
x /= n;
}
return a;
}
int main() {
cin >> n;
for (int i = 1; i < n; i++) {
for (int j = 1; j < n; j++) {
cout << print(i * j) << ' ';
}
puts("");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int table[15][15];
string turn(int x, int k) {
int i;
string s;
char c;
if (x < k) {
c = x + '0';
s += c;
return s;
} else {
while (x > 0) {
char c = (x % k) + '0';
s = c + s;
x = x / k;
}
}
return s;
}
int main() {
int k;
cin >> k;
for (int i = 1; i < k; i++) {
for (int j = 1; j < k; j++) {
table[i][j] = table[i][j - 1] + i;
cout << turn(table[i][j], k) << " ";
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
string a[10][10];
string change(int x, int base) {
string ret, s;
while (x) {
ret += (x % base) + '0';
x /= base;
}
for (string ::reverse_iterator rit = ret.rbegin(); rit != ret.rend(); ++rit)
s += *rit;
return s;
}
int main() {
int N, i, j;
while (scanf("%d", &N) != EOF) {
for (i = 1; i < N; ++i)
for (j = i; j < N; ++j) a[i][j] = a[j][i] = change(i * j, N);
for (i = 1; i < N; ++i) {
printf("%s ", a[i][1].c_str());
for (j = 2; j < N; ++j) printf("%2s ", a[i][j].c_str());
printf("\n");
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
inline int read() {
long long s = 0;
bool w = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') w = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
return s * w;
}
int n;
int zh(int a) {
int x = 0, y = 0, z[1005] = {0};
while (a > 0) {
z[++y] = a % n;
a /= n;
}
for (int i = y; i >= 1; i--) x = x * 10 + z[i];
return x;
}
int main() {
n = read();
for (int i = 1; i < n; i++) {
for (int j = 1; j < n; j++) printf("%d ", zh(i * j));
printf("\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
int a[10][10];
int j(int b) { return b == 0 ? 0 : j(b / n) * 10 + b % n; }
int main() {
cin >> n;
int t = n - 1;
for (int i = 0; i < t; i++)
for (int x = 0; x < t; x++) {
a[i][x] = j((i + 1) * (x + 1));
cout << a[i][x];
if (x == t - 1)
cout << endl;
else
cout << " ";
}
return 0;
}
|
#include <bits/stdc++.h>
int k;
int main() {
scanf("%d", &k);
for (int i = 1; i < k; i++) {
for (int j = 1; j < k; j++)
if (j != 1)
printf("%2d ", (i * j / k) * 10 + (i * j) % k);
else
printf("%d ", i * j);
printf("\n");
}
}
|
#include <bits/stdc++.h>
using namespace std;
void tulis(int n, int m) {
if (n < m) {
printf("%d", n);
} else {
tulis(n / m, m);
printf("%d", n % m);
}
}
int main() {
int k;
scanf("%d", &k);
for (int i = 1; i < k; i++) {
for (int j = 1; j < k; j++) {
if (j == k - 1) {
tulis(i * j, k);
printf("\n");
} else {
tulis(i * j, k);
printf(" ");
}
}
}
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.