text
stringlengths
59
71.4k
module wb_bfm_tb; vlog_tb_utils vlog_tb_utils0(); localparam aw = 32; localparam dw = 32; reg wb_clk = 1'b1; reg wb_rst = 1'b1; always #5 wb_clk <= ~wb_clk; initial #100 wb_rst <= 0; wire [aw-1:0] wb_m2s_adr; wire [dw-1:0] wb_m2s_dat; wire [3:0] wb_m2s_sel; ...
#include <bits/stdc++.h> using namespace std; int main() { int t; int nMin; int ans = 0; int n; int inter[150001]; cin >> t; while (t--) { ans = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> inter[i]; } for (int i = n - 1; i >= 0; i--) { ...
#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 int read() { int x = 0; char ch = getchar(); boo...
/* Distributed under the MIT license. Copyright (c) 2011 Dave McCoy () 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, mo...
/* File: ewrapper_link_transmitter.v This file is part of the Parallella FPGA Reference Design. Copyright (C) 2013 Adapteva, Inc. Contributed by Roman Trogan <> 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...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2017.2 // Copyright (C) 1986-2017 Xilinx, Inc. All Rights Reserved. // // ============================================================== `timescale 1n...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<ll, ll>; const ll MOD = 1e9 + 7, N = 2e5 + 10; vector<ll> g[N]; ll vis[N]; ll n, m, k; void bfs(ll s, vector<ll> &dist) { for (ll i = 1; i < n + 1; i++) { vis[i] = 0; } dist[s] = 0; queue<pii> q; ...
#include <bits/stdc++.h> using namespace std; bool rsort1(const pair<long long int, long long int> &a, const pair<long long int, long long int> &b) { return (a.first > b.first); } bool rsort2(const pair<long long int, long long int> &a, const pair<long long int, long long int> &b...
module top ( input sbclki, sbrwi, sbstbi, input sbadri0, sbadri1, sbadri7, input sbdati0, sbdati1, sbdati7, output sbdato0, sbdato1, sbdato7, output sbacko, i2cirq, i2cwkup, inout scl, sda ); wire scli, sclo, scloe, sdai, sdao, sdaoe; SB_I2C #( .I2C_SLAVE_INIT_ADDR("0b1111100010"), .BUS_AD...
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; for (int x = 0; x < T; x++) { vector<long long> arry(7); for (int i = 0; i < 7; i++) cin >> arry[i]; long long least, all_sum; all_sum = arry[6]; least = arry[0]; vector<long long> a(3); ...
module reg_file #(parameter word_sz = 8, addr_sz = 5) (output [word_sz-1:0] do_1, do_2, input [word_sz-1:0]di, input [addr_sz-1:0] raddr_1, raddr_2, waddr, input wr_enable, clk); parameter reg_ct = 2**addr_sz; reg [word_sz-1:0] file [reg_ct-1:0]; assign do_1 = file[raddr_1]; assign do_2 = file[raddr_2]; al...
/////////////////////////////////////////////////////////////////////////////// // $Id: small_fifo.v 1998 2007-07-21 01:22:57Z grg $ // // Module: fallthrough_small_fifo.v // Project: utils // Description: small fifo with fallthrough i.e. data valid when rd is high // // Change history: // 7/20/07 -- Set nearly full ...
/* ORSoC GFX accelerator core Copyright 2012, ORSoC, Per Lenander, Anton Fosselius. Components for aligning colored pixels to memory and the inverse This file is part of orgfx. orgfx is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by...
/** * 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, Microsoft Corporation All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code ...
/** * 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; vector<int> t; void set_val(int p, int x) { t[p + int(t.size()) / 2] = x; for (p = (p + int(t.size()) / 2) / 2; p > 0; p /= 2) { t[p] = max(t[2 * p], t[2 * p + 1]); } } int leftmost(int left, int y) { if (left >= int(t.size()) / 2) return -1;...
#include <bits/stdc++.h> using namespace std; string mask(int a) { string ans; int x = a; while (x) { if (x % 10 == 4 || x % 10 == 7) ans.insert(ans.begin(), x % 10 + 0 ); x /= 10; } return ans; } int main() { string b; int a; cin >> a >> b; a++; while (mask(...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2013.4 // Copyright (C) 2013 Xilinx Inc. All rights reserved. // // ============================================================== `timescale 1 ns / 1 ps m...
#include <bits/stdc++.h> using namespace std; const int maxn = 550; char grid[maxn][maxn]; int rdp[maxn][maxn], cdp[maxn][maxn], dp[maxn][maxn]; int val[maxn][maxn]; int main() { int n, m, q, c1, c2, r1, r2; scanf( %d%d , &n, &m); for (int i = 0; i < n; i++) scanf( %s , grid[i]); for (int i ...
`default_nettype none `define WIDTH 16 module j4( input wire clk, input wire resetq, output wire io_rd, output wire io_wr, output wire [15:0] mem_addr, output wire mem_wr, output wire [`WIDTH-1:0] dout, input wire [`WIDTH-1:0] io_din, //note: this is always a cycle late, as io_addr_ is registered b...
#include <bits/stdc++.h> using namespace std; const long long MAXN = 2e5 + 7; long long parent[MAXN], rank1[MAXN]; vector<pair<long long, pair<long long, long long>>> edges; void makest(long long v) { parent[v] = v; rank1[v] = 0; } long long find(long long v) { if (v == parent[v]) return v; ...
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; const int N = 1e5 + 9; vector<int> v[N]; bool visited[N]; int c = 0; map<pair<int, int>, int> m; void dfs(int x, int parent) { visited[x] = true; bool b = false; for (int i = 0; i < v[x].size(); i++) { if (...
// File: top.v // Generated by MyHDL 0.10 // Date: Mon Aug 20 12:46:43 2018 `timescale 1ns/10ps module top ( clk, led ); // FPGA Hello world multible pwm duty cycle controled leds // https://timetoexplore.net/blog/arty-fpga-verilog-02 // // Target: // ZYNQ 7000 Board (Arty, PYNQ-Z1, PYNQ-Z2) with at lea...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int k, n, m, x, ans; int a[N]; string second, r; map<string, int> vis1, vis2; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) { char e[50]; scanf( %s , e); r = second = e; while (second.find( kh ...
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n; cin >> n; long long a[n + 1]; long long diff[n]; long long max_count = INT_MIN; for (long long i = 1; i <= n; i++) cin >> a[i]; multiset<long...
#include <bits/stdc++.h> using namespace std; int n, cost; int di[4] = {0, -1, 0, 1}; int dj[4] = {-1, 0, 1, 0}; char grid[51][51]; int vis[51][51]; pair<int, int> pi; pair<int, int> pf; vector<pair<int, int>> ili; vector<pair<int, int>> ilf; void dfs(int r, int c, vector<pair<int, int>>* island) ...
module HPS ( memory_mem_a, memory_mem_ba, memory_mem_ck, memory_mem_ck_n, memory_mem_cke, memory_mem_cs_n, memory_mem_ras_n, memory_mem_cas_n, memory_mem_we_n, memory_mem_reset_n, memory_mem_dq, memory_mem_dqs, memory_mem_dqs_n, memory_mem_odt, memory_mem_dm, memory_oct_rzqin, hps_io_hps_io_gpio_inst_...
/** * 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; template <class c> struct rge { c b, e; }; template <class c> rge<c> range(c i, c j) { return rge<c>{i, j}; } template <class c> auto dud(c* x) -> decltype(cerr << *x, 0); template <class c> char dud(...); struct debug { ~debug() { cerr <...
/** * 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-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...
////////////////////////////////////////////////////////////////////////////////// // SCFIFO_64x64_withCount for Cosmos OpenSSD // Copyright (c) 2015 Hanyang University ENC Lab. // Contributed by Kibin Park <> // Yong Ho Song <> // // This file is part of Cosmos OpenSSD. // // Cosmos OpenSSD is free soft...
#include <bits/stdc++.h> using namespace std; const long long mod = (long long)(1e9 + 7); const long long inv = (long long)(5e8 + 4); int main() { long long n, m; cin >> n >> m; long long ans = (n % mod) * (m % mod) % mod; long long l = 1, r = 1; while (l <= min(n, m)) { long long a = ...
// -- (c) Copyright 2010 - 2011 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...
/** * 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 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-2019 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; namespace flyinthesky { const int MAXN = 500000 + 5; struct edge { int u, v, w; bool operator<(const edge &b) const { return w < b.w; } } ed[MAXN], ed2[MAXN]; struct whw { int id, fr, t; }; struct ask { int id; bool operator<(const ask &b...
#include<bits/stdc++.h> using namespace std; #define ll long long #define mod 1000000007 #define pb push_back #define ff first #define ss second #define all(a) (a).begin(),(a).end() #define fr(i,a,b) for(int i=a;i<b;i++) #define mapit(i,mp) for(auto i = mp.begin(); i!=mp.end(); i++) #define pi...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; string s; cin >> n >> k; cin >> s; int j = 0; for (int i = 0; i < n - 1; i++) { if (s.substr(0, i + 1) == s.substr(n - i - 1)) { j = i + 1; } } string a = s.substr(j); cout << s; for (int...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int start = 1; while (1) { if (m >= start) m -= start; else break; start++; if (start == (n + 1)) start = 1; if (m == 0) break; } cout << m; return 0; }
#include <bits/stdc++.h> using namespace std; int n, m, x, y, dp[108][108][28], dis[108][108]; int DP(int s, int t, int w) { if (dp[s][t][w - a ] >= 0) return dp[s][t][w - a ]; for (int i = 1; i <= n; ++i) if (dis[s][i] >= w && (DP(t, i, dis[s][i]) == 0)) return dp[s][t][w - a ] = 1; ...
#include <bits/stdc++.h> using namespace std; struct str { int q, cost; str(int _q = 0, int _cost = 0) { q = _q; cost = _cost; } bool operator<(const str &two) const { return cost > two.cost; } }; struct edge { int u, v, cost; edge(int _u = 0, int _v = 0, int _cost = 0) { u =...
/** * 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; const int INF = 1e9 + 23; const int MOD = 1e9 + 9; const int MAXN = 1e3 + 100; struct item { int val, type, id; bool operator<(const item &rhs) const { return val > rhs.val; } }; vector<item> items[2]; vector<item> cart[MAXN]; int main() { ios_...
// Generate a test pattern. module LCD_test( input wire clock, input wire reset_n, input wire [6:0] column, input wire [5:0] row, output wire [6:0] character ); /* // Figure out what character to draw. wire [12:0] address = { row, column }; assign character = address[6:0] ^ (row[0] ? 7'h40 : 7'h0...
/** * 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; const int NUM = 2e5 + 5; const int mod = 998244353; int INF = 1e6; pair<int, int> pinf = {INF, INF}; long long bin_pow(int n) { if (n == 0) return 1; if (n % 2 == 0) return bin_pow(n / 2) * bin_pow(n / 2) % mod; return 2 * bin_pow(n - 1) % mod; } ...
module top; string q_tst [$:2]; string q_tmp [$]; bit passed; task automatic check_size(integer size, string fname, integer lineno); if (q_tst.size() !== size) begin $display("%s:%0d: Failed: queue initial size != %0d (%0d)", fnam...
/* verilator lint_off WIDTH */ /* verilator lint_off UNUSED */ module scanline( input clock, // meta data input isDrawArea, input isOsdBgArea, input isScanline, input [8:0] scanline_intensity, // ... input [23:0] data, output reg [23:0] data_out ); localparam ONE_TO_ONE = 9'd_25...
#include <bits/stdc++.h> using namespace std; int main() { long long i, j, k, n; string s, s1, b; cin >> n >> k >> s; b = s; for (i = k; i < n; i++) b[i] = b[i - k]; if (b >= s) cout << n << endl << b << endl; else { for (i = k - 1; i >= 0; i--) { if (b[i] == 9 ) ...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, m, i, j, k, l; cin >> n >> m; string s, t; cin >> s >> t; if (s == t) { cout << Yes << endl; return 0; } long long int present = 0; long long int flag = 0; for (i = 0; i < s.length(); i++) {...
#include <bits/stdc++.h> using namespace std; bool comp(long long a, long long b) { return a > b; } std::vector<long long> fac(500000); void pre() { fac[0] = 1; for (int i = 1; i < 500000; i++) { fac[i] = i * fac[i - 1]; fac[i] %= 998244353; } } long long power(long long x, long long...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 09:26:22 04/13/2015 // Design Name: // Module Name: signex_param // Project Name: // Target Devices: // Tool versions: // Description: // // De...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Mon Jan 23 19:11:23 MST 2017 // Date : Thu Oct 26 22:46:24 2017 // Host : Juice-Laptop running 64-bit major release ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000 * 1000 + 100; int d[MAXN]; int main() { ios::sync_with_stdio(false); long long n, m; cin >> n >> m; long long ans = n * (n - 1) * (n - 2) / 6; ans -= m * (n - 2); for (int i = 0; i < m; i++) { int u, v; cin >...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const long long mod = 1e9 + 7; const int Max = 3e5 + 10; int n; char mp[11][11]; int main() { for (int i = 1; i <= 10; i++) { scanf( %s , mp[i] + 1); } bool ok = false; for (int i = 1; i <= 10 && !ok; i++) { ...
#pragma GCC optimize ( Ofast ) #include<bits/stdc++.h> using namespace std; void*wmem; char memarr[96000000]; template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){ static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; (*mem) = (void*)( ((char*)(*mem)) + sk...
/** * 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, t, tbl[510][510], star[510][510], sum[510]; int main() { scanf( %d%d%d , &n, &m, &t); if (t == 0) { long long ans = 0; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) ans += i * j; cout << ans << endl; return...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2011 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc=0; reg [63:0] crc; reg [63:0] sum; wire [3:0] drv_a = crc[3:0]; w...
// Copyright 1986-2014 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2014.3.1 (lin64) Build Thu Oct 30 16:30:39 MDT 2014 // Date : Wed Apr 8 17:09:37 2015 // Host : parallella running 64-bit Ubuntu 14.04.2 ...
// (C) 1992-2015 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 simulati...
#include <bits/stdc++.h> using namespace std; int main() { int n, bx, x; long long X = 0; cin >> n >> bx; for (int i = 1; i <= n; i++) { cin >> x; X += x * pow(bx, n - i); } int m, by, y; long long Y = 0; cin >> m >> by; for (int i = 1; i <= m; i++) { cin >> y; ...
#include <bits/stdc++.h> const long long MOD = 1000000007; using namespace std; long long ans[2005][2005]; int main() { long long i, j, k; long long A[2005], N, H; cin >> N >> H; for (i = 0; i < N; i++) { cin >> A[i]; } if (A[0] == H - 1) { ans[0][0] = 1; ans[0][1] = 1;...
// -- (c) Copyright 2010 - 2011 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...
/* * 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; struct query { int id, l, x, ans; } qrs[100009]; bool idcomp(query a, query b) { return a.id < b.id; } bool lcomp(query a, query b) { return a.l < b.l; } int N, Q, a[100009], killer[20]; int modExp(int a, int b) { if (b == 0) return 1; int c = modE...
#include <bits/stdc++.h> #pragma GCC optimize( O3 , unroll-loops ) using namespace std; template <class T> inline void sort(T &a) { sort((a).begin(), (a).end()); } template <class T> inline void rsort(T &a) { sort((a).rbegin(), (a).rend()); } template <class T> inline void reverse(T &a) { ...
/** * 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; unordered_map<int, int> Task; unordered_map<int, int> Idle; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int N, K; cin >> N >> K; for (int i = 1; i <= N; i++) { int val; cin >> val; Task[val]++; Idle[i] = val...
#include <bits/stdc++.h> using namespace std; void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __print(float x) { cerr << x; } void __print(double x) { cerr << x; } void __...
(* Import in the following order to minimize trouble: stdlib, old corn things, mathclasses, new corn things *) Require Import Limit. Require Import abstract_algebra orders additional_operations streams series. (* Lemma forall_impl {A} (P Q: ∞ A → Prop) (H1:∀ t, P t → Q t) : ∀ t, ForAll P t → ForAll Q t. Proof. ...
`timescale 1ns/1ns module usb_crossbar (input c, input [15:0] sel, // each nibble says which data source to hear input [39:0] d, // data streaming out of the USB hosts input [4:0] dv, // data-valid from the USB hosts output [31:0] q, // output data to the parsers output [3:0] qv); // output data-valids to the...
#include <bits/stdc++.h> using namespace std; const int maxn = 200000; const long long maxp = 1000000007; int n, m; struct data { int adj, p, p_; }; vector<data> e[maxn]; bool v[maxn]; long long f[maxn][2][2][2]; int con[maxn][2]; void dfs(int x) { v[x] = false; bool flag = false; ...
`include "priority_comp.v" module test_priority(); reg [12:0] control0; reg [12:0] control1; reg [12:0] control2; reg [12:0] control3; wire [1:0] p0, p1, p2, p3; priority_comparator pc(control0, control1, control2, control3, p0, p1, p2, p3); initial begin ...
// // Copyright (c) 1999 Steven Wilson () // // 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) // ...
#include <bits/stdc++.h> using namespace std; struct edge { int to, cost; edge(int to = 0, int cost = 0) : to(to), cost(cost) {} }; vector<edge> vec[100005]; long long int F[100005], G[100005]; int nd[100005]; int n; long long int mpow(long long int m, long long int t) { if (t == 0) return 1...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k; cin >> n >> m >> k; int G[n + 1][m + 1]; memset(G, 0, sizeof(G)); for (int l = 0; l < k; l++) { int i, j; cin >> i >> j; G[i][j] = 1; if ((i > 1 && j > 1 && G[i - 1][j] && G[i][j - 1] && G[i - 1][j - ...
`timescale 1ns / 1ps //************************************************************************* // > ÎļþÃû: regfile.v // > ÃèÊö £º¼Ä´æÆ÷¶ÑÄ£¿é£¬Í¬²½Ð´£¬Òì²½¶Á // > ×÷Õß : LOONGSON // > ÈÕÆÚ : 2016-04-14 //************************************************************************* module regfile( input ...
// Must be run with -gspecify module top; reg passed; reg a, b; wire y; initial begin passed = 1'b1; a = 0; b = 1; #2 if (y !== 1'bx && y !== 1'bz) begin $display("Failed: Initial value, expected 1'bx, got %b", y); passed = 1'b0; end #2 if (y !== 1'b0) begin $display("...
#include <bits/stdc++.h> using namespace std; long long PRIME = 1000000007; long long n, m, k; long long maxm = (long long)(-10e13); long long a[100005][6]; long long max_in_range[100005][6][20]; long long ans[6]; long long times(long long length) { long long cnt = 0; while (length >= 2) { ...
#include <bits/stdc++.h> using namespace std; int N, M; int a[200005], w[200005]; long long qpow(long long x, int n) { long long res = 1; while (n) { if (n & 1) res = res * x % int(998244353); x = x * x % int(998244353); n /= 2; } return res; } long long inv(long long x) { ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int a, b; cin >> a >> b; if ((abs(a - b)) % 2) { cout << -1 << endl; continue; } if (a == b && b == 0) { cout << 0 << endl; continue; } if (...
/* This file is a simple top level that will generate one of four types of Avalon-MM master. As a result all the ports must be declared and it will be up to the component .tcl file to stub unused signals. */ // altera message_off 10034 module custom_master ( clk, reset, // control inputs and outputs ...
///////////////////////////////////////////////////////////////////// //// Author: Zhangfeifei //// //// //// //// Advance Test Technology Laboratory, //// //// Institute of Computing Technol...
#include <bits/stdc++.h> using namespace std; int n, d; int stone[30000 + 3]; int f[30000 + 3][2 * 300 + 3]; int p[30000 + 3]; int main(int argc, char* argv[]) { scanf( %d %d , &n, &d); for (int i = 0; i < n; i++) { int tmp; scanf( %d , &tmp); stone[tmp]++; p[i] = tmp; } ...
#include <bits/stdc++.h> const double pi = 3.1415926535897; using namespace std; int main() { string s; cin >> s; int counter = 0; for (int i = 0; i < s.length(); i++) { if (s[i] == a ) counter++; } if (s.length() / 2 < counter) cout << s.length(); else cout << (coun...
module fifo_fwft_adapter # ( parameter DATA_WIDTH = 0 ) ( input wire clk, input wire rst, input wire rd_en, input wire fifo_empty, output wire fifo_rd_en, input wire [DATA_WIDTH-1:0] fifo_dout, output reg [DATA_WIDTH-1:0]...
#include <bits/stdc++.h> long long n, i, j, h, k, t, d, m, a, b, c; using namespace std; char s; string ss; int main() { cin >> t; for (h = 1; h <= t; h++) { cin >> n; ss = . ; while (n > ss.length()) ss = ss + . ; cin >> a >> b >> c; d = 0; for (i = 0; i < n; i++...
/* Copyright 2018 Nuclei System Technology, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except i...
/** * 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 1986-2017 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2017.3 (lin64) Build Wed Oct 4 19:58:07 MDT 2017 // Date : Tue Oct 17 15:20:13 2017 // Host : TacitMonolith running 64-bit Ubuntu 16.04.3...
#include <bits/stdc++.h> using namespace std; const int N = 250005; int n, k, P, ans, f[30][N], fac[N], ifac[N], inv[N]; inline int ksm(register int x, register int L) { register int ans = 1; while (L) L& 1 ? ans = (0ll + ans) * x % P, 0 : 0, x = (0ll + x) * x % P, L >>= 1; return ans; } i...
/* * 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 main() { int n, x; cin >> n >> x; if (n == 5 && x == 5) { printf( >...v nv.<.. n..^.. n>.... n..^.< n1 1 ); return 0; } if (n == 3 && x == 2) { printf( >vv n^<. n^.< n1 3 ); return 0; } for (int i = 0; i < 50; i++)...
#include <bits/stdc++.h> const long long int N = 2e5 + 5; using namespace std; int main() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); long long int x, y, a, b; cin >> x >> y >> a >> b; vector<pair<long long int, long long int>> mp; for (int i = a; i <= x; i++) { fo...
// 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 : Tue May 30 22:27:54 2017 // Host : GILAMONSTER running 64-bit major release (...