Закинул ещё мусора с Интеллекта, наверное это последнее
This commit is contained in:
@@ -3,7 +3,7 @@ import zlib, json
|
||||
#n = int(input()) # Лучше не смотреть на это НЕ решение)
|
||||
#pool = list(map(int, input().split()))
|
||||
#ans = sum(pool)//2
|
||||
dis = {
|
||||
'''dis = {
|
||||
206: 207,
|
||||
155: 156,
|
||||
355: 360,
|
||||
@@ -13,6 +13,9 @@ dis = {
|
||||
464: 465,
|
||||
54: 103,
|
||||
311: 343
|
||||
}'''
|
||||
dis = {
|
||||
|
||||
}
|
||||
print(json.dumps(dis))
|
||||
print(json.loads(json.dumps(dis)))
|
||||
|
||||
9
uts/uts_17_aut_py/4/A.py
Normal file
9
uts/uts_17_aut_py/4/A.py
Normal file
@@ -0,0 +1,9 @@
|
||||
n, k, x = list(map(int, input().split()))
|
||||
from itertools import combinations_with_replacement
|
||||
cnt = 0
|
||||
for i in combinations_with_replacement(range(1, n+1), k):
|
||||
if cnt == x:
|
||||
for j in i:
|
||||
print(j, end=' ')
|
||||
break
|
||||
cnt += 1
|
||||
9
uts/uts_17_aut_py/4/B.py
Normal file
9
uts/uts_17_aut_py/4/B.py
Normal file
@@ -0,0 +1,9 @@
|
||||
n, k = list(map(int, input().split()))
|
||||
find = tuple(map(int, input().split()))
|
||||
from itertools import combinations_with_replacement
|
||||
cnt = 0
|
||||
for i in combinations_with_replacement(range(1, n+1), k):
|
||||
if i == find:
|
||||
print(cnt)
|
||||
break
|
||||
cnt += 1
|
||||
6
uts/uts_17_aut_py/4/C.py
Normal file
6
uts/uts_17_aut_py/4/C.py
Normal file
@@ -0,0 +1,6 @@
|
||||
le, de = list(map(int, input().split()))
|
||||
de = bin(de)[2:]
|
||||
if len(de) < le:
|
||||
de = ('0'*(le - len(de))) + de
|
||||
|
||||
print(de)
|
||||
47
uts/uts_17_aut_py/FoxNewBot/main.py
Normal file
47
uts/uts_17_aut_py/FoxNewBot/main.py
Normal file
@@ -0,0 +1,47 @@
|
||||
from telegram.ext import Updater
|
||||
updater = Updater(token='462381555:AAGpyrfrkxt0_uitj-z4ZFUMDMfQt0MdZhY')
|
||||
|
||||
dispatcher = updater.dispatcher
|
||||
import sqlite3
|
||||
database_connector = sqlite3.connect
|
||||
DATABASE = 'sq.sql'
|
||||
import logging
|
||||
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
||||
level=logging.INFO)
|
||||
|
||||
|
||||
def start(bot, update):
|
||||
conn = database_connector(DATABASE)
|
||||
conn.execute('INSERT INTO Users VALUES (:user_id, :us)', {"user_id": update.message.chat_id, "us": 'User'})
|
||||
conn.commit()
|
||||
conn.close()
|
||||
bot.send_message(chat_id=update.message.chat_id, text="Вы успешно подписались на новости Лисьего Носа!")
|
||||
print(update.message.chat_id)
|
||||
|
||||
DEBUG = True
|
||||
def send(bot, update):
|
||||
if update.message.chat_id != 130703270:
|
||||
return
|
||||
conn = database_connector(DATABASE)
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('SELECT user_id FROM Users')
|
||||
for i in cursor.fetchall():
|
||||
if DEBUG:
|
||||
bot.send_message(chat_id=int(i[0]), text=update.message.text[5:])
|
||||
else:
|
||||
bot.send_message(chat_id=130703270, text=update.message.text[5:])
|
||||
conn.close()
|
||||
print('yes')
|
||||
|
||||
def kot(bot, update):
|
||||
bot.send_message(chat_id=update.message.chat_id, photo=open('test.png', 'rb'))
|
||||
|
||||
from telegram.ext import CommandHandler
|
||||
|
||||
start_handler = CommandHandler('start', start)
|
||||
|
||||
dispatcher.add_handler(start_handler)
|
||||
dispatcher.add_handler(CommandHandler('send', send))
|
||||
dispatcher.add_handler(CommandHandler('kot', kot))
|
||||
|
||||
updater.start_polling()
|
||||
2
uts/uts_17_aut_py/FoxNewBot/requirements.txt
Normal file
2
uts/uts_17_aut_py/FoxNewBot/requirements.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
python-telegram-bot
|
||||
|
||||
13
uts/uts_17_aut_py/lal/i-v3.py
Normal file
13
uts/uts_17_aut_py/lal/i-v3.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import math
|
||||
|
||||
n = 10000000
|
||||
|
||||
a = [True] * n
|
||||
|
||||
for i in range(2, int(math.sqrt(n))):
|
||||
for j in range(i * 2, n, i):
|
||||
a[j] = False
|
||||
b = [i for i in range(2, n) if a[i]]
|
||||
|
||||
#print(b)
|
||||
print(len(b))
|
||||
82
uts/uts_2017_aut_cpp/A.cpp
Normal file
82
uts/uts_2017_aut_cpp/A.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Andrey Odintsov
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
#define mp make_pair
|
||||
#define pb push_back
|
||||
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0)
|
||||
#define FILE_IO(x) freopen((string(x) + ".in").c_str(), "r", stdin); freopen((string(x) + ".out").c_str(), "w", stdout)
|
||||
#define sz(x) ((int)((x).size()))
|
||||
#define len(x) ((int)((x).length()))
|
||||
#define x first
|
||||
#define y second
|
||||
#define foreach(it, v) for (auto it : v)
|
||||
#define rep(it, n) for (int it = 0; it < n; ++it)
|
||||
#define forin(it, l, r) for (int it = l; it < r; ++it)
|
||||
#define all(x) x.begin(), x.end()
|
||||
|
||||
typedef long long ll;
|
||||
typedef unsigned long long ull;
|
||||
typedef long double ld;
|
||||
typedef pair<int, int> pii;
|
||||
typedef pair<ll, ll> pll;
|
||||
const int INF = (1 << 31) - 1;
|
||||
const ll LINF = (1ll << 63) - 1;
|
||||
const double DINF = numeric_limits<double>::infinity();
|
||||
const int MOD = 1e9 + 7;
|
||||
const double EPS = 1e-7;
|
||||
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
|
||||
mt19937 mmtw(MOD);
|
||||
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }
|
||||
template <class T> T arr_max(T a[], int n) { T res = a[0]; for (int i = 1; i < n; ++i) if (a[i] > res) res = a[i]; return res; }
|
||||
template <class T> T arr_min(T a[], int n) { T res = a[0]; for (int i = 1; i < n; ++i) if (a[i] < res) res = a[i]; return res; }
|
||||
template <class T> T binpow(T n, T k) {if (k == 1) return n; if (k & 1) return binpow(n, k - 1) * n; T a = binpow(n, k / 2); return a * a;}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ll n, k, x;
|
||||
ll a[35];
|
||||
ll dp[35][35];
|
||||
|
||||
int main() {
|
||||
cin >> n >> k >> x;
|
||||
|
||||
forin(i, 1, 35) {
|
||||
dp[1][i] = 1;
|
||||
}
|
||||
|
||||
for (int i = 2; i <= k; ++i) {
|
||||
for (int j = 1; j <= n; ++j) {
|
||||
for (int k = j; k <= n; ++k) {
|
||||
dp[i][j] += dp[i - 1][k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (n == 1) {
|
||||
cout << 1 << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
a[0] = 1;
|
||||
|
||||
|
||||
forin(i, 1, k + 1) {
|
||||
for (int val = a[i - 1]; val <= n; ++val) {
|
||||
// cout << x << " " << val << " " << dp[k - i + 1][val] << endl;
|
||||
if (x < dp[k - i + 1][val]) {
|
||||
a[i] = val;
|
||||
break;
|
||||
} else {
|
||||
x -= dp[k - i + 1][val];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
forin(i, 1, k + 1) {
|
||||
cout << a[i] << " ";
|
||||
}
|
||||
cout << endl;
|
||||
return 0;
|
||||
}
|
||||
78
uts/uts_2017_aut_cpp/B.cpp
Normal file
78
uts/uts_2017_aut_cpp/B.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Andrey Odintsov
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
#define mp make_pair
|
||||
#define pb push_back
|
||||
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0)
|
||||
#define FILE_IO(x) freopen((string(x) + ".in").c_str(), "r", stdin); freopen((string(x) + ".out").c_str(), "w", stdout)
|
||||
#define sz(x) ((int)((x).size()))
|
||||
#define len(x) ((int)((x).length()))
|
||||
#define x first
|
||||
#define y second
|
||||
#define foreach(it, v) for (auto it : v)
|
||||
#define rep(it, n) for (int it = 0; it < n; ++it)
|
||||
#define forin(it, l, r) for (int it = l; it < r; ++it)
|
||||
#define all(x) x.begin(), x.end()
|
||||
|
||||
typedef long long ll;
|
||||
typedef unsigned long long ull;
|
||||
typedef long double ld;
|
||||
typedef pair<int, int> pii;
|
||||
typedef pair<ll, ll> pll;
|
||||
const int INF = (1 << 31) - 1;
|
||||
const ll LINF = (1ll << 63) - 1;
|
||||
const double DINF = numeric_limits<double>::infinity();
|
||||
const int MOD = 1e9 + 7;
|
||||
const double EPS = 1e-7;
|
||||
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
|
||||
mt19937 mmtw(MOD);
|
||||
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }
|
||||
template <class T> T arr_max(T a[], int n) { T res = a[0]; for (int i = 1; i < n; ++i) if (a[i] > res) res = a[i]; return res; }
|
||||
template <class T> T arr_min(T a[], int n) { T res = a[0]; for (int i = 1; i < n; ++i) if (a[i] < res) res = a[i]; return res; }
|
||||
template <class T> T binpow(T n, T k) {if (k == 1) return n; if (k & 1) return binpow(n, k - 1) * n; T a = binpow(n, k / 2); return a * a;}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ll n, k, x;
|
||||
ll a[35];
|
||||
ll dp[35][35];
|
||||
|
||||
int main() {
|
||||
cin >> n >> k;
|
||||
|
||||
forin(i, 1, k + 1) {
|
||||
cin >> a[i];
|
||||
}
|
||||
|
||||
forin(i, 1, 35) {
|
||||
dp[1][i] = 1;
|
||||
}
|
||||
|
||||
for (int i = 2; i <= k; ++i) {
|
||||
for (int j = 1; j <= n; ++j) {
|
||||
for (int q = j; q <= n; ++q) {
|
||||
dp[i][j] += dp[i - 1][q];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (n == 1) {
|
||||
cout << 0 << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
a[0] = 1;
|
||||
|
||||
|
||||
forin(i, 1, k + 1) {
|
||||
for (int val = a[i - 1]; val < a[i]; ++val) {
|
||||
// cout << i + 1 << " " << val << " " << dp[k - i - 1][val] << endl;
|
||||
x += dp[k - i + 1][val];
|
||||
}
|
||||
}
|
||||
|
||||
cout << x << endl;
|
||||
return 0;
|
||||
}
|
||||
68
uts/uts_2017_aut_cpp/C.cpp
Normal file
68
uts/uts_2017_aut_cpp/C.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Andrey Odintsov
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
#define mp make_pair
|
||||
#define pb push_back
|
||||
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0)
|
||||
#define FILE_IO(x) freopen((string(x) + ".in").c_str(), "r", stdin); freopen((string(x) + ".out").c_str(), "w", stdout)
|
||||
#define sz(x) ((int)((x).size()))
|
||||
#define len(x) ((int)((x).length()))
|
||||
#define x first
|
||||
#define y second
|
||||
#define foreach(it, v) for (auto it : v)
|
||||
#define rep(it, n) for (int it = 0; it < n; ++it)
|
||||
#define forin(it, l, r) for (int it = l; it < r; ++it)
|
||||
#define all(x) x.begin(), x.end()
|
||||
|
||||
typedef long long ll;
|
||||
typedef unsigned long long ull;
|
||||
typedef long double ld;
|
||||
typedef pair<int, int> pii;
|
||||
typedef pair<ll, ll> pll;
|
||||
const int INF = (1 << 31) - 1;
|
||||
const ll LINF = (1ll << 63) - 1;
|
||||
const double DINF = numeric_limits<double>::infinity();
|
||||
const int MOD = 1e9 + 7;
|
||||
const double EPS = 1e-7;
|
||||
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
|
||||
mt19937 mmtw(MOD);
|
||||
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }
|
||||
template <class T> T arr_max(T a[], int n) { T res = a[0]; for (int i = 1; i < n; ++i) if (a[i] > res) res = a[i]; return res; }
|
||||
template <class T> T arr_min(T a[], int n) { T res = a[0]; for (int i = 1; i < n; ++i) if (a[i] < res) res = a[i]; return res; }
|
||||
template <class T> T binpow(T n, T k) {if (k == 1) return n; if (k & 1) return binpow(n, k - 1) * n; T a = binpow(n, k / 2); return a * a;}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const int MAXN = 50;
|
||||
ll n, k;
|
||||
ll dp[MAXN][2];
|
||||
int a[MAXN];
|
||||
|
||||
int main() {
|
||||
cin >> n >> k;
|
||||
|
||||
dp[1][0] = 1;
|
||||
dp[1][1] = 1;
|
||||
|
||||
forin(i, 2, 50) {
|
||||
dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
|
||||
dp[i][1] = dp[i - 1][0];
|
||||
}
|
||||
|
||||
rep(i, n) {
|
||||
if (dp[n - i][0] > k) {
|
||||
a[i] = 0;
|
||||
} else {
|
||||
k -= dp[n - i][0];
|
||||
a[i] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
rep(i, n) {
|
||||
cout << a[i];
|
||||
}
|
||||
cout << endl;
|
||||
return 0;
|
||||
}
|
||||
70
uts/uts_2017_aut_cpp/D.cpp
Normal file
70
uts/uts_2017_aut_cpp/D.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Andrey Odintsov
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
#define mp make_pair
|
||||
#define pb push_back
|
||||
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0)
|
||||
#define FILE_IO(x) freopen((string(x) + ".in").c_str(), "r", stdin); freopen((string(x) + ".out").c_str(), "w", stdout)
|
||||
#define sz(x) ((int)((x).size()))
|
||||
#define len(x) ((int)((x).length()))
|
||||
#define x first
|
||||
#define y second
|
||||
#define foreach(it, v) for (auto it : v)
|
||||
#define rep(it, n) for (int it = 0; it < n; ++it)
|
||||
#define forin(it, l, r) for (int it = l; it < r; ++it)
|
||||
#define all(x) x.begin(), x.end()
|
||||
|
||||
typedef long long ll;
|
||||
typedef unsigned long long ull;
|
||||
typedef long double ld;
|
||||
typedef pair<int, int> pii;
|
||||
typedef pair<ll, ll> pll;
|
||||
const int INF = (1 << 31) - 1;
|
||||
const ll LINF = (1ll << 63) - 1;
|
||||
const double DINF = numeric_limits<double>::infinity();
|
||||
const int MOD = 1e9 + 7;
|
||||
const double EPS = 1e-7;
|
||||
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
|
||||
mt19937 mmtw(MOD);
|
||||
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }
|
||||
template <class T> T arr_max(T a[], int n) { T res = a[0]; for (int i = 1; i < n; ++i) if (a[i] > res) res = a[i]; return res; }
|
||||
template <class T> T arr_min(T a[], int n) { T res = a[0]; for (int i = 1; i < n; ++i) if (a[i] < res) res = a[i]; return res; }
|
||||
template <class T> T binpow(T n, T k) {if (k == 1) return n; if (k & 1) return binpow(n, k - 1) * n; T a = binpow(n, k / 2); return a * a;}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const int MAXN = 100;
|
||||
|
||||
ll n, k, bal;
|
||||
ll dp[MAXN][MAXN];
|
||||
string res;
|
||||
|
||||
int main() {
|
||||
cin >> n >> k;
|
||||
n *= 2;
|
||||
|
||||
dp[0][0] = 1;
|
||||
for (int i = 1; i < 100; ++i) {
|
||||
for (int j = 1; j < 100; ++j) {
|
||||
dp[i][j] += dp[i - 1][j - 1];
|
||||
}
|
||||
for (int j = 0; j < 99; ++j) {
|
||||
dp[i][j] += dp[i - 1][j + 1];
|
||||
}
|
||||
}
|
||||
|
||||
rep(i, n) {
|
||||
if (k < dp[n - i - 1][bal + 1]) {
|
||||
bal++;
|
||||
res.push_back('(');
|
||||
} else {
|
||||
k -= dp[n - i - 1][bal + 1];
|
||||
bal--;
|
||||
res.push_back(')');
|
||||
}
|
||||
}
|
||||
cout << res << endl;
|
||||
return 0;
|
||||
}
|
||||
69
uts/uts_2017_aut_cpp/E.cpp
Normal file
69
uts/uts_2017_aut_cpp/E.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Andrey Odintsov
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
#define mp make_pair
|
||||
#define pb push_back
|
||||
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0)
|
||||
#define FILE_IO(x) freopen((string(x) + ".in").c_str(), "r", stdin); freopen((string(x) + ".out").c_str(), "w", stdout)
|
||||
#define sz(x) ((int)((x).size()))
|
||||
#define len(x) ((int)((x).length()))
|
||||
#define x first
|
||||
#define y second
|
||||
#define foreach(it, v) for (auto it : v)
|
||||
#define rep(it, n) for (int it = 0; it < n; ++it)
|
||||
#define forin(it, l, r) for (int it = l; it < r; ++it)
|
||||
#define all(x) x.begin(), x.end()
|
||||
|
||||
typedef long long ll;
|
||||
typedef unsigned long long ull;
|
||||
typedef long double ld;
|
||||
typedef pair<int, int> pii;
|
||||
typedef pair<ll, ll> pll;
|
||||
const int INF = (1 << 31) - 1;
|
||||
const ll LINF = (1ll << 63) - 1;
|
||||
const double DINF = numeric_limits<double>::infinity();
|
||||
const int MOD = 1e9 + 7;
|
||||
const double EPS = 1e-7;
|
||||
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
|
||||
mt19937 mmtw(MOD);
|
||||
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }
|
||||
template <class T> T arr_max(T a[], int n) { T res = a[0]; for (int i = 1; i < n; ++i) if (a[i] > res) res = a[i]; return res; }
|
||||
template <class T> T arr_min(T a[], int n) { T res = a[0]; for (int i = 1; i < n; ++i) if (a[i] < res) res = a[i]; return res; }
|
||||
template <class T> T binpow(T n, T k) {if (k == 1) return n; if (k & 1) return binpow(n, k - 1) * n; T a = binpow(n, k / 2); return a * a;}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const int MAXN = 100;
|
||||
|
||||
ll n, bal;
|
||||
ll dp[MAXN][MAXN];
|
||||
string s;
|
||||
ll res;
|
||||
|
||||
int main() {
|
||||
cin >> n >> s;
|
||||
n *= 2;
|
||||
|
||||
dp[0][0] = 1;
|
||||
for (int i = 1; i < 100; ++i) {
|
||||
for (int j = 1; j < 100; ++j) {
|
||||
dp[i][j] += dp[i - 1][j - 1];
|
||||
}
|
||||
for (int j = 0; j < 99; ++j) {
|
||||
dp[i][j] += dp[i - 1][j + 1];
|
||||
}
|
||||
}
|
||||
|
||||
rep(i, n) {
|
||||
if (s[i] == '(') {
|
||||
bal++;
|
||||
} else {
|
||||
res += dp[n - i - 1][bal + 1];
|
||||
bal--;
|
||||
}
|
||||
}
|
||||
cout << res << endl;
|
||||
return 0;
|
||||
}
|
||||
92
uts/uts_2017_aut_cpp/F.cpp
Normal file
92
uts/uts_2017_aut_cpp/F.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Andrey Odintsov
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
#define mp make_pair
|
||||
#define pb push_back
|
||||
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0)
|
||||
#define FILE_IO(x) freopen((string(x) + ".in").c_str(), "r", stdin); freopen((string(x) + ".out").c_str(), "w", stdout)
|
||||
#define sz(x) ((int)((x).size()))
|
||||
#define len(x) ((int)((x).length()))
|
||||
#define x first
|
||||
#define y second
|
||||
#define foreach(it, v) for (auto it : v)
|
||||
#define rep(it, n) for (int it = 0; it < n; ++it)
|
||||
#define forin(it, l, r) for (int it = l; it < r; ++it)
|
||||
#define all(x) x.begin(), x.end()
|
||||
#define log(x) cout << #x << " = " << x << endl;
|
||||
|
||||
typedef long long ll;
|
||||
typedef unsigned long long ull;
|
||||
typedef long double ld;
|
||||
typedef pair<int, int> pii;
|
||||
typedef pair<ll, ll> pll;
|
||||
const int INF = (1 << 31) - 1;
|
||||
const ll LINF = (1ll << 63) - 1;
|
||||
const double DINF = numeric_limits<double>::infinity();
|
||||
const int MOD = 1e9 + 7;
|
||||
const double EPS = 1e-7;
|
||||
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
|
||||
mt19937 mmtw(MOD);
|
||||
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }
|
||||
template <class T> T arr_max(T a[], int n) { T res = a[0]; for (int i = 1; i < n; ++i) if (a[i] > res) res = a[i]; return res; }
|
||||
template <class T> T arr_min(T a[], int n) { T res = a[0]; for (int i = 1; i < n; ++i) if (a[i] < res) res = a[i]; return res; }
|
||||
template <class T> T binpow(T n, T k) {if (k == 1) return n; if (k & 1) return binpow(n, k - 1) * n; T a = binpow(n, k / 2); return a * a;}
|
||||
template <class T> T fact(T n) {if (n == 1) return 1; return n * fact(n - 1);}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const int MAXN = 105;
|
||||
ll n, k;
|
||||
ll dp[MAXN][MAXN]; // dp[sum][first_digit]
|
||||
vector <int> res;
|
||||
|
||||
int main() {
|
||||
cin >> n >> k;
|
||||
|
||||
for (int i = 1; i < 105; ++i) { // sum
|
||||
for (int j = 1; j < i; ++j) { // first digit
|
||||
for (int k = j; k < 105; ++k) { // second digit
|
||||
dp[i][j] += dp[i - j][k];
|
||||
}
|
||||
}
|
||||
dp[i][i] = 1;
|
||||
}
|
||||
|
||||
if (n == 0 && k != 0) {
|
||||
cout << "N/A" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ll sm = 0;
|
||||
for (int i = 1; i <= n; ++i) {
|
||||
sm += dp[n][i];
|
||||
}
|
||||
if (k >= sm && n != 0) {
|
||||
cout << "N/A" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ll last = 1;
|
||||
|
||||
while (n) {
|
||||
for (int i = last; i <= n; ++i) {
|
||||
// cout << "dp[" << n << "][" << i << "] = " << dp[n][i] << endl;
|
||||
if (k < dp[n][i]) {
|
||||
n -= i;
|
||||
res.push_back(i);
|
||||
last = i;
|
||||
break;
|
||||
} else {
|
||||
k -= dp[n][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
cout << sz(res) << endl;
|
||||
rep(i, sz(res)) {
|
||||
cout << res[i] << " ";
|
||||
}
|
||||
cout << endl;
|
||||
return 0;
|
||||
}
|
||||
78
uts/uts_2017_aut_cpp/G.cpp
Normal file
78
uts/uts_2017_aut_cpp/G.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Andrey Odintsov
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
#define mp make_pair
|
||||
#define pb push_back
|
||||
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0)
|
||||
#define FILE_IO(x) freopen((string(x) + ".in").c_str(), "r", stdin); freopen((string(x) + ".out").c_str(), "w", stdout)
|
||||
#define sz(x) ((int)((x).size()))
|
||||
#define len(x) ((int)((x).length()))
|
||||
#define x first
|
||||
#define y second
|
||||
#define foreach(it, v) for (auto it : v)
|
||||
#define rep(it, n) for (int it = 0; it < n; ++it)
|
||||
#define forin(it, l, r) for (int it = l; it < r; ++it)
|
||||
#define all(x) x.begin(), x.end()
|
||||
|
||||
typedef long long ll;
|
||||
typedef unsigned long long ull;
|
||||
typedef long double ld;
|
||||
typedef pair<int, int> pii;
|
||||
typedef pair<ll, ll> pll;
|
||||
const int INF = (1 << 31) - 1;
|
||||
const ll LINF = (1ll << 63) - 1;
|
||||
const double DINF = numeric_limits<double>::infinity();
|
||||
const int MOD = 1e9 + 7;
|
||||
const double EPS = 1e-7;
|
||||
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
|
||||
mt19937 mmtw(MOD);
|
||||
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }
|
||||
template <class T> T arr_max(T a[], int n) { T res = a[0]; for (int i = 1; i < n; ++i) if (a[i] > res) res = a[i]; return res; }
|
||||
template <class T> T arr_min(T a[], int n) { T res = a[0]; for (int i = 1; i < n; ++i) if (a[i] < res) res = a[i]; return res; }
|
||||
template <class T> T binpow(T n, T k) {if (k == 1) return n; if (k & 1) return binpow(n, k - 1) * n; T a = binpow(n, k / 2); return a * a;}
|
||||
template <class T> T fact(T n) {if (n == 1) return 1; return n * fact(n - 1);}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ll n, k;
|
||||
|
||||
vector <int> res;
|
||||
vector <int> not_used;
|
||||
|
||||
int main() {
|
||||
cin >> n >> k;
|
||||
if (k > fact(n) || k <= 0) {
|
||||
cout << "INVALID number." << endl;
|
||||
return 0;
|
||||
}
|
||||
k--;
|
||||
if (n == 1) {
|
||||
cout << 1 << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (int i = 1; i <= n; ++i) {
|
||||
not_used.push_back(i);
|
||||
}
|
||||
ll size = fact(n - 1);
|
||||
rep(i, n) {
|
||||
ll cnt = k / size;
|
||||
if (cnt > sz(not_used)) {
|
||||
cnt = sz(not_used) - 1;
|
||||
}
|
||||
res.push_back(not_used[cnt]);
|
||||
not_used.erase(not_used.begin() + cnt);
|
||||
k %= size;
|
||||
if (i != n - 1) {
|
||||
size = size / (n - i - 1);
|
||||
}
|
||||
}
|
||||
|
||||
rep(i, n) {
|
||||
cout << res[i] << " ";
|
||||
}
|
||||
cout << endl;
|
||||
return 0;
|
||||
}
|
||||
72
uts/uts_2017_aut_cpp/H.cpp
Normal file
72
uts/uts_2017_aut_cpp/H.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Andrey Odintsov
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
#define mp make_pair
|
||||
#define pb push_back
|
||||
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0)
|
||||
#define FILE_IO(x) freopen((string(x) + ".in").c_str(), "r", stdin); freopen((string(x) + ".out").c_str(), "w", stdout)
|
||||
#define sz(x) ((int)((x).size()))
|
||||
#define len(x) ((int)((x).length()))
|
||||
#define x first
|
||||
#define y second
|
||||
#define foreach(it, v) for (auto it : v)
|
||||
#define rep(it, n) for (int it = 0; it < n; ++it)
|
||||
#define forin(it, l, r) for (int it = l; it < r; ++it)
|
||||
#define all(x) x.begin(), x.end()
|
||||
|
||||
typedef long long ll;
|
||||
typedef unsigned long long ull;
|
||||
typedef long double ld;
|
||||
typedef pair<int, int> pii;
|
||||
typedef pair<ll, ll> pll;
|
||||
const int INF = (1 << 31) - 1;
|
||||
const ll LINF = (1ll << 63) - 1;
|
||||
const double DINF = numeric_limits<double>::infinity();
|
||||
const int MOD = 1e9 + 7;
|
||||
const double EPS = 1e-7;
|
||||
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
|
||||
mt19937 mmtw(MOD);
|
||||
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }
|
||||
template <class T> T arr_max(T a[], int n) { T res = a[0]; for (int i = 1; i < n; ++i) if (a[i] > res) res = a[i]; return res; }
|
||||
template <class T> T arr_min(T a[], int n) { T res = a[0]; for (int i = 1; i < n; ++i) if (a[i] < res) res = a[i]; return res; }
|
||||
template <class T> T binpow(T n, T k) { if (k == 1) return n; if (k & 1) return binpow(n, k - 1) * n; T a = binpow(n, k / 2); return a * a; }
|
||||
template <class T> T fact(T n) { if (n == 1) return 1; return n * fact(n - 1); }
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const int MAXN = 25;
|
||||
ll n;
|
||||
ll a[MAXN];
|
||||
ll res;
|
||||
vector <ll> not_used;
|
||||
|
||||
int main() {
|
||||
cin >> n;
|
||||
rep(i, n) {
|
||||
cin >> a[i];
|
||||
}
|
||||
|
||||
if (n == 1) {
|
||||
cout << 1 << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (int i = 1; i <= n; ++i) {
|
||||
not_used.push_back(i);
|
||||
}
|
||||
|
||||
ll size = fact(n - 1);
|
||||
rep(i, n) {
|
||||
auto it = find(all(not_used), a[i]);
|
||||
res += size * (it - not_used.begin());
|
||||
not_used.erase(it);
|
||||
if (i != n - 1) {
|
||||
size = size / (n - i - 1);
|
||||
}
|
||||
}
|
||||
|
||||
cout << res + 1 << endl;
|
||||
return 0;
|
||||
}
|
||||
0
uts/uts_2017_aut_cpp/main-1.cpp
Normal file
0
uts/uts_2017_aut_cpp/main-1.cpp
Normal file
@@ -1,48 +1,49 @@
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void comb(unsigned int N, unsigned int K, unsigned int stp)
|
||||
{
|
||||
string bitmask(K, 1);
|
||||
bitmask.resize((unsigned long)N, 0);
|
||||
unsigned int carl = 0;
|
||||
do {
|
||||
for (int i = 0; i < N; ++i)
|
||||
{
|
||||
if (bitmask[i]) { cout << " " << i; }
|
||||
}
|
||||
cout << endl;
|
||||
carl++;
|
||||
} while (prev_permutation(bitmask.begin(), bitmask.end()));
|
||||
}
|
||||
|
||||
int compare(const void * x1, const void * x2)
|
||||
{
|
||||
return ( *(int*)x1 - *(int*)x2 );
|
||||
}
|
||||
|
||||
int main() {
|
||||
unsigned long long n, b, p;
|
||||
cin >> n >> b >> p;
|
||||
unsigned long long a[n];
|
||||
for (long i = 0; i < n; i++) {
|
||||
a[i] = (unsigned long long)pow(b, i+1) % p;
|
||||
unsigned long long n, na;
|
||||
//cin >> n;
|
||||
for (na = 1; na < 101; na++) {
|
||||
n = na;
|
||||
cout << na << ':' << '\n';
|
||||
if(n==1){
|
||||
cout << 1;
|
||||
//return 0;
|
||||
}
|
||||
unsigned long long ma;
|
||||
unsigned long long mi;
|
||||
long lastclean;
|
||||
for (long j = 0; j < n-1; j++) {
|
||||
mi = 10000000000;
|
||||
ma = 0;
|
||||
for (long i = 0; i < n; i++) {
|
||||
bool change = false;
|
||||
if (a[i] >= ma && a[i] != 10000000000) {
|
||||
ma = a[i];
|
||||
change = true;
|
||||
lastclean = i;
|
||||
}
|
||||
if (a[i] <= mi && a[i] != 10000000000) {
|
||||
mi = a[i];
|
||||
change = true;
|
||||
lastclean = i;
|
||||
}
|
||||
if (change) {
|
||||
a[i] = 10000000000;
|
||||
}
|
||||
for (unsigned long long i = 2; i*i <= n; i++) {
|
||||
while (n % i == 0) {
|
||||
cout << i << ' ';
|
||||
n = n / i;
|
||||
}
|
||||
a[lastclean] = (mi + ma) % p;
|
||||
cout << a[lastclean] << ' ';
|
||||
}
|
||||
//cout << '\n';
|
||||
//for (long i = 0; i < n; i++) {
|
||||
// cout << a[i] << ' ';
|
||||
//}
|
||||
if (n != 1) {
|
||||
cout << n << ' ';
|
||||
} cout << '\n'; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user