text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int stuff(int x) { int s = 0; while (x / 10 != 0) { int r = x % 10; x /= 10; s += r; } s += x; return s; } int main() { ios_base::sync_with_stdio(false); long long int i = 0; long long int p, f, a, b, c, s, spow = 1;...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: dram2_ddr2_rptr.v // Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. // // The above named program is free software; you can redistribute it a...
// ==================================================================== // Radio-86RK FPGA REPLICA // // Copyright (C) 2011 Dmitry Tselikov // // This core is distributed under modified BSD license. // For complete licensing information see LICENSE.TXT. // ------------------------------------...
#include <bits/stdc++.h> #include <cmath> #include <regex> #define ff first #define ss second #define pb push_back #define mp make_pair #define ba back #define ppb pop_back #define eb emplace_back #define eps 1e-6 #define vec vector<long long int> #define sz(x) (int((x.size()))) #define all(x)...
#include <bits/stdc++.h> using namespace std; int ky[8] = {-1, 1, -2, 2, -2, 2, -1, 1}; int kx[8] = {-2, -2, -1, -1, 1, 1, 2, 2}; int dy[4] = {-1, 0, 1, 0}; int dx[4] = {0, 1, 0, -1}; int ddy[8] = {-1, 0, 1, -1, 1, -1, 0, 1}; int ddx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}; const double PI = acos(-1.0); int ...
/** * 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) 2015 - 2017 Harmon Instruments, LLC * * 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 License, or * (at your option) any later version. * * Thi...
`timescale 1ns/10ps module PressCountSim; reg clock0; reg clock180; reg reset; reg countu; reg countd; wire [7:0] nr_presses; initial begin #0 $dumpfile(`VCDFILE); #0 $dumpvars; #5000 $finish; end initial begin #0 clock0 =...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2005 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); input clk; localparam // synopsys enum En_State EP_State_IDLE = {3'b000,5'd00}, EP_State_...
/* Copyright (c) 2014-2017 Alex Forencich Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distri...
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); unsigned n, m; vector<long long> a; vector<long long> prefix; map<long long, long long, greater<long long> > time; cin >> n >> m; prefix.resize(n + 1, 0); a.resize(n); for (unsigned i = 0; i < n; cin >> a[i++]...
#include <bits/stdc++.h> using namespace std; long long power(long long a, long long p, long long mod) { long long ret = 1; while (p) { if (p & 1) ret = (ret * a) % mod; a = (a * a) % mod; p /= 2; } return ret; } long long DP[1000]; int A[1000]; int main() { int n; ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int n, k; cin >> n >> k; if (k > (n * n + 1) / 2) { cout << NO ; return 0; } cout << YES n ; int tmp = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if...
/** * 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...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2010 by Wilson Snyder. module t (/*AUTOARG*/ // Outputs out, // Inputs in ); input in; // inputs don't get flagged as undriven output out; // outputs don't get...
#include <bits/stdc++.h> using namespace std; int main() { long long arr[4]; for (int i = 0; i < 4; i++) cin >> arr[i]; sort(arr, arr + 4); long long w, x, y, z; w = arr[0]; x = arr[1]; y = arr[2]; long long a, b, c, d; b = (w - x + y) / 2; a = w - b; c = x - a; cout ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int a, b, c, d, m, v; cin >> a >> b >> c >> d; m = max((3 * a) / 10, a - (a / 250) * c); v = max((3 * b) / 10, b - (b / 250) * d); if (m > v) cout << Misha ; else if (v > m) cout << ...
#include <bits/stdc++.h> using namespace std; void FastIO() { ios_base::sync_with_stdio(false); cin.tie(0); cout.precision(20); } int main() { FastIO(); int A, B; while (cin >> A >> B) { int M = min(A, B); int N = max(A - M, B - M); cout << M << << N / 2 << endl; ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n = 4; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } if (max(a[2], a[3]) - 1 > min(a[2], a[3])) { cout << -1; return 0; } string ans = ; ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t, n, num; cin >> t; while (t--) { cin >> n; bool flag = false; unordered_map<int, vector<int>> m; for (int i = 0; i < n; ++i) { cin >> num; m[n...
#include <bits/stdc++.h> const long long int mod = 1000000007; const long long int AM = 2e5 + 5; using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; long long int t; cin >> t; while (t--) { long long int n; cin >> n; string s[n + 1]; ...
/* * 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 (c) 2016, The Regents of the University of California All // rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met:...
// -*- verilog -*- // // USRP - Universal Software Radio Peripheral // // Copyright (C) 2003 Matt Ettus // // 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...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Wed Dec 14 22:35:39 MST 2016 // Date : Mon May 08 23:35:06 2017 // Host : GILAMONSTER running 64-bit major release (...
#include <bits/stdc++.h> using namespace std; const int c = 200002; int n, m, maxi, pos = c, cnt, id[c], szint[c], kezd; vector<int> sz[c]; bool v[c], v2[c], jo[c]; void dfs2(int a) { v2[a] = true; bool s = jo[a]; for (int x : sz[a]) { if (!v2[x]) { dfs2(x); if (jo[x]) { ...
#include <bits/stdc++.h> using namespace std; int n, m, x, y, z, d[200 + 5], nows[200 + 5], fr[200 + 5], en[200 + 5], A[200 + 5], S, T, fa[200 + 5], now, Bh, Ch, B[200 + 5], C[200 + 5], H, un, wn, ToT; struct yyy { int to, w, z; } tmp; struct ljb { int head, h[200 + 5]; yyy f[1000 + 5 ...
/** * 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...
module instr_info_table (/*AUTOARG*/ // Outputs vgpr_alu_rd_data, vgpr_lsu_rd_data, sgpr_alu_rd_data, sgpr_lsu_rd_data, issued_rd_data, // Inputs f_decode_valid, clk, rst, f_decode_wfid, decode_wr_data, f_vgpr_alu_wr_done_wfid, f_vgpr_lsu_wr_done_wfid, f_sgpr_alu_wr_done_wfid, f_sgpr_lsu_instr_d...
module ll_crc(/*AUTOARG*/ // Outputs crc_tx, crc_rx, // Inputs clk, rst_n, LLDMARXD, LLDMARXREM, LLDMARXSOFN, LLDMARXEOFN, LLDMARXSOPN, LLDMARXEOPN, LLDMARXSRCRDYN, DMALLRXDSTRDYN, DMALLTXD, DMALLTXREM, DMALLTXSOFN, DMALLTXEOFN, DMALLTXSOPN, DMALLTXEOPN, DMALLTXSRCRDYN, LLDMATXDSTRDYN ); ...
#include <bits/stdc++.h> using namespace std; int v[1005]; int a[1005], b[1005]; char s[1005]; vector<int> c, d; int main() { cin >> s + 1; int len = strlen(s + 1); int num = 0; for (int i = 1; i <= len; i++) { if (s[i] == ( ) { a[i]++; c.push_back(i); } a[...
module act_led( clk, reset, gmii_rxen, gmii_txen, r_act_sfp); input clk; input reset; input gmii_rxen; input gmii_txen; output r_act_sfp; reg [23:0] count_led; reg r_act_sfp; reg [1:0]current_state; parameter idle=2'b0, first =2'b01, second=2'b10; always@(posedge clk or ...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 22:21:30 05/20/2014 // Design Name: alu // Module Name: C:/Users/Deus/Windows Sync/Xilinx Workspace/Single/test_alu.v // Project Name: Single // Target Dev...
#include <bits/stdc++.h> using namespace std; const int maxn = 10003; int32_t main() { int n, a, b, c; cin >> n >> a >> b >> c; if (n == 1) { cout << 0 ; return 0; } n--; long long ans = 0; ans += min(a, b); n--; if (min(a, b) > c) { ans += n * c; cout ...
#include <bits/stdc++.h> using namespace std; const int INF = 1E9; int main() { int n; string s; cin >> n >> s; for (int len = 1; len <= n; len++) { bool ok = true; for (int i = 0; i < n; i++) { if (i + len * 4 < n && s[i] == * && s[i] == s[i + len] && s[i] == s[i...
#include <bits/stdc++.h> using namespace std; const int MAX = 500004; long long p, pos1, pos2, q, x, l, ans = 0, r, y, z, k, n, m, t, d, c = 0, sum = 0; long long int mn = 0x3f3f3f3f, len, cnt = 1, mx = -1000; std::vector<int> v[MAX]; string s[10004], s1, s2; int main()...
#include <bits/stdc++.h> using namespace std; long long n, m, k, y, a, b, c; long long A[2005]; bool B[2005]; int main() { cin >> n >> k; priority_queue<pair<int, int> > pq; for (int i = int(0); i < int(n); i++) { cin >> A[i]; pq.push({A[i], i}); } int ans = 0; for (int i =...
// This file has been automatically generated by goFB and should not be edited by hand // Compiler written by Hammond Pearce and available at github.com/kiwih/goFB // Verilog support is EXPERIMENTAL ONLY // This file represents the Basic Function Block for VVI_VRP //defines for state names used internally `define STA...
// -*- verilog -*- // // USRP - Universal Software Radio Peripheral // // Copyright (C) 2003 Matt Ettus // // 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...
//------------------------------------------- cpu.v ????? ------------------------------------------- /****************************************************************************** *** ?????CPU ?????????RISC_ CPU???, ?????????? *** ???????????????????????????? ***********************************...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); template <class T> void out(const vector<T> &a) { cout << array: ; for (int i = 0; i < (int)a.size(); i++) cout << a[i] << ; cout << endl; cout.flush(); } template <class T> T gcd(T a, T b) { return (b == ...
// Accellera Standard V2.5 Open Verification Library (OVL). // Accellera Copyright (c) 2005-2010. All rights reserved. parameter CHANGE_START = 1'b0; parameter CHANGE_CHECK = 1'b1; reg r_change; reg [width-1:0] r_test_expr; reg r_state; integer i; `ifdef OVL_XCHECK_OFF //Do nothing `else `ifdef OVL_...
module etx_remap (/*AUTOARG*/ // Outputs emesh_access_out, emesh_packet_out, // Inputs clk, nreset, emesh_access_in, emesh_packet_in, remap_en, etx_wait ); parameter AW = 32; parameter DW = 32; parameter PW = 104; //Clock input clk; input nreset; //Input from arb...
/* # ZUMA Open FPGA Overlay # Alex Brant # Email: # 2012 # LUTRAM wrapper */ /* These luts are used for building configurable muxes.*/ `include "define.v" `include "def_generated.v" `include "primitives.v" module lut_custom #( parameter used = 0, parameter LUT_MASK={2**K{1'b0}} ) ( a, d, dpra, clk, we, dp...
// ---------------------------------------------------------------------- // Copyright (c) 2016, The Regents of the University of California All // rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met:...
/* * 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 la...
#include <bits/stdc++.h> using namespace std; int n, a[1050]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; int tens = a[0]; set<int> answer; for (int rem = 0; rem < 10000000; rem++) { double fuel = tens * 10 + static_cast<double>(rem) / 1000000; double addend = f...
module user_design(clk, rst, exception, input_timer, input_rs232_rx, input_ps2, input_i2c, input_switches, input_eth_rx, input_buttons, input_timer_stb, input_rs232_rx_stb, input_ps2_stb, input_i2c_stb, input_switches_stb, input_eth_rx_stb, input_buttons_stb, input_timer_ack, input_rs232_rx_ack, input_ps2_ack, input_i2...
//############################################################################# //# Function: Latch data when clk=0 # //############################################################################# //# Author: Andreas Olofsson # ...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; template <class T> void dbg(const char* xn, T x) { if (0) cout << xn << : << x << n ; } template <class T, class... TA> void dbg(const char* xn, T x, TA... t) { while (*xn != , ) if (0) cout << *xn++; if (0...
`timescale 1ns/10ps (* whitebox *) (* keep *) module ASSP ( WB_CLK, WBs_ACK, WBs_RD_DAT, WBs_BYTE_STB, WBs_CYC, WBs_WE, WBs_RD, WBs_STB, WBs_ADR, SDMA_Req, SDMA_Sreq, SDMA_Done, SDMA_Active, FB_msg_out, FB_Int_Clr, FB_Start, FB_Busy, WB_RST, Sys_PKfb_Rst, Sys_...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2014.4 // Copyright (C) 2014 Xilinx Inc. All rights reserved. // // ============================================================== `timescale 1 ns / 1 ps m...
/** * 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; int main() { int n, m; long long res = 0; cin >> n >> m; int v[n]; for (int i = 0; i < n; i++) { cin >> v[i]; } for (int i = 0; i < m; i++) { int x, y; cin >> x >> y; res += min(v[x - 1], v[y - 1]); } cout << r...
#include <bits/stdc++.h> using namespace std; int t[3000]; int main() { int n, k; cin >> n >> k; string s; cin >> s; for (int i = 0; i < n; i++) { t[s[i]] += 1; } int lk = t[ A ]; for (char c = A ; c < A + k; c++) { if (t[c] < lk) { lk = t[c]; } } ...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const int N = 1234567; int x[N], y[N]; int n; double areas[N]; void line(int i, int j, double &a, double &b, double &c) { i %= n; j %= n; a = y[j] - y[i]; b = x[i] - x[j]; c = -a * x[i] - b * y[i]; } void i...
#include <bits/stdc++.h> template <class T> inline void read(T &x) { x = 0; register char c = getchar(); register bool f = 0; while (!isdigit(c)) f ^= c == - , c = getchar(); while (isdigit(c)) x = x * 10 + c - 0 , c = getchar(); if (f) x = -x; } template <class T> inline void print(...
/* * 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 lucky[1024 * 4]; long long fact[14]; int cnt; void func(long long cur, int pos, int maxpos) { if (pos == maxpos) { lucky[++cnt] = cur * 10 + 4; lucky[++cnt] = cur * 10 + 7; return; } func(cur * 10 + 4, pos + 1, maxpos); ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 22:08:24 04/14/2015 // Design Name: // Module Name: PrimeList // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // ...
// (c) Copyright 1995-2017 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property // laws. // // DISCLAIMER // This disclaimer is not a license and does not grant ...
/* * Copyright 2017 Google Inc. * * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to...
#include <bits/stdc++.h> using namespace std; queue<int> s1, s2; int main() { int n, k1, k2; cin >> n; cin >> k1; int a, b; for (int i = 0; i < k1; i++) { cin >> a; s1.push(a); } cin >> k2; for (int i = 0; i < k2; i++) { cin >> b; s2.push(b); } int a...
/* * Copyright (c) 1998 Stephen Williams () * * This source code is free software; you can redistribute it * and/or modify it in source code form 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) * ...
/* Copyright (c) 2014 Alex Forencich Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute,...
#include <bits/stdc++.h> using namespace std; const int iinf = 1e9 + 7; const long long linf = 1ll << 60; const double dinf = 1e60; template <typename T> inline void scf(T &x) { bool f = 0; x = 0; char c = getchar(); while ((c < 0 || c > 9 ) && c != - ) c = getchar(); if (c == - ) {...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; int mx[N << 2], lz[N << 2], sum[N << 2], a[N], b[N]; void pushup(int rt) { mx[rt] = max(mx[(rt << 1)], mx[(rt << 1 | 1)]); } void pushdown(int rt) { if (lz[rt]) { lz[(rt << 1)] += lz[rt]; lz[(rt << 1 | 1)] += lz[rt]; m...
#include <bits/stdc++.h> using namespace std; vector<int> v, vv, vv2; int main() { int t, n, a[1000], k, f = 0; cin >> n; if (n == 3) { for (int i = 1; i <= n; i++) { if (i % 2 != 0) { for (int j = 1; j <= n; j++) { if (j % 2 != 0) { cout << W ; ...
#include <bits/stdc++.h> using namespace std; int main() { int m, n; scanf( %d%d , &n, &m); printf( %d n , m * n / 2); return 0; }
#include <bits/stdc++.h> using namespace std; const long long inf = 0x3f3f3f3f3f3f3f3fll; inline long long read() { long long x = 0, f = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) { x = (x << 1) + (x...
#include <bits/stdc++.h> using namespace std; const int N = 300005, INF = 9999999; const long long P = 1e9 + 7; template <typename T> inline void read(T& first, char s = getchar()) { first = 0; while (s > 9 || s < 0 ) s = getchar(); while (s <= 9 && s >= 0 ) first = first * 10 + s - 0 , 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 law...
#include <bits/stdc++.h> using namespace std; const int INF = 2e9; const long long LINF = 1LL << 60; const double inf = 1e15; long long mod = 1e9 + 7; char READ_DATA; int SIGNAL_INPUT; template <typename Type> inline Type ru(Type &v) { SIGNAL_INPUT = 1; while ((READ_DATA = getchar()) < 0 || ...
#include <bits/stdc++.h> using namespace std; const long long int siz = 3e5 + 5; map<int, vector<int>> adjList; long long int ans[siz] = {0}; long long int cum[siz] = {0}; map<long long int, long long int> q[siz]; void dfs(int cur, int parent, int level, long long int val) { for (pair<long long int, l...
#include <bits/stdc++.h> using namespace std; int a[10005][6], n, m; map<int, int> f[10005]; int power(int x, int y) { int s = 1; for (; y; y /= 2, x = 1ll * x * x % 1000000007) if (y & 1) s = 1ll * s * x % 1000000007; return s; } int main() { scanf( %d%d , &n, &m); for (int i = 2;...
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf( %d , &t); while (t--) { int n; scanf( %d , &n); vector<int> a(n); for (int i = 0; (i) < (int)(n); (i)++) { scanf( %d , &a[i]); } queue<int> que; vector<int> ans; for (int i = ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; const int level = 20; vector<int> adj[N]; bool checked[N]; int parent[N]; int sz[N]; int centroid; int sparse[N][level]; int depth[N]; void subtree(int cur, int prev) { sz[cur] = 1; for (auto &child : adj[cur]) { i...
module encoder #( parameter logS=4 ) ( g_input, e_input, o ); localparam S = 2**logS; input [S/2-1:0] g_input; input [S/2-1:0] e_input; output [logS-1:0] o; wire [S-1:0] in; assign in[S/2-1:0] = g_input; assign in[S-1:S/2] = e_input; encoder_ #( .logS(logS) ) enc...
#include <bits/stdc++.h> using namespace std; int freq[300]; string s; const int maxN = 2000; int primes[maxN]; int equs[maxN]; char result[maxN]; set<pair<int, char> > lets; int n; void sieve() { for (int i = 2; i < maxN; i++) { primes[i] = 1; } for (long long i = 2; i * i < maxN;...
#include <bits/stdc++.h> using namespace std; using ll = int64_t; int main(int argc, char* argv[]) { std::ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(10); int n; cin >> n; auto g = vector<vector<ll>>(n, vector<ll>(n, 2000000000)); for (int i = 0; i < (n - 1); ++i) ...
/* * Copyright (C) 2017 Systems Group, ETHZ * 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 * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed t...
/** * 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...
module maple( input clk, input reset, input pin1, input pin5, output ControllerData controller_data, output KeyboardData keyboard_data ); wire maple_active; wire maple_start_detected; wire maple_end_detected; wire maple_data_produce; wire maple_trigger_start; wire maple_trigger_end; wire [7:0...
// daq_dma32_debug.v `timescale 1 ns / 1 ps /* register set: offset | bits | name |access| description -------+------+-----------+------+-------------------------------- 0 | 30:0 | mem_base | R/W |memory base byte address 4 | 25:0 | mem_size | R/W |memory size in words (16 bit) ...
#include <bits/stdc++.h> using namespace std; const int MAX = 5048; vector<int> adj[MAX]; bool used[MAX]; int dist[MAX][MAX]; void solve(const int test_num) { (void)test_num; int v, e; cin >> v >> e; for (int ee = 0, a, b; ee < e; ++ee) { cin >> a >> b; adj[a].push_back(b); }...
#include <bits/stdc++.h> using namespace std; const int N = 200020; long long int n; int main() { cin >> n; for (long long int i = 1; i <= n - 1; i++) { for (long long int j = 1; j <= n - 1; j++) { if (i == j) cout << 0 ; else cout << 1 + (i + j - 2) % (n - 1)...
#include <bits/stdc++.h> using namespace std; vector<long long> ft(1, 1LL); int n, ans[3], hg, xxx = 0; vector<int> graph[200005], vis(200005); queue<int> q; void dfs(int node, int par, int i, int h) { if (h >= hg) hg = h, ans[i] = node; for (auto child : graph[node]) if (child != par) dfs(chi...
#include <bits/stdc++.h> using namespace std; const int N = (int)5e5 + 50; int n; int ans[N]; vector<int> G[N]; int q[N]; int dep[N]; vector<pair<int, int> > hist[N]; void upd(int u, int val) { q[u] = max(q[u], val); } void calc(int v, int p) { dep[v] = 0; for (int nxt : G[v]) { if (nx...
/** * ------------------------------------------------------------ * Copyright (c) All rights reserved * SiLab, Institute of Physics, University of Bonn * ------------------------------------------------------------ */ `timescale 1ps/1ps `default_nettype none module timestamp #( parameter BASEADDR = 16'h000...
/*64 bit wide byte addressable memory*/ module ememory(/*AUTOARG*/ // Outputs wait_out, access_out, write_out, datamode_out, ctrlmode_out, dstaddr_out, data_out, srcaddr_out, // Inputs clk, reset, access_in, write_in, datamode_in, ctrlmode_in, dstaddr_in, data_in, srcaddr_in, wait_in ); paramet...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2017.4 // Copyright (C) 1986-2017 Xilinx, Inc. All Rights Reserved. // // ============================================================== `timescale 1 ns / 1...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; const int mod = 998244353; const int maxn = 2e5 + 10; struct edge { int st, ed; int w; bool operator<(const edge &b) const { return w < b.w; } edge() {} edge(...
#include <bits/stdc++.h> int main() { puts( 1 ); return 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...
#include <bits/stdc++.h> using namespace std; int n, m, notFind; vector<pair<int, int>> edge[100001]; vector<int> ans[2], e[2]; int vis[100001]; void DFS(int u, int c, int vit) { vis[u] = c; e[c].push_back(u); for (auto k : edge[u]) { int v, col, nextCol; tie(v, col) = k; col =...
#include <bits/stdc++.h> using namespace std; const int N = 2e3 + 10; char s[N], t[N]; int n; vector<int> G; void shift(int x) { if (x == 0) return; reverse(s, s + n); reverse(s + x, s + n); G.push_back(x); } int main() { scanf( %d%s%s , &n, s, t); for (int i = 0; i < n; i++) { ...
#include <bits/stdc++.h> using namespace std; long long power_mod(long long num, long long g) { if (g == 0) return 1; if (g % 2 == 1) return (num * power_mod((num * num) % 1000000007, g / 2)) % 1000000007; return power_mod((num * num) % 1000000007, g / 2); } long long power(long long num, long...
#include <bits/stdc++.h> using namespace std; struct rec { int x, p; } a[101]; vector<rec> ans; int n; bool was[101]; bool cmp(rec a, rec b) { return a.x > b.x; } void dfs(int v) { was[v] = true; for (int i = v + 1; i < n; ++i) { if (a[v].x == 0) break; if (!was[i]) { a[v...
`timescale 1ns / 1ps /* -- Module Name: switch fabric -- crossbar -- -- Description: Estructura de interconexion entre puertos de entrada y salida. El modulo implementa un crossbar por medio de un conjunto de multiplexores. Las señales de control provienen del camino de control, en especifico de los...