text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; cout << a + (a - 1) / (b - 1); }
#include <bits/stdc++.h> int main() { int a, b, c, count; scanf("%d%d", &a, &b); count = 0; c = a; count = count + c; while (c >= b) { c = c - b; c++; count++; } printf("%d", count); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; int ans = 0; ans += a; while (a >= b) { ans = ans + a / b; a = a / b + a % b; } cout << ans; }
#include <bits/stdc++.h> int main() { int a, b, h, left; scanf("%d%d", &a, &b); left = h = a; while (left >= b) { left -= b; h++; left++; } printf("%d\n", h); }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; int a, b; cin >> a >> b; int ans = a; while (a >= b) { int k = a / b; ans += k; a = a % b + k; } cout << ans << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b; c = a; while (a >= b) { d = a % b; c += (a / b); a = (a / b + d); } cout << c; return 0; }
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; int inline in() { int x = 0, c; for (; (unsigned)((c = getchar()) - '0') >= 10;) { if (c == '-') return -in(); if (!~c) throw ~0; } do { x = (x << 3) + (x << 1) + (c - '0'); } while ((unsigned)((c = getchar()) - '0') < 10); return x; } int k; int main() { cin >> k; for (int i = 0; i < (k - 1); i++) { for (int j = 0; j < (k - 1); j++) { int pro = (i + 1) * (j + 1); if (pro >= k) { int tmp = pro / k; pro %= k; pro += tmp * 10; } cout << pro << ' '; } cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int k; int main() { cin >> k; for (int i = 1; i < k; ++i) { for (int j = 1; j < k; ++j) { int res = i * j; res = (res / k) * 10 + (res % k); cout << res << ' '; } cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; const int mx = (int)2e5 + 6; int n; int conver(int x) { int num = 0; vector<int> v; while (x != 0) { v.push_back(x % n); x /= n; } for (int i = (int)v.size() - 1; i >= 0; --i) { num += v[i]; if (i) num *= 10; } return num; } int main() { cin >> n; int mul[n + 2][n + 2]; for (int i = 1; i < n; ++i) { for (int j = 1; j < n; ++j) { mul[i][j] = i * j; } } for (int i = 1; i < n; ++i) { for (int j = 1; j < n; ++j) { if (mul[i][j] >= n) { mul[i][j] = conver(mul[i][j]); } } } for (int i = 1; i < n; ++i) { for (int j = 1; j < n; ++j) { cout << mul[i][j] << " "; } cout << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; void fl() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); } map<char, int> iin; map<char, int> iout; string lls(long long a) { stringstream ss; ss << a; string str = ss.str(); return str; } long long sst(string s) { stringstream g(s); long long x = 0; g >> x; return x; } int main() { fl(); int n; cin >> n; for (int i = 1; i < n; i++, cout << endl) for (int j = 1; j < n; j++) cout << ((i * j) / n) * 10 + (i * j) % n << " "; return 0; }
#include <bits/stdc++.h> using namespace std; int a[10][10]; vector<int> ostv; int perevod(int n, int p) { ostv.resize(1); int chastn = n / p; ostv[0] = n % p; int k = 1; while (chastn >= p) { k++; ostv.resize(k); ostv[k - 1] = chastn % p; chastn = chastn / p; } ostv.resize(k + 1); ostv[k] = chastn; int ans = 0, d = 1; for (int i = 0; i < ostv.size(); i++) { ans += ostv[i] * d; d = d * 10; } return ans; } int main() { int k, s; scanf("%d", &k); for (int i = 0; i < k - 1; i++) { a[0][i] = i + 1; a[i][0] = i + 1; } for (int i = 1; i < k - 1; i++) for (int j = 1; j < k - 1; j++) { s = (i + 1) * (j + 1); a[i][j] = perevod(s, k); } for (int i = 0; i < k - 1; i++) { for (int j = 0; j < k - 1; j++) printf("%d ", a[i][j]); printf("\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; void base(int n, int k) { vector<int> vt; while (n) { vt.push_back(n % k); n /= k; } reverse(vt.begin(), vt.end()); for (int i = 0; i < vt.size(); i++) { cout << vt[i]; } cout << " "; } int main() { int n; cin >> n; for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { base(i * j, n); } cout << endl; } cout << endl; }
#include <bits/stdc++.h> using namespace std; int i, j, k, l, m, n, h, t, arr[100000]; int fun(int a) { int i = 0, j = 0, d = 0; while (a > 0) { arr[i] = a % n; a /= n; i++; } for (j = i - 1; j >= 0; j--) d = d * 10 + arr[j]; return d; } int main() { scanf("%d", &n); for (i = 1; i < n; i++) { for (j = 1; j < n; j++) printf("%d ", fun(i * j)); printf("\n"); } }
#include <bits/stdc++.h> using namespace std; string str(int n, int b) { string ret; for (; n; n /= b) ret.push_back(n % b + '0'); reverse((ret).begin(), (ret).end()); return ret; } void run() { int k; cin >> k; for (int i = 0; i < k - 1; i++) { string s; for (int j = 0; j < k - 1; j++) s += str((i + 1) * (j + 1), k) + " "; cout << s << endl; } } int main() { run(); return 0; }
#include <bits/stdc++.h> void answer(const std::vector<std::vector<std::string>>& v) { for (const auto& r : v) { const char* separator = ""; for (const std::string& x : r) { std::cout << separator << x; separator = " "; } std::cout << '\n'; } } void solve(unsigned k) { const size_t n = k - 1; std::vector<std::vector<std::string>> t(n, std::vector<std::string>(n)); for (size_t i = 0; i < n; ++i) { for (size_t j = 0; j < n; ++j) { unsigned c = (i + 1) * (j + 1); do { t[i][j].push_back('0' + c % k); c /= k; } while (c != 0); std::reverse(t[i][j].begin(), t[i][j].end()); } } answer(t); } int main() { unsigned k; std::cin >> k; solve(k); return 0; }
#include <bits/stdc++.h> using namespace std; int base; string get(int a) { if (a == 0) return "0"; string res = ""; for (; a; a /= base) res += char(a % base + '0'); reverse(res.begin(), res.end()); return res; } int main() { scanf("%d", &base); for (int i = 1; i < base; i++) { for (int j = 1; j < base; j++) cout << get(i * j) << " "; cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; string toBase(int n, int b) { if (n == 0) return "0"; string s; int x; while (n) { x = n % b, n /= b; s.push_back('0' + x); } int l = s.length(); for (int i = 0; i < l / 2; i++) swap(s[i], s[l - i - 1]); return s; } int main() { int k; cin >> k; for (int i = 1; i < k; i++) { for (int j = 1; j < k; j++) { cout << toBase(i * j, k) << " "; } cout << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; int n, i, j, k; vector<int> ar; int cnvrt(int num) { int nn; ar.clear(); while (1) { ar.push_back(num % n); num /= n; if (num == 0) break; } k = 1; nn = 0; for (int i = ar.size() - 1; i >= 0; i--) { nn = nn * 10 + ar[i]; } return nn; } int main() { while (cin >> n) { for (i = 1; i < n; i++) { for (j = 1; j < n; j++) { cout << cnvrt(i * j) << " "; } cout << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; string fun(int x, int b) { string a = ""; while (x > 0) { char c = x % b + '0'; a = c + a; x /= b; } return a; } int main() { int k; cin >> k; for (int i = 0; i < (k - 1); i++) { for (int j = 0; j < (k - 1); j++) { cout << fun((i + 1) * (j + 1), k) << " "; } cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; const double INFK = 1e20; bool dy(double x, double y) { return x > y + 1e-6; } bool xy(double x, double y) { return x < y - 1e-6; } bool dyd(double x, double y) { return x > y - 1e-6; } bool xyd(double x, double y) { return x < y + 1e-6; } bool dd(double x, double y) { return fabs(x - y) < 1e-6; } int k; void f(int x) { int tot = 0; char ch[10000]; while (x) { ch[tot++] = x % k + '0'; x /= k; } for (int i = tot - 1; i >= 0; --i) { cout << ch[i]; } cout << ' '; } int main() { while (cin >> k) { for (int i = 1; i < k; ++i) { for (int j = 1; j < k; ++j) f(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++) cout << ((i * j) / k) * 10 + (i * j) % k << " "; cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; int n; int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> n; for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) cout << (i * j / n) * 10 + (i * j % n) << ' '; cout << '\n'; } }
#include <bits/stdc++.h> using namespace std; int n, a[11][11]; int c(int x) { int s = 0, p = 1; while (x) { s = s + (x % n) * p; x = x / n; p = p * 10; } return s; } int main() { cin >> n; for (int i = 1; i < n; i++) for (int j = 1; j < n; j++) a[i][j] = c(i * j); for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) cout << a[i][j] << " "; cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n == 2) cout << 1; if (n == 3) { cout << "1 2" << endl; cout << "2 11"; } if (n == 4) { cout << "1 2 3" << endl; cout << "2 10 12" << endl; cout << "3 12 21"; } if (n == 5) { cout << "1 2 3 4" << endl; cout << "2 4 11 13" << endl; cout << "3 11 14 22" << endl; cout << "4 13 22 31"; } if (n == 6) { cout << "1 2 3 4 5" << endl; cout << "2 4 10 12 14" << endl; cout << "3 10 13 20 23" << endl; cout << "4 12 20 24 32" << endl; cout << "5 14 23 32 41"; } if (n == 7) { cout << "1 2 3 4 5 6" << endl; cout << "2 4 6 11 13 15" << endl; cout << "3 6 12 15 21 24" << endl; cout << "4 11 15 22 26 33" << endl; cout << "5 13 21 26 34 42" << endl; cout << "6 15 24 33 42 51"; } if (n == 8) { cout << "1 2 3 4 5 6 7" << endl; cout << "2 4 6 10 12 14 16" << endl; cout << "3 6 11 14 17 22 25" << endl; cout << "4 10 14 20 24 30 34" << endl; cout << "5 12 17 24 31 36 43" << endl; cout << "6 14 22 30 36 44 52" << endl; cout << "7 16 25 34 43 52 61"; } if (n == 9) { cout << "1 2 3 4 5 6 7 8" << endl; cout << "2 4 6 8 11 13 15 17" << endl; cout << "3 6 10 13 16 20 23 26" << endl; cout << "4 8 13 17 22 26 31 35" << endl; cout << "5 11 16 22 27 33 38 44" << endl; cout << "6 13 20 26 33 40 46 53" << endl; cout << "7 15 23 31 38 46 54 62" << endl; cout << "8 17 26 35 44 53 62 71"; } if (n == 10) { cout << "1 2 3 4 5 6 7 8 9" << endl; cout << "2 4 6 8 10 12 14 16 18" << endl; cout << "3 6 9 12 15 18 21 24 27" << endl; cout << "4 8 12 16 20 24 28 32 36" << endl; cout << "5 10 15 20 25 30 35 40 45" << endl; cout << "6 12 18 24 30 36 42 48 54" << endl; cout << "7 14 21 28 35 42 49 56 63" << endl; cout << "8 16 24 32 40 48 56 64 72" << endl; cout << "9 18 27 36 45 54 63 72 81"; } return 0; }
#include <bits/stdc++.h> int sto[111]; int main() { int n; scanf("%d", &n); for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { int ii = i * j; int cnt = 0; while (ii) { sto[cnt++] = ii % n; ii /= n; } for (int kk = cnt - 1; kk >= 0; kk--) printf("%d", sto[kk]); putchar(' '); } puts(""); } }
#include <bits/stdc++.h> using namespace std; int k; void calc(int x) { string s = " "; while (x) { s = char('0' + x % k) + s; x /= k; } cout << s; } int main() { cin >> k; for (int i = 1; i < k; i++) { for (int j = 1; j < k; j++) calc(i * j); cout << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { int res = i * j; string str; while (res != 0) { str += (res % n + '0'); res /= n; } for (int i = str.size() - 1; i >= 0; i--) cout << str[i]; cout << " "; } cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int a[10]; int main() { int n, mul, k; scanf("%d", &n); for (int i = 1; i <= n - 1; i++) { for (int j = 1; j <= n - 1; j++) { mul = i * j; k = 0; while (mul) { a[k] = mul % n; mul /= n; k++; } for (int l = k - 1; l >= 0; l--) printf("%d", a[l]); printf(" "); } printf("\n"); } return 0; }
#include <bits/stdc++.h> int tran(int a, int b) { int t; int res = 0; int pow = 1; do { t = a / b; res += pow * (a - (a / b) * b); a = t; pow *= 10; } while (t >= b); res += pow * t; return res; } int main() { int b, i, j; scanf("%d", &b); for (i = 1; i < b; i++) { for (j = 1; j < b; j++) { printf("%d ", tran(i * j, b)); } printf("\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int k; int q = 1; cin >> k; int a[k - 1][k - 1]; for (int i = 0; i < k - 1; i++) { for (int j = 0; j < k - 1; j++) { a[i][j] = j * q + q; if (a[i][j] >= k) { a[i][j] = (a[i][j] / k) * 10 + (a[i][j] % k); } cout << a[i][j] << " "; } q++; cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; 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++) { int x = i * j, y = 0, r = 1; while (x > 0) { y = r * (x % k) + y; x /= k; r *= 10; } cout << y << ' '; } cout << endl; ; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { int x = (i * j / n) * 10 + (i * j % n); cout << x << " "; } cout << endl; } }
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 20; const int MAX = 10000007; inline long long read() { char c = getchar(); long long x = 0, f = 1; while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = x * 10 + c - '0', c = getchar(); } return x * f; } inline void out(int x) { if (x > 9) out(x / 10); putchar(x % 10 + '0'); } int k; int main() { k = read(); for (int i = (1); i <= (k - 1); ++i) { for (int j = (1); j <= (k - 1); ++j) { int t = i * j; int kep = t; string s; while (kep) { s += kep % k + '0'; kep /= k; } reverse(s.begin(), s.end()); cout << s << " "; } cout << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j, k, x, y; scanf("%d", &n); for (i = 1; i < n; i++) { for (j = 1; j < n; j++) { k = i * j % n; if (i * j / n) printf("%d", i * j / n); printf("%d ", k); } printf("\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; for (int i = 1; i <= (k - 1); i++) { if (i != 1) cout << '\n'; for (int j = 1; j <= (k - 1); j++) cout << 10 * ((i * j) / k) + (i * j) % k << ' '; } return 0; }
#include <bits/stdc++.h> using namespace std; int sort(const void* a, const void* b) { return (*(int*)a - *(int*)b); } int main() { int k; cin >> k; int** mat = new int*[k - 1]; for (int i = 0; i < k - 1; i++) mat[i] = new int[k - 1]; for (int i = 0; i < k - 1; i++) mat[0][i] = i + 1; for (int i = 1; i < k - 1; i++) mat[i][0] = i + 1; for (int i = 1; i < k - 1; i++) for (int j = 1; j < k - 1; j++) mat[i][j] = ((mat[0][j] * mat[i][0]) / k) * 10 + (mat[0][j] * mat[i][0]) % k; for (int i = 0; i < k - 1; i++) { for (int j = 0; j < k - 1; j++) cout << mat[i][j] << " "; cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int a[20][20], i, j, k, sk[20], tp; int main() { scanf("%d", &k); for (i = 1; i < k; i++) a[i][1] = a[1][i] = i; for (i = 2; i < k; i++) for (j = 2; j < k; j++) a[i][j] = a[i][1] * a[1][j]; for (i = 1; i < k; i++) { for (j = 1; j < k; j++) { tp = 0; while (a[i][j] > 0) { ++tp; sk[tp] = a[i][j] % k; a[i][j] /= k; } while (tp > 0) { printf("%d", sk[tp]); tp--; } printf(" "); } printf("\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; int eprintf(const char *format, ...) { return 0; } string calc(int x, int n) { string res = ""; for (; x; x /= n) res = string(1, '0' + (x % n)) + res; return res; } int main() { int n; while (scanf("%d", &n) >= 1) { for (int a = 1; a <= n - 1; a++, printf("\n")) for (int b = 1; b <= n - 1; b++) { int c = a * b; string s = calc(c, n); if (b > 1) printf(" %2s", s.c_str()); else printf("%1s", s.c_str()); } break; } return 0; }
#include <bits/stdc++.h> void conv(char *str, int k, int n) { int n2, num = 0; n2 = n; while (n2 != 0) { num++; n2 = n2 / k; } while (n != 0) { } } int main() { int a[10][10] = {0}; int d1, d2, c; int k, i, j; scanf("%d", &k); for (j = 0; j < k - 1; j++) a[0][j] = j + 1; for (i = 1; i < k - 1; i++) a[i][0] = i + 1; for (i = 1; i < k; i++) for (j = 1; j < k; j++) { c = (i + 1) * (j + 1); if (c >= k) { d1 = c % k; c /= k; d2 = c % k; a[i][j] = d1 + d2 * 10; } else a[i][j] = c; } for (i = 0; i < k - 1; i++) { for (j = 0; j < k - 1; j++) { printf("%d\t", a[i][j]); if (j != k - 1) printf(" "); } printf("\n"); } }
#include <bits/stdc++.h> using namespace std; string base(int a, int b, int base) { int res = a * b; int temp = 0, c = 0; string y = ""; while (res != 0) { int x = (int)res % base; res /= base; y += (x + 48); } reverse(y.begin(), y.end()); return y; } int main() { int num; cin >> num; for (int i = 1; i < num; i++) { for (int j = 1; j < num; j++) { if (j == num - 1) { cout << base(i, j, num) << endl; } else cout << base(i, j, num) << " "; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a[11][11], valore; string s[11][11], t; cin >> n; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) a[i][j] = (i + 1) * (j + 1); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) { valore = a[i][j]; t = ""; while (valore > 0) { t += to_string(valore % n); valore /= n; } reverse(t.begin(), t.end()); s[i][j] = t; } for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - 1; j++) cout << s[i][j] << " "; cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; long n, t; vector<long> v; int main() { ios_base::sync_with_stdio(0); cin >> n; for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { t = i * j; v.clear(); while (t) { v.push_back(t % n); t /= n; } for (int q = v.size() - 1; q + 1; --q) cout << v[q]; cout << " "; } cout << endl; } cin.get(); cin.get(); return 0; }
#include <bits/stdc++.h> using namespace std; const int inf = 1e9, dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1}; int n; int f(int x, int base) { string s; int a = x; while (a) { s += char(a % base + '0'); a /= base; } int ans = 0; for (int i = s.size() - 1; i >= 0; i--) ans = ans * 10 + int(s[i] - '0'); return ans; } int main() { cin >> n; for (int i = 1; i < n; i++, cout << '\n') for (int j = 1; j < n; j++) { int x = f(i * j, n); if (j > 1) { if (x < 10) cout << " "; else cout << ' '; } cout << x; } return 0; }
#include <bits/stdc++.h> using namespace std; int multi(int i, int j, int n) { int x = i * j; int y; int p = 1; int sum = 0; while (x != 0) { sum = sum + (x % n) * p; x = x / n; p = p * 10; } return sum; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int arr[n - 1][n - 1]; for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - 1; j++) { arr[i][j] = multi(i + 1, j + 1, n); } } for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - 1; j++) { cout << arr[i][j]; if (arr[i][j] < 10) { cout << " "; } else { cout << " "; } } cout << '\n'; } return 0; }
#include <bits/stdc++.h> using namespace std; int A[15][15] = {0}; int main() { short k; cin >> k; int a, b; a = 0; b = 0; int temp; int x = 0; for (int i = 1; i < k; i++) A[0][i] = i + 1; for (int i = 1; i < k; i++) A[i][0] = i + 1; A[0][0] = 1; for (int i = 2, a = 1; i < k; i++, a++) for (int j = 2, b = 1; j < k; j++, b++) { int res = 0; temp = i * j; if (temp >= k) { x = temp / k; res = temp - (x * k); res = res + 10 * x; temp = res; } A[a][b] = temp; } for (int a = 0; a < k - 1; a++) { for (int b = 0; b < k - 1; b++) cout << A[a][b] << " "; cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; void tabdil(int a, int b) { if (a < b) cout << a; else { cout << int(a / b); cout << a % b; } return; } int main() { int k; cin >> k; for (int i = 1; i < k; i++) { for (int j = 1; j < k; j++) { tabdil(i * j, k); if (j != k - 1) cout << " "; } cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; stack<int> sol; int main() { int n; scanf("%d", &n); for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { int nn = i * j; while (nn > 0) { sol.push(nn % n); nn /= n; } while (!sol.empty()) { printf("%d", sol.top()); sol.pop(); } printf(" "); } printf("\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n == 2) { cout << 1; } if (n == 3) { cout << "1 2" << endl; cout << "2 11" << endl; } if (n == 4) { cout << "1 2 3" << endl; cout << "2 10 12" << endl; cout << "3 12 21" << endl; } if (n == 5) { cout << "1 2 3 4" << endl; cout << "2 4 11 13" << endl; cout << "3 11 14 22" << endl; cout << "4 13 22 31" << endl; } if (n == 6) { cout << "1 2 3 4 5" << endl; cout << "2 4 10 12 14" << endl; cout << "3 10 13 20 23" << endl; cout << "4 12 20 24 32" << endl; cout << "5 14 23 32 41" << endl; } if (n == 7) { cout << "1 2 3 4 5 6" << endl; cout << "2 4 6 11 13 15" << endl; cout << "3 6 12 15 21 24" << endl; cout << "4 11 15 22 26 33" << endl; cout << "5 13 21 26 34 42" << endl; cout << "6 15 24 33 42 51" << endl; } if (n == 8) { cout << "1 2 3 4 5 6 7" << endl; cout << "2 4 6 10 12 14 16" << endl; cout << "3 6 11 14 17 22 25" << endl; cout << "4 10 14 20 24 30 34" << endl; cout << "5 12 17 24 31 36 43" << endl; cout << "6 14 22 30 36 44 52" << endl; cout << "7 16 25 34 43 52 61" << endl; } if (n == 9) { cout << "1 2 3 4 5 6 7 8" << endl; cout << "2 4 6 8 11 13 15 17" << endl; cout << "3 6 10 13 16 20 23 26" << endl; cout << "4 8 13 17 22 26 31 35" << endl; cout << "5 11 16 22 27 33 38 44" << endl; cout << "6 13 20 26 33 40 46 53" << endl; cout << "7 15 23 31 38 46 54 62" << endl; cout << "8 17 26 35 44 53 62 71" << endl; } if (n == 10) { cout << "1 2 3 4 5 6 7 8 9" << endl; cout << "2 4 6 8 10 12 14 16 18" << endl; cout << "3 6 9 12 15 18 21 24 27" << endl; cout << "4 8 12 16 20 24 28 32 36" << endl; cout << "5 10 15 20 25 30 35 40 45" << endl; cout << "6 12 18 24 30 36 42 48 54" << endl; cout << "7 14 21 28 35 42 49 56 63" << endl; cout << "8 16 24 32 40 48 56 64 72" << endl; cout << "9 18 27 36 45 54 63 72 81" << endl; } return 0; }
#include <bits/stdc++.h> #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; void rev(string s) { for (int i = 0; i < s.size(); i++) { long long p = (s[i] - '0') % 10; cout << p; } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long b; cin >> b; int v; for (long long i = 1; i < b; i++) { for (long long j = 1; j < b; j++) { long long c = i * j; long long i, a[10] = {0}; for (i = 0; c != 0; i++) { long long k = c % b; a[i] = k; c = c / b; } for (int j = i - 1; j >= 0; j--) cout << a[j]; cout << " "; } cout << '\n'; } return 0; }
#include <bits/stdc++.h> using namespace std; int n; int conv(int num, int *str, int base) { str[0] = 0; while (num > 0) { str[++str[0]] = num % base; num /= base; } return 0; } int input(void) { scanf("%d", &n); return 0; } int solve(void) { int str[10 + 1]; for (register int i = 1; i <= n - 1; i++) { for (register int j = 1; j <= n - 1; j++) { conv(i * j, str, n); for (register int t = str[0]; t >= 1; t--) { printf("%d", str[t]); } if (j < n - 1) printf(" "); } printf("\n"); } return 0; } int main(void) { input(); solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k, p; cin >> k; for (i = 1; i < k; i++) { for (j = 1; j < k; j++) { p = i * j; if (p >= k) cout << p / k; else cout << ' '; cout << p % k << ' '; } cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int n, a[11][11]; int zh(int x) { long long sum = 0, i = 0; while (x) { sum = sum + ((x % n) * pow(10, i)); i++; x /= n; } return sum; } int main() { cin >> n; for (int i = 1; i < n; i++) a[1][i] = a[i][1] = i; for (int i = 2; i < n; i++) { for (int j = 2; j < n; j++) { a[i][j] = zh(i * j); } } for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) cout << a[i][j] << " "; puts(""); } return 0; }
#include <bits/stdc++.h> using namespace std; int conversion(string p) { int o; o = atoi(p.c_str()); return o; } string toString(int h) { stringstream ss; ss << h; return ss.str(); } long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); } long long lcm(long long a, long long b) { return (a * (b / gcd(a, b))); } long long toi(string p) { long long x; istringstream in(p); in >> x; return x; } int k, mul = 1, lab[11][11]; string go(int n) { string ans = ""; while (n / k > 0) { ans += toString(n % k); n /= k; } ans += toString(n % k); reverse(ans.begin(), ans.end()); return ans; } int main() { for (int i = 1; i <= 10; i++) { for (int j = 1; j <= 10; j++) { lab[i][j] = j * mul; } mul++; } while (cin >> k) { for (int i = 1; i <= k - 1; i++) { for (int j = 1; j <= k - 1; j++) { cout << go(lab[i][j]) << " "; } cout << endl; } } }
#include <bits/stdc++.h> using namespace std; string ans; int n; string zjz(int a) { if (a == 0) { return ""; } else { return zjz(a / n) + char(a % n + '0'); } } int main() { int t; cin >> n; for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { t = i * j; ans = zjz(t); cout << ans; if (ans.size() == 1) { cout << " "; } else { cout << " "; } } 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]; } } 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; const int MAXN = 20; int arr[MAXN][MAXN]; int n; void F(int a) { string s; while (a >= n) { s += (a % n) + '0'; a /= n; } s += a + '0'; reverse(s.begin(), s.end()); cout << s << " "; } int main() { cin >> n; for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) F(i * j); cout << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int n, i, c, j; while (cin >> n) { for (i = 1; i <= n - 1; i++) { c = 0; for (j = i;; j += i) { c++; if (j >= n) printf("%d%d ", j / n, j % n); else cout << j << " "; if (c == n - 1) break; } cout << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 105; int k; void out(int n, int k) { if (n == 0) return; out(n / k, k); cout << n % k; } int main() { cin >> k; for (int i = 1; i < k; i++) { for (int j = 1; j < k; j++) { int num = i * j; out(num, k); cout << (j == k - 1 ? "\n" : " "); } } return 0; }
#include <bits/stdc++.h> using namespace std; int n; int main() { cin >> n; for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { cout << i * j / n * 10 + (i * j) % n << " "; } cout << endl; } }
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const int inf = (int)1e9; const double inf1 = 1e-9; const int ss = (int)1e6 + 3; const int base = inf; bool pred(const pair<string, int>& i, const pair<string, int>& j) { if (i.second == j.second) return i.first < j.first; else return i.second > j.second; } bool pred2(const int& i, const int& j) { return i < j; } int main() { int n; scanf("%d", &n); --n; int k = n + 1; int z; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { z = (i + 1) * (j + 1); string s = ""; while (z != 0) { s = (char)(z % k + '0') + s; z /= k; } cout << s << " "; } cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; for (int i = 1; i <= k - 1; i++) { for (int j = 1; j <= k - 1; j++) { cout << ((i * j / k) * 10) + (i * j % k) << " "; } cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const long double PI = 4 * atan((long double)1); long long power(long long a, long long n) { long long res = 1; while (n) { if (n % 2) res *= a; a *= a; n /= 2; } return res; } long long int h = power(10, 10); string bin(int n, int k) { string t, s; while (n != 0) { int x = n % k; char a = x + '0'; n = n / k; t = t + a; } for (int i = t.size() - 1; i >= 0; i--) s = s + t[i]; return s; } int main() { int n; cin >> n; for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { string as = bin(i * j, n); cout << as << " "; } cout << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int k, i, j, a[200][200], p, x[100], n, l; cin >> k; for (i = 1; i < k; i++) { for (j = 1; j < k; j++) { p = i * j; n = 0; while (p != 0) { x[n++] = p % k; p /= k; } for (l = n - 1; l >= 0; l--) cout << x[l]; cout << " "; } cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; void work(int a, int n) { if (a >= n) cout << a / n % n; cout << a % n << " "; } int main() { int n; cin >> n; for (int i = 1; i < n; i++, cout << endl) for (int j = 1; j < n; j++) work(i * j, n); return 0; }
#include <bits/stdc++.h> using namespace std; string fromDeci(int base, int inputNum) { string result; while (inputNum > 0) { result = result + to_string(inputNum % base); inputNum = inputNum / base; } reverse(result.begin(), result.end()); return result; } int main() { int k, i, j; cin >> k; for (i = 1; i < k; i++) { for (j = 1; j < k; j++) cout << fromDeci(k, i * j) << " "; cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j, k, k1, a[11][11]; vector<int> c; cin >> n; for (i = 1; i < n; i++) for (j = 1; j < n; j++) { a[i][j] = 0; k = i * j; while (k >= n) { c.push_back(k % n); k /= n; } c.push_back(k); for (int x = c.size() - 1; x >= 0; x--) a[i][j] = a[i][j] * 10 + c[x]; c.clear(); } for (i = 1; i < n; i++) { for (j = 1; j < n; j++) cout << a[i][j] << ' '; cout << '\n'; } return 0; }
#include <bits/stdc++.h> using namespace std; string ans; int n; string zjz(int a) { if (a == 0) { return ""; } else { return zjz(a / n) + char(a % n + '0'); } } int main() { int t; cin >> n; for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { t = i * j; ans = zjz(t); if (ans.size() == 1) { if (j != 1) { cout << " "; } } else { cout << " "; } cout << ans; } cout << endl; } }
#include <bits/stdc++.h> using namespace std; int n, w = 1, j, sum; string s; int main() { cin >> n; for (w = 1; w < n; w++) { for (j = 1; j < n; j++) { sum = j * w; while (sum > 0) { s += sum % n + '0'; sum /= n; } reverse(s.begin(), s.end()); cout << s << " "; s.clear(); if (j == n - 1) { cout << "\n"; } } } return 0; }
#include <bits/stdc++.h> using namespace std; int n, x, a[15][15]; int main() { cin >> n; if (n == 2) { cout << "1"; } if (n == 3) { cout << "1 2" << endl; cout << "2 11"; } if (n == 4) { cout << "1 2 3" << endl; cout << "2 10 12" << endl; cout << "3 12 21" << endl; } if (n == 5) { cout << "1 2 3 4" << endl; cout << "2 4 11 13" << endl; cout << "3 11 14 22" << endl; cout << "4 13 22 31" << endl; } if (n == 6) { cout << "1 2 3 4 5" << endl; cout << "2 4 10 12 14" << endl; cout << "3 10 13 20 23" << endl; cout << "4 12 20 24 32" << endl; cout << "5 14 23 32 41" << endl; } if (n == 7) { cout << "1 2 3 4 5 6" << endl; cout << "2 4 6 11 13 15" << endl; cout << "3 6 12 15 21 24" << endl; cout << "4 11 15 22 26 33" << endl; cout << "5 13 21 26 34 42" << endl; cout << "6 15 24 33 42 51" << endl; } if (n == 8) { cout << "1 2 3 4 5 6 7" << endl; cout << "2 4 6 10 12 14 16" << endl; cout << "3 6 11 14 17 22 25" << endl; cout << "4 10 14 20 24 30 34" << endl; cout << "5 12 17 24 31 36 43" << endl; cout << "6 14 22 30 36 44 52" << endl; cout << "7 16 25 34 43 52 61" << endl; } if (n == 9) { cout << "1 2 3 4 5 6 7 8" << endl; cout << "2 4 6 8 11 13 15 17" << endl; cout << "3 6 10 13 16 20 23 26" << endl; cout << "4 8 13 17 22 26 31 35" << endl; cout << "5 11 16 22 27 33 38 44" << endl; cout << "6 13 20 26 33 40 46 53" << endl; cout << "7 15 23 31 38 46 54 62" << endl; cout << "8 17 26 35 44 53 62 71" << endl; } if (n == 10) { cout << "1 2 3 4 5 6 7 8 9" << endl; cout << "2 4 6 8 10 12 14 16 18" << endl; cout << "3 6 9 12 15 18 21 24 27" << endl; cout << "4 8 12 16 20 24 28 32 36" << endl; cout << "5 10 15 20 25 30 35 40 45" << endl; cout << "6 12 18 24 30 36 42 48 54" << endl; cout << "7 14 21 28 35 42 49 56 63" << endl; cout << "8 16 24 32 40 48 56 64 72" << endl; cout << "9 18 27 36 45 54 63 72 81" << endl; } return 0; }
#include <bits/stdc++.h> #pragma GCC optimize(3) #pragma GCC optimize("02") #pragma GCC optimize("Ofast") #pragma GCC optimize("inline") #pragma GCC optimize("-fgcse") #pragma GCC optimize("-fgcse-lm") #pragma GCC optimize("-fipa-sra") #pragma GCC optimize("-ftree-pre") #pragma GCC optimize("-ftree-vrp") #pragma GCC optimize("-fpeephole2") #pragma GCC optimize("-ffast-math") #pragma GCC optimize("-fsched-spec") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("-falign-jumps") #pragma GCC optimize("-falign-loops") #pragma GCC optimize("-falign-labels") #pragma GCC optimize("-fdevirtualize") #pragma GCC optimize("-fcaller-saves") #pragma GCC optimize("-fcrossjumping") #pragma GCC optimize("-fthread-jumps") #pragma GCC optimize("-funroll-loops") #pragma GCC optimize("-fwhole-program") #pragma GCC optimize("-freorder-blocks") #pragma GCC optimize("-fschedule-insns") #pragma GCC optimize("inline-functions") #pragma GCC optimize("-ftree-tail-merge") #pragma GCC optimize("-fschedule-insns2") #pragma GCC optimize("-fstrict-aliasing") #pragma GCC optimize("-fstrict-overflow") #pragma GCC optimize("-falign-functions") #pragma GCC optimize("-fcse-skip-blocks") #pragma GCC optimize("-fcse-follow-jumps") #pragma GCC optimize("-fsched-interblock") using namespace std; class complex { public: inline char gc() { static const int IN_LEN = 1 << 18 | 1; static char buf[IN_LEN], *s, *t; return (s == t) && (t = (s = buf) + fread(buf, 1, IN_LEN, stdin)), s == t ? -1 : *s++; } template <typename _Tp> __inline__ __attribute__((always_inline)) complex &operator>>(_Tp &x) { static char ch, sgn; ch = gc(), sgn = 0; for (; !isdigit(ch); ch = gc()) { if (ch == -1) return *this; sgn |= ch == '-'; } for (x = 0; isdigit(ch); ch = gc()) x = x * 10 + (ch ^ '0'); sgn && (x = -x); return *this; } } inc; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; switch (n) { case 2: printf("1\n"); break; case 3: printf("1 2\n2 11\n"); break; case 4: printf("1 2 3\n2 10 12\n3 12 21\n"); break; case 5: printf("1 2 3 4\n2 4 11 13\n3 11 14 22\n4 13 22 31\n"); break; case 6: printf( "1 2 3 4 5\n2 4 10 12 14\n3 10 13 20 23\n4 12 20 24 32\n5 14 23 " "32 41\n"); break; case 7: printf( "1 2 3 4 5 6\n2 4 6 11 13 15\n3 6 12 15 21 24\n4 11 15 22 26 " "33\n5 13 21 26 34 42\n6 15 24 33 42 51\n"); break; case 8: printf( "1 2 3 4 5 6 7\n2 4 6 10 12 14 16\n3 6 11 14 17 22 25\n4 10 " "14 20 24 30 34\n5 12 17 24 31 36 43\n6 14 22 30 36 44 52\n7 16 25 " "34 43 52 61\n"); break; case 9: printf( "1 2 3 4 5 6 7 8\n2 4 6 8 11 13 15 17\n3 6 10 13 16 20 " "23 26\n4 8 13 17 22 26 31 35\n5 11 16 22 27 33 38 44\n6 13 20 " "26 33 40 46 53\n7 15 23 31 38 46 54 62\n8 17 26 35 44 53 62 71\n"); break; case 10: printf( "1 2 3 4 5 6 7 8 9\n2 4 6 8 10 12 14 16 18\n3 6 9 12 15 " "18 21 24 27\n4 8 12 16 20 24 28 32 36\n5 10 15 20 25 30 35 40 " "45\n6 12 18 24 30 36 42 48 54\n7 14 21 28 35 42 49 56 63\n8 16 24 " "32 40 48 56 64 72\n9 18 27 36 45 54 63 72 81\n"); break; } return 0; }
#include <bits/stdc++.h> using namespace std; int k; string fun(int d) { string a; while (d != 0) { a += '0' + d % k; d /= k; } reverse(a.begin(), a.end()); return a; } int main() { cin >> k; for (int i = 1; i < k; i++) { for (int j = 1; j < k; j++) { cout << fun(i * j); if (j != k - 1) cout << " "; } cout << endl; } return 0; }
#include <bits/stdc++.h> long i, j, k, q, p; long A[100]; void tool() { p = i * j; q = 0; while (p != 0) { q++; A[q] = p % k; p = p / k; } for (q = q; q >= 1; q--) printf("%ld", A[q]); } int main() { scanf("%ld", &k); for (i = 1; i < k; i++) { for (j = 1; j < k - 1; j++) { tool(); printf(" "); } j = k - 1; tool(); printf("\n"); } }
#include <bits/stdc++.h> int n; int main() { scanf("%d", &n); for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) if (i * j >= n) printf("%d%d ", i * j / n, i * j % n); else printf("%d ", i * j % n); printf("\n"); } return 0; }
#include <bits/stdc++.h> int main() { int k, a, b; scanf("%d", &k); for (int i = 1; i < k; i++) { for (int j = 1; j < k; j++) { if (j == 1) { printf("%d", i); continue; } a = i * j / k; b = i * j % k; if (a == 0) printf(" %d", b); else printf(" %d%d", a, b); } puts(""); } }
#include <bits/stdc++.h> using namespace std; int n, i, j, k; void bin(int k) { if (k == 0) return; bin(k / n); cout << k % n; } int main() { cin >> n; for (i = 1; i < n; i++, cout << '\n') for (j = 1; j < n; j++, cout << ' ') bin(i * j); }
#include <bits/stdc++.h> using namespace std; int main() { int k, r; cin >> k; deque<int> ans; for (int i = 1; i < k; i++) { for (int j = 1; j < k; j++) { r = i * j; if (r >= k) { while (r >= k) { ans.push_front(r % k); r /= k; } ans.push_front(r); while (ans.size()) { cout << ans.front(); ans.pop_front(); } } else { cout << r; } cout << " "; } cout << endl; } }
#include <bits/stdc++.h> using namespace std; void TO(int x, int y) { string s; while (x) { s += x % y + '0'; x /= y; } for (int i = s.size() - 1; i >= 0; i--) cout << s[i]; cout << ' '; } int main() { int k; cin >> k; for (int i = 1; i <= k - 1; i++) { for (int j = 1; j <= k - 1; j++) TO(i * j, k); cout << endl; } return 0; }
#include <bits/stdc++.h> int main() { int n; scanf("%d", &n); for (int i = 1; i < n; i++, printf("\n")) for (int j = 1; j < n; j++) if (j != 1) printf("%4d ", (i * j / n) * 10 + (i * j) % n); else printf("%d", i * j); return 0; }
#include <bits/stdc++.h> using namespace std; int i, j, k, l, n, m, x, y, s, p; int main() { cin >> n; for (i = 1; i < n; i++) { for (j = 1; j < n; j++) { x = i * j; s = 0; p = 0; while (x > 0) { k = x % n; s += k * pow(10, p); x /= n; p++; } printf("%d", s); if (j != n - 1) printf(" "); } if (i != n - 1) printf("\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 1; i < n; i++, cout << '\n') for (int j = 1; j < n; j++) { int t = i * j; string s; while (t) s += t % n + '0', t /= n; reverse(s.begin(), s.end()); cout << s << ' '; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; int tabla[k - 1][k - 1]; int i, j; for (i = 0; i < k - 1; i++) { for (j = 0; j < k - 1; j++) { int M = (i + 1) * (j + 1); int p = 0, q = 1; while (M >= k) { p = p + (M % k) * (q); q = 10 * q; M = M / k; } p = p + (M) * (q); tabla[i][j] = p; } } for (i = 0; i < k - 1; i++) { for (j = 0; j < k - 1; j++) { cout << tabla[i][j] << " "; } cout << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; void print(int x, int b) { if (x) { print(x / b, b); printf("%d", x % b); } } int main() { int k; cin >> k; for (int i = (1); i <= (k - 1); ++i) for (int j = (1); j <= (k - 1); ++j) print(i * j, k), printf("%c", j == k - 1 ? '\n' : ' '); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a; cin >> a; for (int i = 1; i <= a - 1; i++, putchar('\n')) for (int j = 1; j <= a - 1; j++) if (j != 1) printf("%2d ", (i * j / a) * 10 + (i * j) % a); else printf("%d ", i * j); }
#include <bits/stdc++.h> using namespace std; int n, x, num, b[109]; int main() { cin >> n; for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { int x = i * j; num = 0; while (x) { num++; b[num] = x % n; x /= n; } for (int q = num; q >= 1; q--) cout << b[q]; cout << " "; } cout << endl; } }
#include <bits/stdc++.h> using namespace std; int k; int main() { cin >> k; for (int i = 1; i < k; i++) { for (int j = 1; j < k; j++) { int n = i * j; string s; while (n) { s = char((n % k) + '0') + s; n /= k; } cout << s << " "; } cout << endl; } }
#include <bits/stdc++.h> using namespace std; string number(int n, int radix, int j) { string s(""); while (n > 0) { int rem = n % radix; rem = rem + 48; char x = rem; s = x + s; n = n / radix; } if ((s.length() == 1) && (j != 1)) s = " " + s; return s; } int main() { int n; cin >> n; for (int i = 1; i <= n - 1; i++) { for (int j = 1; j <= n - 1; j++) { cout << number(i * j, n, j) << " "; } cout << endl; } }
#include <bits/stdc++.h> using namespace std; void Cout(int x, int y) { int res = 0, y2 = 0, num[1005]; memset(num, 0, sizeof(num)); while (y) { num[y2++] = y % x; y /= x; } for (int i = y2 - 1; i >= 0; i--) cout << num[i]; } int n; int main() { cin >> n; for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { Cout(n, i * j); cout << ' '; } cout << endl; } }
#include <bits/stdc++.h> using namespace std; int k; string iomap[10][10]; string chan(int x) { string ans = ""; while (x) { ans += (char)((x % k) + '0'); x /= k; } reverse(ans.begin(), ans.end()); return ans; } int main() { cin >> k; for (int i = 1; i <= k - 1; i++) { for (int j = 1; j <= k - 1; j++) { int tmp = i * j; iomap[i][j] = chan(tmp); } } for (int i = 1; i <= k - 1; i++) { for (int j = 1; j <= k - 1; j++) cout << iomap[i][j] << " "; cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int k; string solve(int n) { string ans; bool ok = false; int d, p = pow(k, 8); while (p > 0) { d = n / p; n = n % p; if (!ok) { if (d != 0) { ok = true; } } if (ok) { ans += to_string(d); } p /= k; } return ans; } int main(void) { ios ::sync_with_stdio(0); cin.tie(0); cin >> k; for (int i = 1; i <= k - 1; ++i) { for (int j = 1; j <= k - 1; ++j) { cout << solve(i * j) << " "; } cout << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; int n; char z[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; string turn(int x) { string a = ""; while (x) a = z[x % n] + a, x /= n; return a; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) cout << turn(i * j) << ' '; cout << endl; } return 0; }
#include <bits/stdc++.h> std::vector<std::string> ar[10]; std::string get(int v, int k) { std::string re; while (v) { re += (char)(v % k + '0'); v /= k; } return re; } int main() { int n; scanf("%d", &n); for (int i = 1; i < n; ++i) for (int j = 1; j < n; ++j) ar[i].push_back(get(i * j, n)); int sz[10] = {0}; for (int i = 1; i < n; ++i) for (int j = 0; j < ar[i].size(); ++j) if (ar[i][j].size() > sz[j]) sz[j] = ar[i][j].size(); for (int i = 1; i < n; ++i) { for (int j = 0; j < ar[i].size(); ++j) { if (j) putchar(' '); if (ar[i][j].size() == sz[j]) { for (int k = sz[j] - 1; k >= 0; --k) std::cout << ar[i][j][k]; } else std::cout << " " << ar[i][j][0]; } puts(""); } return 0; }
#include <bits/stdc++.h> using namespace std; void change(int n, int k, int kk) { int a[100], cnt = 0; int i; while (n) { a[cnt++] = n % k; n /= k; } if (cnt == 0) { a[cnt++] = 0; } for (i = 1; i <= kk - cnt; i++) { printf(" "); } for (i = cnt - 1; i >= 0; i--) { printf("%d", a[i]); } } int get_len(int a, int b) { int res = 0; while (a) { a /= b; res++; } if (res == 0) res = 1; return res; } int main() { int i, j, k; int n; while (scanf("%d", &n) != EOF) { for (i = 1; i < n; i++) { for (j = 1; j < n; j++) { int kk = (n - 1) * j; kk = get_len(kk, n); if (j > 1) printf(" "); change(i * j, n, kk); } putchar('\n'); } } return 0; }
#include <bits/stdc++.h> using namespace std; template <class T> inline T euclide(T a, T b, T& x, T& y) { if (a < 0) { T d = euclide(-a, b, x, y); x = -x; return d; } if (b < 0) { T d = euclide(a, -b, x, y); y = -y; return d; } if (b == 0) { x = 1; y = 0; return a; } else { T d = euclide(b, a % b, x, y); T t = x; x = y; y = t - (a / b) * y; return d; } } template <class T> inline void checkmin(T& a, T b) { if (b < a) a = b; } template <class T> inline void checkmax(T& a, T b) { if (b > a) a = b; } template <class T> T Abs(T x) { return x > 0 ? x : -x; } template <class T> inline T sqr(T x) { return x * x; } template <class T> inline bool isPrime(T n) { if (n <= 1) return false; for (T i = 2; i * i <= n; i++) if (n % i == 0) return false; return true; } template <class T> inline T Mod(T n, T m) { return (n % m + m) % m; } template <class T> string toString(T n) { ostringstream oss; oss << n; oss.flush(); return oss.str(); } int toInt(string s) { int r = 0; istringstream sin(s); sin >> r; return r; } long long toLl(string s) { long long r = 0; istringstream sin(s); sin >> r; return r; } template <class T> void debug(const T& e) { cout << e << endl; } template <class T1, class T2> void debug(const T1& e1, const T2& e2) { cout << e1 << "\t" << e2 << endl; } template <class T1, class T2, class T3> void debug(const T1& e1, const T2& e2, const T3& e3) { cout << e1 << "\t" << e2 << "\t" << e3 << endl; } template <class T1, class T2, class T3, class T4> void debug(const T1& e1, const T2& e2, const T3& e3, const T4& e4) { cout << e1 << "\t" << e2 << "\t" << e3 << "\t" << e4 << endl; } template <class T1, class T2, class T3, class T4, class T5> void debug(const T1& e1, const T2& e2, const T3& e3, const T4& e4, const T5& e5) { cout << e1 << "\t" << e2 << "\t" << e3 << "\t" << e4 << "\t" << e5 << endl; } template <class T> void debug(vector<T>& e) { int i; for (i = 0; i < (int)e.size(); i++) cout << e[i] << " "; cout << endl; } template <class T> void debug(vector<basic_string<T> >& e) { int i, j; for (i = 0; i < (int)e.size(); i++) { for (j = 0; j < (int)e[i].size(); j++) cout << e[i][j]; cout << endl; } cout << endl; } template <class T> void debug(vector<vector<T> >& e, int row, int col) { int i, j; for (i = 0; i < row; i++) { for (j = 0; j < col; j++) cout << e[i][j] << "\t"; cout << endl; } cout << endl; } template <class T> void debug(T e[100][100], int row, int col) { int i, j; for (i = 0; i < row; i++) { for (j = 0; j < col; j++) cout << e[i][j] << " "; cout << endl; } } template <class T> void debug(T e[], int row) { int i; for (i = 0; i < row; i++) cout << e[i] << " "; cout << endl; } long long Pow(int B, int P) { long long R = 1; while (P > 0) { if (P % 2 == 1) R = (R * B); P /= 2; B = (B * B); } return R; } int BigMod(long long B, long long P, long long M) { long long R = 1; while (P > 0) { if (P % 2 == 1) { R = (R * B) % M; } P /= 2; B = (B * B) % M; } return (int)R; } long long mulmod(long long a, long long b, long long c) { long long x = 0, y = a % c; while (b > 0) { if (b % 2 == 1) { x = (x + y) % c; } y = (y * 2) % c; b /= 2; } return x % c; } void binprint(int mask, int n) { int i; string s = ""; do { s += (mask % 2 + '0'); mask /= 2; } while (mask); reverse(s.begin(), s.end()); s = string(max(n - (int)s.size(), 0), '0') + s; for (i = (int)s.size() - n; i < (int)s.size(); i++) printf("%c", s[i]); printf("\n"); } int convert(int num, int base) { string str = ""; while (num) { str += num % base + '0'; num /= base; } reverse(str.begin(), str.end()); return toInt(str); } int main() { int i, j, test, Case = 1, k; while (scanf("%d", &k) == 1) { for (i = 1; i < k; i++) { for (j = 1; j < k; j++) printf("%d ", convert(i * j, k)); printf("\n"); } } return 0; }
#include <bits/stdc++.h> using namespace std; void ra(int n, int k) { char numero[100]; int j, i = 0; while (n != 0) { numero[i++] = n % k + 48; n /= k; } i--; numero[i + 1] = '\0'; char resposta[100]; for (j = i; j >= 0; j--) { resposta[i - j] = numero[j]; } resposta[i + 1] = '\0'; cout << resposta << " "; } int main() { int i, j, n; cin >> n; for (i = 1; i < n; i++) { for (j = 1; j < n; j++) { ra(i * j, n); } cout << endl; } }
#include <bits/stdc++.h> using namespace std; int n, p[100005]; void kkk(int x, int k) { int cnt = 0; while (x) { p[++cnt] = x % k; x /= k; } for (int i = cnt; i >= 1; i--) { printf("%d", p[i]); } } int main(void) { scanf("%d", &n); for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { kkk(i * j, n); printf(" "); } puts(""); } return 0; }
#include <bits/stdc++.h> using namespace std; int n; int pr(int p, int q) { return p * q / n * 10 + p * q % n; } int main() { cin >> n; for (int i = 1; i < n; i++) for (int j = 1; j < n; j++) { cout << pr(i, j); if (j == n - 1) cout << "\n"; else cout << " "; } return 0; }
#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; if (x != 10) { 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"; } } else for (int i = 1; i < 10; i++) { for (int j = 1; j < 10; j++) cout << i * j << " "; cout << endl; } }
#include <bits/stdc++.h> using namespace std; int n; void calc(int x) { vector<int> v; while (x) { v.push_back(x % n); x /= n; } for (int i = v.size() - 1; i >= 0; i--) cout << v[i]; cout << " "; } int main() { ios_base::sync_with_stdio(false); cin >> n; for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) calc(i * j); cout << endl; } return -0; }
#include <bits/stdc++.h> using namespace std; int x[11][11]; int wei[100]; int get(int a, int k) { int ans = 0; int cnt = 0; while (a) { wei[cnt++] = (a % k); a /= k; } for (int i = cnt - 1; i >= 0; i--) { ans = ans * 10 + wei[i]; } return ans; } int main() { for (int i = 1; i < 10; i++) for (int j = 1; j < 10; j++) { x[i][j] = i * j; } int k; cin >> k; for (int i = 1; i < k; i++) { for (int j = 1; j < k; j++) cout << get(x[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 = 0; j < k; j++) { int w = i * j; string s; while (w > 0) { s = (char)(w % k + '0') + s; w /= k; } cout << s << " "; } cout << endl; } return 0; }