/** * Seed: Математика — вопросы для тестов * * Источники: * — 21 вопрос ЦТ/ЦЭ (общие) * — 32 вопроса ЦТ 2021, Вариант 1 (A1–A18 + B1–B14) * * Запуск: node src/db/seed-math.js (из папки backend/) */ const db = require('./db'); /* ── helpers ─────────────────────────────────────────────────────────── */ function getOrCreateTopic(subjectId, name) { const ex = db.prepare('SELECT id FROM topics WHERE subject_id=? AND LOWER(name)=LOWER(?)').get(subjectId, name); if (ex) return ex.id; return db.prepare('INSERT INTO topics (subject_id, name) VALUES (?,?)').run(subjectId, name).lastInsertRowid; } /* ── subject ─────────────────────────────────────────────────────────── */ const math = db.prepare("SELECT id FROM subjects WHERE slug='math'").get(); if (!math) { console.error('Subject "math" not found. Run migrate first.'); process.exit(1); } const SID = math.id; /* ═══════════════════════════════════════════════════════════════════════ Вопросы Поля: topic, difficulty, text, options[{text,correct}], explanation Необязательные: year (число), type ('single'|'multiple') ═══════════════════════════════════════════════════════════════════════ */ const questions = [ /* ══════════════════════════════════════════════════════════════════════ РАЗДЕЛ 1 — Общие задания ЦТ/ЦЭ ══════════════════════════════════════════════════════════════════════ */ { topic: 'Арифметика и степени', difficulty: 1, text: 'Вычислите: \\((-3)^2 - 2^3 + 1\\)', options: [ { text: '\\(2\\)', correct: true }, { text: '\\(4\\)', correct: false }, { text: '\\(0\\)', correct: false }, { text: '\\(-2\\)', correct: false }, { text: '\\(18\\)', correct: false }, ], explanation: '\\((-3)^2=9,\\;2^3=8.\\;9-8+1=2\\)', }, { topic: 'Словесные задачи', difficulty: 1, text: 'Толя купил 3 альбома и 5 карандашей. Стоимость альбома — 1 р. 20 к., карандаша — 25 к. Сколько копеек осталось у Толи после покупки, если всего у него было 6 р.?', options: [ { text: '115 к.', correct: true }, { text: '145 к.', correct: false }, { text: '110 к.', correct: false }, { text: '125 к.', correct: false }, { text: '275 к.', correct: false }, ], explanation: '3·120+5·25=360+125=485 к. Остаток: 600−485=115 к.', }, { topic: 'Теория чисел', difficulty: 1, text: 'Укажите формулу для нахождения делимого \\(n\\), если делитель равен 15, неполное частное \\(k\\), остаток 7:', options: [ { text: '\\(n=15k+7\\)', correct: true }, { text: '\\(n=15(k+7)\\)', correct: false }, { text: '\\(n=k+22\\)', correct: false }, { text: '\\(n=7k+15\\)', correct: false }, ], explanation: 'По теореме о делении с остатком: \\(n=d\\cdot q+r=15k+7\\)', }, { topic: 'Тригонометрия', difficulty: 1, text: 'Среди значений \\(-\\dfrac{\\pi}{6};\\;\\dfrac{\\pi}{4};\\;\\dfrac{\\pi}{3};\\;-\\dfrac{3\\pi}{2};\\;-6\\pi\\) укажите то, при котором \\(\\sin x=0\\):', options: [ { text: '\\(-6\\pi\\)', correct: true }, { text: '\\(-\\dfrac{\\pi}{6}\\)', correct: false }, { text: '\\(\\dfrac{\\pi}{4}\\)', correct: false }, { text: '\\(-\\dfrac{3\\pi}{2}\\)', correct: false }, ], explanation: '\\(\\sin(-6\\pi)=0\\), так как \\(-6\\pi\\) кратно \\(\\pi\\).', }, { topic: 'Квадратные уравнения', difficulty: 2, text: 'Укажите квадратное уравнение, произведение действительных корней которого равно 5:', options: [ { text: '\\(x^2-6x+5=0\\)', correct: true }, { text: '\\(x^2-4x+5=0\\)', correct: false }, { text: '\\(x^2-5x+6=0\\)', correct: false }, { text: '\\(x^2+5x=0\\)', correct: false }, ], explanation: 'По формуле Виета произведение корней \\(=c/a\\). Для \\(x^2-6x+5=0\\): \\(5/1=5\\). Корни: \\(x=1,\\;x=5\\).', }, { topic: 'Тригонометрия', difficulty: 2, text: 'Найдите значение выражения \\(\\dfrac{38}{\\pi}\\cdot\\arcsin(-1)-|-7|\\)', options: [ { text: '\\(-26\\)', correct: true }, { text: '\\(-16\\)', correct: false }, { text: '\\(-12\\)', correct: false }, { text: '\\(26\\)', correct: false }, ], explanation: '\\(\\arcsin(-1)=-\\dfrac{\\pi}{2}\\). Тогда: \\(\\dfrac{38}{\\pi}\\cdot(-\\dfrac{\\pi}{2})-7=-19-7=-26\\).', }, { topic: 'Квадратные уравнения', difficulty: 1, text: 'Найдите нули функции \\(f(x)=x^2+4x-5\\):', options: [ { text: '\\(x=-5\\) и \\(x=1\\)', correct: true }, { text: '\\(x=5\\) и \\(x=-1\\)', correct: false }, { text: '\\(x=5\\) и \\(x=1\\)', correct: false }, { text: '\\(x=-5\\) и \\(x=-1\\)', correct: false }, ], explanation: 'Дискриминант: \\(16+20=36\\). \\(x_{1,2}=\\dfrac{-4\\pm6}{2}\\). \\(x_1=-5,\\;x_2=1\\).', }, { topic: 'Тригонометрия', difficulty: 2, text: 'Найдите \\(\\operatorname{ctg}^2\\alpha\\), если \\(\\sin\\alpha=\\dfrac{1}{5}\\):', options: [ { text: '\\(24\\)', correct: true }, { text: '\\(\\frac{1}{24}\\)', correct: false }, { text: '\\(4\\)', correct: false }, { text: '\\(25\\)', correct: false }, ], explanation: '\\(\\cos^2\\alpha=1-\\tfrac{1}{25}=\\tfrac{24}{25}\\). \\(\\operatorname{ctg}^2\\alpha=\\dfrac{24/25}{1/25}=24\\).', }, { topic: 'Прогрессии', difficulty: 2, text: 'Пятый член геометрической прогрессии равен 48, шестой — 96. Найдите первый член:', options: [ { text: '\\(3\\)', correct: true }, { text: '\\(1\\)', correct: false }, { text: '\\(2\\)', correct: false }, { text: '\\(4\\)', correct: false }, ], explanation: '\\(q=96/48=2\\). \\(b_1=48/2^4=3\\).', }, { topic: 'Неравенства', difficulty: 2, text: 'Сколько целых решений имеет неравенство \\(-3\\le2-\\dfrac{3x-2}{2}<27\\,\\)?', options: [ { text: '\\(20\\)', correct: true }, { text: '\\(18\\)', correct: false }, { text: '\\(19\\)', correct: false }, { text: '\\(21\\)', correct: false }, ], explanation: 'Решение: \\(-15\\le x\\le4\\). Целые: от −15 до 4 → \\(4-(-15)+1=20\\) чисел.', }, { topic: 'Квадратные уравнения', difficulty: 1, text: 'Функция \\(f(x)=x^2+4x-5\\). Найдите сумму нулей функции.', options: [ { text: '\\(-4\\)', correct: true }, { text: '\\(4\\)', correct: false }, { text: '\\(-5\\)', correct: false }, { text: '\\(0\\)', correct: false }, ], explanation: 'По теореме Виета: \\(-b/a=-4\\).', }, { topic: 'Прогрессии', difficulty: 2, text: 'Найдите сумму всех натуральных чисел, кратных 9, которые больше 141, но меньше 170.', options: [ { text: '\\(459\\)', correct: true }, { text: '\\(468\\)', correct: false }, { text: '\\(315\\)', correct: false }, { text: '\\(414\\)', correct: false }, ], explanation: 'Числа: 144, 153, 162. Сумма: \\(144+153+162=459\\).', }, { topic: 'Геометрия', difficulty: 2, text: 'Радиус описанной окружности прямоугольного треугольника \\(ABC\\) (\\(\\angle ABC=90°\\)) равен \\(18\\sqrt{2}\\). Найдите \\(90\\cdot\\cos\\angle ACB\\), если \\(BC=6\\sqrt{2}\\).', options: [ { text: '\\(15\\)', correct: true }, { text: '\\(30\\)', correct: false }, { text: '\\(45\\)', correct: false }, { text: '\\(60\\)', correct: false }, ], explanation: '\\(AC=2R=36\\sqrt{2}\\). \\(\\cos\\angle ACB=\\dfrac{6\\sqrt{2}}{36\\sqrt{2}}=\\dfrac{1}{6}\\). Ответ: \\(15\\).', }, { topic: 'Словесные задачи', difficulty: 2, text: 'Проездной на месяц стоит 39 р., разовый — 80 к. 75% потраченной Машей суммы равны стоимости проездного. Сколько поездок она совершила?', options: [ { text: '65', correct: true }, { text: '52', correct: false }, { text: '75', correct: false }, { text: '60', correct: false }, ], explanation: '75% суммы=39 р. → сумма=52 р.=5200 к. Поездок: \\(5200/80=65\\).', }, { topic: 'Неравенства', difficulty: 2, text: 'Найдите сумму наименьшего и наибольшего целых решений неравенства \\(-3\\le2-\\dfrac{3x-2}{2}<27\\).', options: [ { text: '\\(-11\\)', correct: true }, { text: '\\(-10\\)', correct: false }, { text: '\\(-12\\)', correct: false }, { text: '\\(-14\\)', correct: false }, ], explanation: 'Целые решения: от −15 до 4. Сумма крайних: \\(-15+4=-11\\).', }, { topic: 'Функции', difficulty: 2, text: 'Функция \\(y=f(x)\\) чётная. Точки \\(A(3;-\\tfrac{2}{3})\\) и \\(B(6;-\\tfrac{3}{4})\\) на графике. Найдите \\(6f(-3)+8f(-6)\\).', options: [ { text: '\\(-10\\)', correct: true }, { text: '\\(10\\)', correct: false }, { text: '\\(-6\\)', correct: false }, { text: '\\(-4\\)', correct: false }, ], explanation: '\\(f(-3)=f(3)=-\\tfrac{2}{3}\\), \\(f(-6)=-\\tfrac{3}{4}\\). \\(6\\cdot(-\\tfrac{2}{3})+8\\cdot(-\\tfrac{3}{4})=-4-6=-10\\).', }, { topic: 'Логарифмы', difficulty: 3, text: 'Найдите произведение корней уравнения \\(\\log_2^2x-2\\log_2x=\\log_224-\\log_23\\), умноженное на 11.', options: [ { text: '\\(44\\)', correct: true }, { text: '\\(22\\)', correct: false }, { text: '\\(88\\)', correct: false }, { text: '\\(48\\)', correct: false }, ], explanation: 'Пусть \\(t=\\log_2x\\): \\(t^2-2t=3\\Rightarrow t=3\\) или \\(t=-1\\). Корни: \\(x=8,\\;x=\\tfrac{1}{2}\\). Произведение \\(=4\\). \\(4\\times11=44\\).', }, { topic: 'Геометрия', difficulty: 3, text: 'Плоскость, параллельная основанию треугольной пирамиды, делит высоту в отношении \\(5:3\\) от вершины. Найдите площадь сечения, если она меньше площади основания на 39.', options: [ { text: '\\(25\\)', correct: true }, { text: '\\(36\\)', correct: false }, { text: '\\(16\\)', correct: false }, { text: '\\(49\\)', correct: false }, ], explanation: '\\(k=\\tfrac{5}{8}\\). \\(S_{\\text{осн}}-\\tfrac{25}{64}S_{\\text{осн}}=39\\Rightarrow S_{\\text{осн}}=64\\). \\(S_{\\text{сеч}}=25\\).', }, { topic: 'Показательные неравенства', difficulty: 3, text: 'Найдите наименьшее целое решение неравенства \\(8^{2x-32}+10\\cdot4^{3x-49}>56\\).', options: [ { text: '\\(17\\)', correct: true }, { text: '\\(16\\)', correct: false }, { text: '\\(18\\)', correct: false }, { text: '\\(15\\)', correct: false }, ], explanation: 'Пусть \\(t=2^{6x-98}\\): \\(4t+10t>56\\Rightarrow t>4\\Rightarrow x>16{,}\\overline{6}\\). Мин. целое: 17.', }, { topic: 'Логарифмы', difficulty: 3, text: 'Найдите произведение наименьшего и наибольшего целых решений неравенства \\(\\log_3^2(x+12)-\\log_3(x+12)-6<0\\).', options: [ { text: '\\(-154\\)', correct: true }, { text: '\\(154\\)', correct: false }, { text: '\\(-110\\)', correct: false }, { text: '\\(-180\\)', correct: false }, ], explanation: 'Пусть \\(t=\\log_3(x+12)\\): \\(-2 insertO.run(qid, o.text, o.correct ? 1 : 0, i)); inserted++; } db.exec('COMMIT'); console.log(`✓ math: вставлено ${inserted}, пропущено ${skipped} (уже было).`); } catch (err) { db.exec('ROLLBACK'); console.error('Ошибка:', err.message); process.exit(1); }