text
stringlengths
59
71.4k
// (C) 2001-2016 Intel Corporation. All rights reserved. // Your use of Intel Corporation's design tools, logic functions and other // software and tools, and its AMPP partner logic functions, and any output // files any of the foregoing (including device programming or simulation // files), and any associated docum...
#include <bits/stdc++.h> using namespace std; double tick() { static clock_t oldtick; clock_t newtick = clock(); double diff = 1.0 * (newtick - oldtick) / CLOCKS_PER_SEC; oldtick = newtick; return diff; } long long gcd(long long a, long long b) { if ((a == 0) || (b == 0)) { return ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); set<int> a; int n, t; cin >> n; while (n--) { cin >> t; a.insert(t); } cout << ((a.count(0) == 1) ? a.size() - 1 : a.size()); return 0; } ...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, s, x, k, ans = 0, ch = 0; cin >> n >> s; s = 8 * s; vector<long long int> vec(n); vector<pair<long long int, long long int>> dat; for (long long int i = 0; i < n; i++) cin >> vec[i]; sort(vec.begin(), vec.end());...
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; const int MAX = 2e3 + 5; const long long MAX2 = 11; const long long MOD = 998244353; const long long MOD2 = 1000005329; const long long INF = 2e18; const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1, 0}; const int dc[] = {0, 1, 0, -1, 1...
/* This file is part of JT12. JT12 program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. JT12 program is distribute...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; long long int dp[2010][2010]; long long int a[2010]; long long int b[2010]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i] >> b[i]; } for (int i = 0; i <= 2000; i++) { for (int j = 0; j <= 2000; j++) { ...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; int n, l, k, i, p[256], a[256], j, w; double f[201][512][201], aa; int main() { scanf( %d%d%d , &n, &l, &k); k = min(k, n); for (i = 0; i < n; ++i) scanf( %d , p + i); for (i = 0; i < n; ++i) scanf( %d , a + i); f[0][k + 256][0] = 1; for (i =...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s[n]; int a[n]; for (int x = 0; x < n; x++) { cin >> s[x]; a[x] = s[x].length(); } for (int x = 0; x < n; x++) { for (int y = 0; y < n - 1; y++) { if (a[y] > a[y + 1]) { ...
#include <bits/stdc++.h> using namespace std; inline char gc() { static char buf[100000], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++; } inline long long read() { long long x = 0; char ch = getcha...
#include <bits/stdc++.h> int main() { int i, j, k, n, t, c1, c2, c3, c4, c5; scanf( %d%d%d%d%d , &c1, &c2, &c3, &c4, &c5); t = c1 + c2 + c3 + c4 + c5; if (t == 0) printf( -1 n ); else if (t % 5 == 0) printf( %d n , t / 5); else printf( -1 n ); }
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; long long a, b, c, d, e, f, k; bool check(long long x, long long y) { if (k == 0) { return x == c && y == d; } return ((c - x) * e + (d - y) * f) % k == 0 && (e * (d - y) + f * (x - c)) % k == 0; } int mai...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int sum = 0; bool ok = false; for (int i = 1; i <= n; i++) { sum = i + sum; if (n == 1 || n == sum) { cout << YES << endl; break; } if (sum > n) { ok = true; brea...
module jsrflipfloptb; wire q, qbar; reg clk,rst; reg [1:0] sr; jsrflipflop jsrff(q,qbar,clk,rst,sr); always #5 clk = ~clk; initial begin clk = 1'b0; rst = 1; # 10; rst = 0; #10; $display("RSLT\ts\tr\tq\tqbar"); sr = 0; # 10; // Another value if ( q === 1'b0 ...
#include <bits/stdc++.h> using namespace std; void reverseStr(string& str) { int n = str.length(); for (int i = 0; i < n / 2; i++) swap(str[i], str[n - i - 1]); } int main() { string str, str1; cin >> str; cin >> str1; reverseStr(str); if (str == str1) { cout << YES << endl; ...
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const int N = 100010; int n, k, m; int a[N]; int main() { ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; int cnt = 0; while (k > 0) { cnt += 1...
#include <bits/stdc++.h> using namespace std; template <typename T> void print(T t) { cout << t << endl; } long long n = 0, t = 0; long long small = -1e18, big = 1e18; const long long mod = 1e9 + 7; map<long long, long long> occ; map<pair<long long, long long>, long long> occP; void print2dVec(v...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 20; long long int c[15][maxn]; int lowbit(int x) { return x & (-x); } void upDate(int pos, long long int val, int which) { while (pos <= maxn - 20) { c[which][pos] += val; pos += lowbit(pos); } } long long int ask(int...
#include <bits/stdc++.h> using namespace std; const long long MAX = 100001; long long n, k, l[MAX], inf = 1000000000000; multiset<long long> kek; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> k; for (int i = 0; i < n; i++) { cin >> l[i + 1]; } lon...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<vector<long long>> a; bool tr = true; for (long long l, r, i = 0; i < n; i++) { cin >> l >> r; a.push_back({l, r}); } sort(a.begin(), a.end(), [](const vector<long long>& a, const vect...
`timescale 1ns/1ns module camera ( input refclk, input reset_n, output pixclk, output vsync, output hsync, output [7:0] data ); reg [12:0] hs_counter = 0; reg [9:0] vs_counter = 0; assign pixclk = refclk; always @(negedge refclk) begin if(reset_n == 0) begin hs_counter = 0; vs_counter = 0; end ...
#include <bits/stdc++.h> using namespace std; const string pocetno = 0000000000 ; const string oznake = RGBYW ; const int maxn = 105; int N, razlicite, sol = maxn * maxn; vector<pair<int, int> > V; set<string> S; void rijesi() { for (int maska = 0; maska < (1 << 10) + 1; maska++) { S.clear()...
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353, INF = 1e9; const long long N = 2e5 + 1; const double ep = 1e-10; const double pi = 3.141592653589793238; void floyd() { long long n; cin >> n; string a, b; cin >> a >> b; long long a1 = 0, a2 = 0, k = 0, ans =...
#include <bits/stdc++.h> using namespace std; void qmax(long long &x, long long y) { if (x < y) x = y; } void qmin(long long &x, long long y) { if (x > y) x = y; } inline long long read() { char s; long long k = 0, base = 1; while ((s = getchar()) != - && s != EOF && !(isdigit(s))) ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> int main() { int n, m; scanf( %d%d , &n, &m); std::vector<std::vector<int>> graph(n); for (int i = 0; i < m; ++i) { int a, b; scanf( %d%d , &a, &b); a--; b--; graph.at(a).push_back(b); graph.at(b).push_back(a); } std::vector<int> col...
module \$_DFFE_PN0P_ (input D, C, R, E, output Q); AL_MAP_SEQ #(.DFFMODE("FF"), .REGSET("RESET"), .SRMUX("INV"), .SRMODE("ASYNC")) _TECHMAP_REPLACE_ (.d(D), .q(Q), .clk(C) ,.ce(E), .sr(R)); wire _TECHMAP_REMOVEINIT_Q_ = 1'b1; endmodule module \$_DFFE_PN1P_ (input D, C, R, E, output Q); AL_MAP_SEQ #(.DFFMODE("FF"), .R...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
/////////////////////////////////////////////////////////////////////////////// // // Silicon Spectrum Corporation - All Rights Reserved // Copyright (C) 2009 - All rights reserved // // This File is copyright Silicon Spectrum Corporation and is licensed for // use by Conexant Systems, Inc., hereafter the "li...
#include <bits/stdc++.h> using namespace std; const int mx[] = {0, 2, 3, 1}; long long get_base(long long n) { long long b = 4; for (;;) { if (b > n) return b / 4; b <<= 2; } return 0; } long long func1(long long n) { long long b = get_base(n); return (n - b) / 3 + b; } ...
//================================================================================================== // Filename : RKOA_OPCHANGE.v // Created On : 2016-10-26 23:25:59 // Last Modified : 2016-10-31 11:17:35 // Revision : // Author : Jorge Esteban Sequeira Rojas // Company : Instituto Tec...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; long long dp[101][101][11][2]; long long k1, k2; long long solve(long long n1, long long n2, long long count, long long flag) { if (n1 < 0 || n2 < 0) { return 0; } if (n1 == 0 && n2 == 0) { return 1; } if (flag != -1 && dp[n1][n2][cou...
`include "senior_defines.vh" module register_file #(parameter ctrl_w = `RF_CTRL_WIDTH, parameter nat_w = `SENIOR_NATIVE_WIDTH) ( input wire clk_i, input wire reset_i, input wire [nat_w-1:0] pass_through_dat_i, input wire [ctrl_w-1:0] ctrl_i, input wire [nat_w-1:0] dat_i, input wire [nat_w-1:...
#include <bits/stdc++.h> using namespace std; int main() { int n; string cad; cin >> n >> cad; int res = 0; for (int i = 0; i < n; ++i) { if (cad[i] == 0 ) { res++; break; } else { res++; } } cout << res << n ; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, p = 0, q = 0; cin >> n; string str; cin >> str; for (int i = 0; i < n; i++) { if (str[i] == F && str[i + 1] == S ) p = p + 1; if (str[i] == S && str[i + 1] == F ) q = q + 1; } if (q > p) cout << YE...
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << << name << : << arg1 << n ; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1,...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: Jafet Chaves Barrantes // // Create Date: 17:39:32 03/02/2016 // Design Name: // Module Name: Modificacion_Frec_Conmu // Project Name: // Target Devices: // Tool versions: // De...
#include <bits/stdc++.h> using namespace std; const double EPS = 0.0000001; const double PI = acos(-1); const long long INFLL = 0x7FFFFFFFFFFFFFFF; const int INF = 0x7FFFFFFF; template <typename T> inline void next(T &num) { char c; num = 0; do { c = getchar_unlocked(); } while (c !=...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; const int maxn = 1010, max_range = 1000001; int edge[maxn][3 * maxn], reached[maxn], start[3 * maxn], len[3 * maxn], vert[3 * maxn][2], n, m, res; FILE *in; int nb(int v, int e) { if (vert[e][0] == v) return vert[e][1]; else return vert[e...
#include <bits/stdc++.h> using namespace std; string s; long long a[101], b[101]; int main() { long long i, j, k, l, n, c, m, x, y, lft, rgt, p, q; cin >> n; for (i = 0; i < 2 * n; i++) { cin >> a[i]; } sort(a, a + 2 * n); c = 0; p = 0; long long mnm = 1267357834; for (...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
`include "mux.v" module HalfAdder(input a,b, output sum, carry); Xor g1(a, b, sum); And g2(a, b, carry); endmodule module FullAdder(input a,b,c, output sum, carry); wire s1, c1, c2; Xor g1(a, b, s1); Xor g2(s1, c, sum); And g3(a, b, c1); And g4(s1, c, c2); Xor g5(c2, c1, carry); endmodule modul...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> const int N = 100001; int Pri[200005]; int NN, Cnt[100005], Mac[100005]; bool Use[200005]; void GetPrimeList() { int TmpN = sqrt(N); for (int i = 2; i <= N; ++i) Use[i] = true; for (int i = 2; i <= N; ++i) { if (Use[i]) Pri[++Pri[0]] = i; for (int j = 1; j <= P...
//======================================================================== // Verilog Components: Registers //======================================================================== // Note that we place the register output earlier in the port list since // this is one place we might actually want to use positional p...
#include <bits/stdc++.h> int main() { int m, n; scanf( %d %d , &n, &m); if (n == 1) { if (m == 2) { printf( 0 n ); printf( 1 1 n ); printf( 1 2 n ); printf( 1 1 n ); return 0; } else { printf( 1 n ); printf( 1 %d 1 1 n , m); for (...
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, p; string s, x, y; cin >> n; cin.ignore(); while (n--) { getline(cin, s); a = 0; b = 0; p = s.length(); if (s[0] == m && s[1] == i && s[2] == a && s[3] == o && s[4] == . ) { ...
#include <bits/stdc++.h> using namespace std; int main() { int num[3]; cin >> num[0] >> num[1] >> num[2]; char c1 = * , c2 = * ; if (num[0] == 1) c1 = + ; if (num[2] == 1) c2 = + ; if (num[1] == 1 && num[0] != 1 && num[2] != 1) { cout << max(num[0] * (num[1] + num[2]), (num[0] + nu...
module top; int q_tst [$]; int q_tmp [$]; int elem; integer idx; bit passed; task automatic check_size(integer size, string fname, integer lineno); if (q_tst.size !== size) begin $display("%s:%0d: Failed: queue size != %0d (%0d)", ...
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; cout << 0 << << 0 << << n; return 0; }
#include <bits/stdc++.h> using namespace std; class Node { public: Node *prev, *next; int k; Node(int K) { k = K; prev = next = NULL; }; void insert(int K) { Node *n = new Node(K); n->prev = this; if (this->next == NULL) this->next = n; else { ...
/* * schoolMIPS - small MIPS CPU for "Young Russian Chip Architects" * summer school ( ) * * originally based on Sarah L. Harris MIPS CPU * * Copyright(c) 2017 Stanislav Zhelnio * Aleksandr Romanov */ `include "sm_cpu.vh" module sm_cpu ( input clk, //...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; double dp[105][105][105][3] = {{{{0}}}}; bool used[105][105][105] = {{{0}}}; void f(int a, int b, int c) { if (used[a][b][c]) return; ; used[a][b][c] = 1; if (a == 0) dp[a][b][c][1] = 1; else if (b == 0) dp[a][b][c][2] = 1; else i...
#include <bits/stdc++.h> using namespace std::chrono; using namespace std; const long long int mod = 998244353; const int inf = 1e9 + 7; long long int f(long long int x, long long int n) { long long int r = 1; while (n > 0) { if (n % 2 == 1) r = (r * x) % mod; x = (x * x) % mod; n /=...
`timescale 1ns/1ps module DdrCtl1Sim; reg clock0; reg clock90; reg clock2x0; reg clock2x90; reg clock2x180; reg reset; reg [11:0] inst; reg inst_en; wire [31:0] page; wire ready; wire ddrctl_ddr_cke; wire ...
module AUDIO_ADC( // host clk, reset, read, readdata, //available, empty, clear, // dac bclk, adclrc, adcdat ); /***************************************************************************** * Parameter Declarations * ************************************...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 19:07:49 02/26/2016 // Design Name: // Module Name: Alu // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencie...
#include <bits/stdc++.h> using namespace std; int mod = 1e9 + 7; const int N = 1005; vector<pair<int, int>> graph[N]; vector<int> ans; int vis[N]; int v[N]; void dfs(int pos) { vis[pos] = 1; v[pos] = 1; for (auto& e : graph[pos]) { if (vis[e.first] == 0) { if (e.second == 0) { ...
//////////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2013, University of British Columbia (UBC); All rights reserved. // // // // Redistribution and use in source and binary forms, w...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 17:29:35 03/29/2015 // Design Name: // Module Name: regfileparam_behav // Project Name: // Target Devices: // Tool versions: // Description: // ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
/* * Copyright (C) 2009 Onno Kortmann <> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program ...
`include "system_conf.v" `include "../components/lm32_top/lm32_include.v" // for {IROM,DRAM}_ADDR_WIDTH `include "../components/lm32_top/lm32_include_all.v" module superkdf9 ( input wire clk, rst ,output wire [3:0] led ,input wire [31:0] interrupt_n ,output wire [10:0] user_opcode ,output wire [31:0] user_opera...
module user_io( input SPI_CLK, input SPI_SS_IO, output reg SPI_MISO, input SPI_MOSI, input [7:0] CORE_TYPE, output [5:0] JOY0, output [5:0] JOY1, output [2:0] MOUSE_BUTTONS, output KBD_MOUSE_STROBE, output [1:0] KBD_MOUSE_TYPE, output [7:0] KBD_MOUSE_DATA, ...
#include <bits/stdc++.h> using namespace std; const int N = 120000 + 10; const double PI = acos(-1); pair<double, double> operator+(pair<double, double> a, pair<double, double> b) { return make_pair(a.first + b.first, a.second + b.second); } pair<double, double> operator-(pair<double, double> a, pair<do...
#include <bits/stdc++.h> using namespace std; string ent = n ; string space = ; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; string s; cin >> s; int zero, one; zero = one = 0; for (int i = 0; i < n; i++) { if (s[i] == 48) zero++; else ...
#include <cstdio> #include <iostream> using namespace std; const int M = 20005; const int N = 31; #define make make_pair #define pii pair<int,int> int read() { int x=0,f=1;char c; while((c=getchar())< 0 || c> 9 ) {if(c== - ) f=-1;} while(c>= 0 && c<= 9 ) {x=(x<<3)+(x<<1)+(c^48);c=getchar();} ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; map<pair<string, int>, vector<pair<string, int> > > edg; queue<string> que; map<string, int> num, por; set<string> sett; int main() { int n, i, k, l, r, a, b, j; cin >> n; string s, t, S; for (i = 0; i < n; i++) { cin >> s >> a; if (!...
#include <bits/stdc++.h> using namespace std; int a[13] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; int run(int x) { if ((x % 4 == 0 && x % 100 != 0) || (x % 400 == 0)) return 1; else return 0; } int main() { int y1, y2, m1, m2, d1, d2; int i, j; scanf( %d:%d:%d ...
#include <bits/stdc++.h> int b; struct Matrix { long long int x[110][110]; } A, B, C; Matrix operator*(Matrix A, Matrix B) { Matrix C; for (int i = 1; i <= b; i++) { for (int j = 1; j <= b; j++) { C.x[i][j] = 0; for (int k = 1; k <= b; k++) { C.x[i][j] += A.x[i][k] * ...
#include <bits/stdc++.h> using namespace std; const int infint = 1e9; const long long inf = 1e18; const int MOD = (int)1e9 + 7; const int MAXN = (int)3e5 + 7; const int LOG = 17; int a[MAXN], n, IL[MAXN], IR[MAXN], Lp, Rp, ans, L, R; pair<int, int> G, seg[LOG][2 * MAXN]; pair<int, int> operator*(const...
#include <bits/stdc++.h> using namespace std; using ll = long long; using db = double; int mod = 1000000007; db pie = 3.1415926535; int spf[5000005]; int mm = 5000000; int pre[5000005]; void help() { int i; for (i = 1; i <= mm; i++) { spf[i] = i; } for (i = 2; i <= mm; i += 2) { ...
#include<bits/stdc++.h> #include<unordered_map> #include<unordered_set> #define f(i,a,b) for( int i=a;i<=b;++i) #define ff(i,a,b) for( int i=a;i>=b;--i) #define debug(x) cerr << #x << : << x << << endl using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long doub...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 1e3; string s, sq; int z1[maxn + 10], z2[maxn + 10], pref[1010], suff[1010], rez; void calc(string ss, int z[]) { int l = -1; int r = -1; for (int i = 1; i < ss.size(); i++) { if (i > r) { l = i; r = l - 1; ...
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize( O3,Ofast,no-stack-protector,unroll-loops,fast-math ) const int maxn = 2e3 + 7; int32_t main() { int n, d, e; cin >> n >> d >> e; int ans = 1e9 + 7; for (int i = 1; i * 5 * e <= n; i++) { int t = i * 5 * e; t = n - t;...
#include <bits/stdc++.h> using namespace std; set<long long int> blacklist; long long int par(long long int* parent, long long int f, long long int n) { if (parent[f] < 0) return parent[f]; if (parent[f] == f) return f; else { parent[f] = par(parent, parent[f], n); return parent[f]; ...
#include <bits/stdc++.h> using namespace std; const int MOD = 998244353; const int N = 2000 + 10; int n; int pa, pb, p, q; int cp[N][N]; int strong[N]; int f[N]; void add(int &t, int s) { t += s; if (t >= MOD) t -= MOD; } void mul(int &t, int s) { t = (long long)t * s % MOD; } int pow(in...
/* This file is part of JT12. JT12 is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. JT12 is distributed in the hope tha...
// test_data_dma.v `timescale 1ns / 1ps module test_data_dma; // avalon clock interface reg clk = 0; reg reset = 1; // avalon mm slave: control port reg [1:0]avs_ctrl_address = 2'bxx; reg avs_ctrl_write = 0; reg [31:0]avs_ctrl_writedata = 32'hxxxx_xxxx; reg avs_ctrl_read = 0; wire [31:0]...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
// (C) 2001-2014 Altera Corporation. All rights reserved. // Your use of Altera Corporation's design tools, logic functions and other // software and tools, and its AMPP partner logic functions, and any output // files any of the foregoing (including device programming or simulation // files), and any associated doc...
#include <bits/stdc++.h> using namespace std; int n, x, y, nr; int a[110], b[110]; bool used[110]; int main() { cin >> n; cin >> x; for (int i = 1; i <= x; ++i) { cin >> nr; used[nr] = true; } cin >> y; for (int i = 1; i <= y; ++i) { cin >> nr; used[nr] = true; ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> int main() { int i, j, count, n, a[5001], flag[5001]; scanf( %d , &n); count = 0; memset(flag, 0, sizeof(int) * 5001); for (i = 0; i < n; i++) { scanf( %d , &a[i]); if (a[i] > n) count++; else if (flag[a[i]] == 1) count++; else ...
/* * Titor - Barrel Processor - Easy to replicate register * Copyright (C) 2012,2013 Sean Ryan Moore * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the Li...
////////////////////////////////////////////////////////////////////// //// //// //// dbg_cpu_registers.v //// //// //// //// ...
#include <bits/stdc++.h> using namespace std; const int dx[] = {0, 0, -1, 1}; const int dy[] = {1, -1, 0, 0}; const int N = 505; int n, m; char adj[N][N]; bool vis[N][N]; struct node { int type, x, y; node() {} node(int type, int x, int y) : type(type), x(x), y(y) {} void print() { ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; long long ans = 0; for (int i = (0); i < (n); ++i) { long long t, T, x, cost; cin >> t >> T >> x >> cost; if (t >= T) { ans += cost + m * x; continue; } long long aux1 = ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n < 3) { cout << -1; return 0; } if (n == 3) { cout << 210; return 0; } int A[] = {50, 80, 170, 20, 200, 110}; int nA[] = {2, 2, 3, 2, 3, 3}; int j = 0; for (int i = 4; i <...
#include <bits/stdc++.h> using namespace std; long long t, n, sum, t1, ans; string st; int main() { cin >> t; while (t--) { cin >> n; cin >> st; int a = 0, b = 0; for (int i = 0; i < n; i++) { if (st[i] == ( ) a++; if (st[i] == ) ) { if (a) ...
module opc3cpu( inout[15:0] data, output[15:0] address, output rnw, input clk, input reset_b); parameter FETCH0=0, FETCH1=1, RDMEM=2, RDMEM2=3, EXEC=4 ; parameter AND=5'bx0000, LDA=5'bx0001, NOT=5'bx0010, ADD=5'bx0011; parameter LDAP=5'b01001, STA=5'b11000, STAP=5'b01000; parameter JPC=5'b11001, JPZ=5'b11...
module membus_1_connect( // unused input wire clk, input wire reset, // Master input wire m_wr_rs, input wire m_rq_cyc, input wire m_rd_rq, input wire m_wr_rq, input wire [21:35] m_ma, input wire [18:21] m_sel, input wire m_fmc_select, input wire [0:35] m_mb_write, output wire m_addr_ack, output wire m_r...
#include <bits/stdc++.h> using namespace std; int dadsadasda; const int INF = 0x3f3f3f3f; const long long LLINF = 1e18; const int MAXN = 3e5; int n; int a[MAXN]; int ans[MAXN]; priority_queue<pair<int, int> > pq; int father[MAXN], siz[MAXN], cnt[MAXN]; void makeSet(int nn, int m) { for (int i ...