-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmicrocircuit.hpp
More file actions
35 lines (25 loc) · 774 Bytes
/
Copy pathmicrocircuit.hpp
File metadata and controls
35 lines (25 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pragma once
#include <iostream>
#include <string>
#include <vector>
#include "logger.hpp"
#include "mc_instruction.hpp"
#include "stack.hpp"
class Microcircuit {
Stack<long long> _stack;
Logger& _logger;
int _cycles;
int _elementary_ops;
long long _pre_compute(long long x, long long n);
void _write(long long x);
void _mul();
void _pow_n(long long n);
void _print_answer(long long ans, int cycles);
public:
Microcircuit(Logger& logger);
long long brute_force_compute(long long x, long long n); // O(N)
long long bin_exp_compute(long long x, long long n); // O(logN)
void clear();
inline int get_cycles() const { return _cycles; }
inline int get_elem_ops() const { return _elementary_ops; }
};