text
stringlengths
59
71.4k
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2003 by Wilson Snyder. module t; real n0; initial n0 = 0.0; real n1; initial n1 = 1.0; real n2; initial n2 = 0.1; real n3; initial n3 = 1.2345e-15; real n4; initial n4 ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2017 by Wilson Snyder. module t (/*AUTOARG*/ // Outputs dout, // Inputs clk, rstn, dval0, dval1 ); input clk; input rstn; output wire [7:0] dout; input [7...
#include <bits/stdc++.h> using namespace std; int main() { int n, a[100001], i; set<int> mysetp, mysetn, left, right; set<int>::iterator l, r, p; scanf( %d , &n); scanf( %d , &a[1]); mysetn.insert(-a[1]); mysetp.insert(a[1]); for (i = 2; i <= n; i++) { scanf( %d , &a[i]); ...
#include <bits/stdc++.h> using namespace std; struct ring { int c1; int c2; int r1; int r2; }; int contour(struct ring a, struct ring b, double dist) { int cnt = 0; if (dist >= a.r2 + b.r2 || dist <= b.r1 - a.r2 || dist <= a.r2 - b.r2) cnt++; if (dist >= a.r1 + b.r2 || dist <= b.r1 -...
module scratch_pad_gold_tb; `include "log2.vh" `define PORTS 16 `define WIDTH 64 `define DEPTH `PORTS*512 `define ADDR_WIDTH log2(`DEPTH-1) reg rst, clk; reg [0:`PORTS-1] rd_en, wr_en; reg [`PORTS*`WIDTH-1:0] d; wire [`PORTS*`WIDTH-1:0] q; reg [`PORTS*`ADDR_WIDTH-1:0] addr; r...
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n; cin >> n; vector<long long> arr(n); for (long long i = 0; i < n; i++) { cin >> arr[i]; } sort(arr.begin(), arr.end()); if (arr[n ...
/* Copyright (C) 2015-2016 by John Cronin * * 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, pu...
/** * 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; inline int Get() { int res = 0, q = 1; char ch = getchar(); while ((ch < 0 || ch > 9 ) && ch != - ) ch = getchar(); if (ch == - ) q = -1, ch = getchar(); while (ch >= 0 && ch <= 9 ) res = res * 10 + ch - 0 , ch = getchar(); return res * ...
#include <bits/stdc++.h> using namespace std; const long long M = (long long)1e9 + 7; const double PI = 2 * acos(0.0); const long long oo = 1e17 + 100; const string DIGITS = 0123456789 , alph = abcdefghijklmnopqrstuvwxyz , ALPH = ABCDEFGHIJKLMNOPQRSTUVWXYZ ; const long long N = (long long)...
#include <bits/stdc++.h> using namespace std; using tint = tuple<int, int, int>; const int maxn = 200004; int N, M; tint a[maxn]; struct dsu { dsu() { iota(p, p + maxn, 0); } int p[maxn], add[maxn]; int root(int k) { return p[k] != k ? p[k] = root(p[k]) : k; } bool connect(int x, int y) { ...
#include <bits/stdc++.h> int main() { int g[6] = {0, 2, 3, 1, 2, 1}, i; while (scanf( %d , &i) == 1) { printf( %d n , g[i]); } 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 law...
#include <bits/stdc++.h> using namespace std; int n, m, n1, m1; double dp[1002][1002], ans, c[1003][1003]; int main() { scanf( %d %d , &n, &m); scanf( %d%d , &n1, &m1); if (n == n1) ans = 0.000000; else if (m == 1) dp[n1][m1] = 2 * (n - n1); else { for (int i = n - 1; i >= ...
#include <bits/stdc++.h> using namespace std; constexpr int inf = 1e9 + 5; void umin(int& a, int b) { a = min(a, b); } void umax(int& a, int b) { a = max(a, b); } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<array<int, 2>> a(n); for (auto& ai : a) { ...
#include <bits/stdc++.h> using namespace std; int n, m, k; int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, 1, 0, -1}; vector<string> museum; vector<vector<int> > pictures; vector<vector<bool> > used; queue<pair<int, int> > line; vector<pair<int, int> > req; void BFS(int& i, int& j) { line.push(make_p...
#include <bits/stdc++.h> using namespace std; long long n, x, y; long long dp[10000005]; int main(void) { scanf( %lld%lld%lld , &n, &x, &y); dp[1] = x; for (int i = 2; i <= n; ++i) { if (i & 1) { dp[i] = min(dp[i - 1] + x, dp[(i + 1) >> 1] + x + y); } else dp[i] = min(dp[...
#include <bits/stdc++.h> using namespace std; struct point { int x, y, l, r; }; bool f(point a, point b) { return a.r > b.r; } point a[5000]; int par[5000]; void init(int n) { for (int i = 1; i <= n; i++) par[i] = i; } int root(int n) { if (par[n] == n) return n; return par[n] = root(p...
#include <bits/stdc++.h> using namespace std; long long int max(long long int a, long long int b) { if (a > b) return a; else return b; } long long int min(long long int a, long long int b) { if (a < b) return a; else return b; } const int dx[4] = {-1, 1, 0, 0}; con...
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define ppb pop_back #define pf push_front #define ppf pop_front #define all(x) (x).begin(),(x).end() #define uniq(v) (v)....
#include <bits/stdc++.h> using namespace std; template <class T> void read(T& x) { T res = 0, f = 1; char c = getchar(); while (!isdigit(c)) { if (c == - ) f = -1; c = getchar(); } while (isdigit(c)) { res = (res << 3) + (res << 1) + c - 0 ; c = getchar(); } x...
module scratch_pad_gold(rst, clk, rd_en, wr_en, d, q, addr, stall, valid, full); parameter PORTS = 8; parameter WIDTH = 64; parameter FRAGMENT_DEPTH = 512; parameter DEPTH = FRAGMENT_DEPTH * PORTS; parameter ADDR_WIDTH = log2(DEPTH-1); parameter PORTS_ADDR_WIDTH = log2(PORTS-1); input rst; ...
// wasca_mm_interconnect_0_avalon_st_adapter_006.v // This file was auto-generated from altera_avalon_st_adapter_hw.tcl. If you edit it your changes // will probably be lost. // // Generated using ACDS version 15.1 193 `timescale 1 ps / 1 ps module wasca_mm_interconnect_0_avalon_st_adapter_006 #( parameter inBits...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long t; cin >> t; w...
// ============================================================== // 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...
#include <bits/stdc++.h> using namespace std; template <typename T> void chkmin(T &a, T b) { a = min(a, b); } template <typename T> void chkmax(T &a, T b) { a = max(a, b); } inline int fread(void) { int ret = 0, op = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) ...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long LL_INF = 0x3f3f3f3f3f3f3f3f; const double PI = 3.14159265359; const int mod = 1000 * 1000 * 1000 + 7; int dx[4] = {1, -1, 0, 0}; int dy[4] = {0, 0, 1, -1}; string s; int dp[100005]; int solve(int idx) { if ...
#include <bits/stdc++.h> using namespace std; int main() { int m, n, i, j, k; scanf( %d%d , &n, &m); vector<int> A; for (i = 0; i < n; i++) A.push_back(i + 1); int M = 0; do { int s = 0; for (i = 0; i < n; i++) { for (j = i + 1; j < n + 1; j++) { int s1 = 1000; ...
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; int n, k; int a[2011]; long long pre[1 << 11 + 1]; long long cur[1 << 11 + 1]; void solve() { memset(pre, 0, sizeof(pre)); pre[0] = 1; for (int i = 0; i < n; i++) { memset(cur, 0, sizeof(cur)); for (int...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int jou[n + 1]; vector<bool> u(n + 1, false); int k = 1; for (int i = 1; i < n + 1; i++) { cin >> jou[i]; if (u[jou[i]] == false) { u[jou[i]] = true; ...
// -*- Mode: Verilog -*- // Filename : uart_regs.v // Description : UART Registers // Author : Philip Tracton // Created On : Wed May 27 17:22:20 2015 // Last Modified By: Philip Tracton // Last Modified On: Wed May 27 17:22:20 2015 // Update Count : 0 // Status ...
/** * 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> #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma ) #pragma GCC optimize( unroll-loops ) using namespace std; long long MOD9 = 998244353; long long MOD = 1000000007; double eps = 1e-12; void solve() { int n; cin >> n; ...
#include <bits/stdc++.h> using namespace std; int n; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n; if (n & 1) cout << (n / 2) * (n / 2 + 1); else cout << (n / 2) * (n / 2); cout << n ; for (int i = 1; i <= n / 2; i++) for (int j = n / 2 + 1; j <= n...
#include <bits/stdc++.h> using namespace std; const int N = 200001; const int INF = 1061109567; int n, m; struct Edge { int to, val, id, next; } edge[N << 1]; int head[N], cnt; void add_edge(int u, int v, int w, int id) { cnt++; edge[cnt].to = v; edge[cnt].val = w; edge[cnt].id = id;...
/* * yosys -- Yosys Open SYnthesis Suite * * Copyright (C) 2018 Miodrag Milanovic <> * Copyright (C) 2012 Claire Xenia Wolf <> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this...
// Accellera Standard V2.3 Open Verification Library (OVL). // Accellera Copyright (c) 2005-2008. All rights reserved. `ifdef OVL_ASSERT_ON wire xzcheck_enable; `ifdef OVL_XCHECK_OFF assign xzcheck_enable = 1'b0; `else `ifdef OVL_IMPLICIT_XCHECK_OFF assign xzcheck_enable = 1'b0; `else assign xzcheck...
#include <bits/stdc++.h> using namespace std; int n; double first[10005], second[10005], w, u, v; double eps = 1e-9; signed main() { ios::sync_with_stdio(0); cin.tie(NULL), cout.tie(NULL); cin >> n >> w >> u >> v; for (int i = 0; i < n; i++) cin >> first[i] >> second[i]; double ans = w / v...
/* * Copyright 2012, Homer Hsing <> * * 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; const int maxn = 100005; const int INF = 0x3f3f3f3f; const double pi = acos(-1.0); const double eps = 1e-9; template <class T> inline void read(T &x) { int c; for (c = getchar(); c < 32 && ~c; c = getchar()) ; for (x = 0; c > 32; x = x * 10 +...
#include <bits/stdc++.h> using namespace std; unsigned long long B[31][31], res = 0; int main(void) { for (int i = 0; i <= 30; i++) { B[i][0] = B[i][i] = 1; for (int j = 1; j < i; j++) B[i][j] = B[i - 1][j - 1] + B[i - 1][j]; } int n, m, k; cin >> n >> m >> k; for (int b = 4; b < k...
module alu (ALUop, a, b, result, clk, hi_data, lo_data); input [3:0] ALUop; input [31:0] a, b; input clk; output [31:0] hi_data; output [31:0] lo_data; output reg [31:0] result; reg [63:0] tem64; reg [31:0] HI, LO; assign hi_data = HI[31:0]; assign lo_data = LO[31:0]; initial begin HI <= 32'h...
/** * 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 N = 3005; int n, m, k, p[N]; bool vis[N]; inline void mk(int v) { for (int i = v; !vis[i]; i = p[i]) vis[i] = 1; } int main() { while (~scanf( %d , &n)) { for (int i = 0; i < n; ++i) scanf( %d , &p[i]), --p[i]; scanf( %d , &m); ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 15:56:24 03/17/2015 // Design Name: // Module Name: alu // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencie...
/** * 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...
//Legal Notice: (C)2016 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 associate...
/** * 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...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 03.06.2015 14:58:39 // Design Name: // Module Name: harness // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revis...
module StepDecoder(output [15:0] TimeSteps, input [3:0]StepCounter); and and1(TimeSteps[0], ~StepCounter[3], ~StepCounter[2], ~StepCounter[1], ~StepCounter[0]); and and2(TimeSteps[1], ~StepCounter[3], ~StepCounter[2], ~StepCounter[1], StepCounter[0]); and and3(TimeSteps[2], ~StepCounter[3], ~StepCounter[2], St...
#include <bits/stdc++.h> using namespace std; void dbg_out() { cerr << b b] n ; } template <typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << H << , ; dbg_out(T...); } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); string s; cin >> s; ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000006; long long num[MAXN << 2]; long long sum[MAXN << 2]; long long N; void pushup(int rt) { num[rt] = num[rt << 1] + num[rt << 1 | 1]; sum[rt] = sum[rt << 1] + sum[rt << 1 | 1]; } void update(int P, int C, int l, int r, int rt) {...
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 20, MAX2 = 1e7 + 10; int an[MAX], n, x; bool primes[MAX2]; void seive(long long n) { for (long long i = 2; i <= n; i++) primes[i] = 1; for (long long i = 2; i <= n; i++) { if (primes[i] == 1) { for (long long j = i * i; ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1005; int n, a[MAXN]; vector<int> ans; int main() { scanf( %d , &n); ans.reserve(n); for (int i = 1; i <= n; ++i) scanf( %d , &a[i]); a[n + 1] = 1; for (int i = 1; i <= n; ++i) if (a[i + 1] == 1) ans.push_back(a[i]); ...
#include <bits/stdc++.h> int gcd(int a, int b) { if (a == 0) return b; else return (b % a, a); } using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int a[n]; long long sum = 0; for (int i = 0; i < n; i++) { ci...
#include <iostream> #include <sstream> #include <cstdio> #include <cmath> #include <cstring> #include <cctype> #include <string> #include <vector> #include <set> #include <unordered_set> #include <map> #include <unordered_map> #include <queue> #include <stack> #include <algorithm> #include...
`include "riscv_functions.vh" module riscv_mem ( input clk, input rstn, //Downstream input ex_mem_rdy, output ex_mem_ack, //MEM input input [31:0] ex_mem_result, input [`MEM_FUNCT_W-1:...
#include <bits/stdc++.h> using namespace std; char s[20005]; struct SuffixArray { int wa[20005], wb[20005], cnt[20005], wv[20005]; int rk[20005], height[20005]; int sa[20005]; bool cmp(int r[], int a, int b, int l) { return r[a] == r[b] && r[a + l] == r[b + l]; } void calcSA(char r[]...
#include <bits/stdc++.h> using namespace std; const int maxn = 502; vector<int> adj[maxn]; bool vis[maxn]; bool fin[maxn]; vector<pair<int, int> > edgesInCycle; int n; bool dfs(int node) { vis[node] = 1; for (int ch : adj[node]) { edgesInCycle.push_back({node, ch}); if (!vis[ch]) { ...
#include <bits/stdc++.h> using namespace std; vector<string> substrings; bool cmp(pair<int, int> &a, pair<int, int> &b) { if (a.first < b.first) return true; if (a.first > b.first) return false; if (substrings[a.second].length() > substrings[b.second].length()) return true; return false; }...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, c = 0, temp; int h[101], g[101]; cin >> n; for (int i = 0; i < n; i++) { cin >> h[i] >> g[i]; } for (int j = 0; j < n; j++) { temp = n - 1; while (temp > j) { ...
// megafunction wizard: %RAM: 1-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: arriagx_pmem.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // ===========================...
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; while (t--) { long long int n, i, zer = -1, one; cin >> n; string s; string ans = ; cin >> s; for (i = 0; i < n; i++) { if (s[i] == 1 ) break; zer = i; } ...
/* ENGINNER: Mateusz Okulanis PROJECT: OM_FIREWALL MODULE: eth_mac_l2_testbench SCENARIO: 1. PREAMBLE 2. SFD */ module eth_mac_l2_testbench(); reg Clk; reg Rst_n; reg Enet0_Rx_Data; reg Enet0_Rx_Dv; reg Enet0_Rx_Er; wire avalonST_1_valid_wire; wire [7:0] avalonST_1_data_wire; wire avalonST_1_channel_wire; wire a...
/* Module from the schematic_gui program written by Andreas Ehliar <> This Verilog file is licensed under the CC0 license. */ module mult #(parameter WIREWIDTH = 1) (input wire clk, input wire [WIREWIDTH:0] x,y, output reg [WIREWIDTH:0] res); /* FIXME: reswidth! */ initial begin $schematic_boundi...
#include <bits/stdc++.h> using namespace std; void solve() { string s; cin >> s; int n = s.length(); int r = 0; vector<int> f(3, -1); f[0] = 0; vector<int> z(n + 1); for (int i = 1; i < (n + 1); ++i) { r = (r + s[i - 1] - 0 ) % 3; z[i] = z[i - 1]; if (f[r] != -1) z...
/** * This is written by Zhiyang Ong * and Andrew Mattheisen */ `timescale 1ns/100ps /** * `timescale time_unit base / precision base * * -Specifies the time units and precision for delays: * -time_unit is the amount of time a delay of 1 represents. * The time unit must be 1 10 or 100 * -base is the time bas...
#include <bits/stdc++.h> typedef long long LL; const double INF = 1e100; const int oo = ~0u >> 2; const double pi = acos(-1.0); const double EPS = 1e-8; const int MAXN = 100033; double a, b, c; double x11, x2; int main() { scanf( %lf%lf%lf , &a, &b, &c); x11 = sqrt(b * b - 4.0 * a * c); if...
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; long long n; bool valid(long long x) { long long a = 0, b = 0; long long r = n; while (r) { a += min(r, x); r -= min(r, x); b += r / 10; r -= r / 10; } return a >= b; } signed main() { io...
Require Import Verdi.Verdi. Require Import Verdi.HandlerMonad. Require Import Verdi.NameOverlay. Require Import Verdi.LabeledNet. Require Import TreeAux. Require Import ZTreeAggregationDynamicLabeled. Require Import InfSeqExt.infseq. Require Import Relation_Definitions. Require Import Relation_Operators. Require Im...
// 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 : Fri Jan 13 17:34:00 2017 // Host : KLight-PC running 64-bit major release (bu...
// Accellera Standard V2.5 Open Verification Library (OVL). // Accellera Copyright (c) 2005-2010. All rights reserved. `include "std_ovl_defines.h" `module ovl_handshake (clock, reset, enable, req, ack, fire); parameter severity_level = `OVL_SEVERITY_DEFAULT; parameter min_ack_cycle = 0; parameter max_ack_cyc...
#include <bits/stdc++.h> using namespace std; const int maxN = (int)2e5 + 10; const int maxM = (int)4e5 + 10; int n, m, k, type[maxN], a[maxN], pa[maxN]; long long d[maxN]; vector<int> c[maxN], w[maxN]; set<pair<long long, int> > s; int en, ea[maxM], eb[maxM], ep[maxM]; long long ew[maxM]; inline bo...
/** * 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() { ios::sync_with_stdio(false); int n, pos; string s; cin >> n >> s; bool flag = false; for (int i = 1; i < n; i++) { if (s[i] == s[i - 1]) continue; else { flag = true; pos = i; break; ...
#include <bits/stdc++.h> using namespace std; template <class T> void sf(T &res) { int f = 1; char c; res = 0; while (c = getchar(), !isdigit(c)) ; if (c == - ) f = -1, c = getchar(); do res = (res << 1) + (res << 3) + (c ^ 48); while (c = getchar(), isdigit(c)); res *= f; ...
#include <bits/stdc++.h> using namespace std; long long rdtsc() { long long tmp; asm( rdtsc : =A (tmp)); return tmp; } inline int myrand() { return abs((rand() << 15) ^ rand()); } inline int rnd(int x) { return myrand() % x; } const int maxn = (int)1600 + 10; int a[maxn][maxn]; int used[ma...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: jbi_min_rq_rdq_ctl.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 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...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2021 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 `define stop $stop `define checkh(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 12:42:54 04/15/2015 // Design Name: // Module Name: digital_display_4 // Project Name: // Target Devices: // Tool versions: // Description: // // Dependenci...
#include <bits/stdc++.h> using namespace std; int n, a, b, ed; double p, M; long long T; vector<pair<double, double> > v; pair<double, double> sta[100004]; double cros(pair<double, double> a, pair<double, double> b) { return (b.second - a.second) / (a.first - b.first); } double r[100004], ret; d...
// megafunction wizard: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: scfifo // ============================================================ // File Name: fifo_139_256.v // Megafunction Name(s): // scfifo // // Simulation Library Files(s): // altera_mf // ==============================...
#include <bits/stdc++.h> using namespace std; long long T, m, n, q, w, mi, ma, cnt, s, t, fi, cc, e, r, z, x, an, anx, any, cx, cy; long long d[5][2]; int main() { scanf( %I64d%I64d , &m, &n); scanf( %I64d%I64d , &e, &r); scanf( %I64d%I64d , &cx, &cy); for (int i = 0; i < 4; i++) { q...
/* * NAME * ---- * * decoder - specialized decoder * * DESCRIPTION * ----------- * * This is a specialized decoder designed * to map the 7-bit addresses to the following * active low enable signals. * * Full address decoding is used so devices cannot * be inadvertly addressed using out of bounds address...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); const double eps = 1e-9; const int inf = 2000000000; const long long infLL = 90000000000000000; inline bool checkBit(long long n, int i) { return n & (1LL << i); } inline long long setBit(long long n, int i) { return n | (1LL <<...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5, oo = 0x3f3f3f3f; pair<int, int> stop[maxn]; int nxt[maxn]; int main(void) { int d, n, m; scanf( %d%d%d , &d, &n, &m); int x, y; for (int i = 1; i <= m; i++) { scanf( %d%d , &x, &y); stop[i] = pair<int, int>(x, ...
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j = 0, r, ctr = 0, ans; cin >> n; string s, s7; cin >> s; string s1 = RGB ; string s2 = GBR ; string s3 = BGR ; string s4 = GRB ; string s5 = RBG ; string s6 = BRG ; j = 0; for (i = 0; i < n; i...
#include <bits/stdc++.h> using namespace std; bool isPowerOfTwo(int n) { if (n == 0) return false; return (ceil(log2(n)) == floor(log2(n))); } void asquare() { long long n, c = 0, ans = LONG_LONG_MAX; cin >> n; string sn; if (isPowerOfTwo(n) == true) cout << 0 n ; else { ...
#include <bits/stdc++.h> using namespace std; bool collinear(int x1, int y1, int x2, int y2, int x3, int y3) { return (y1 - y2) * (x1 - x3) == (y1 - y3) * (x1 - x2); } int main() { int n, x, y; cin >> n; vector<pair<int, int> > points; for (int i = 0; i < n; i++) { cin >> x >> y; ...
/* * 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> using namespace std; int main() { int n; cin >> n; int h[n]; for (int i = 0; i < n; i++) { cin >> h[i]; } int wys[n][2]; int rosnpr = 0; int rosnlw = 0; for (int i = 0; i < n; i++) { if (h[i] > rosnpr) { rosnpr++; wys[i][0] = r...
// This program is based on pr2138979. In particular, the signed // expressions are sign-extended before the '|' is evaluated. This // behavior is verified by modelsim and ncverilog. (It appears that // gplcver gets this wrong.) module main; reg [7:0] a, b; wire [15:0] y; reg [15:0] z; // Use $signed(...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const int N = 1e5; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int tc, ca = 0; cin >> tc; while (tc--) { int n, el; vector<int> v; cin >> n; for (int i = 0; i ...
#include <bits/stdc++.h> using namespace std; int a, x, y, xx, yy; int main() { cin >> a >> x >> y >> xx >> yy; if (abs(x - xx) == a) cout << a + min(2 * a - y - yy, y + yy); else if (abs(y - yy) == a) cout << a + min(2 * a - x - xx, x + xx); else cout << abs(xx - x) + abs(yy - y...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx ) template <class T = int> inline T readInt(); inline double readDouble(); inline int readUInt(); inline int readChar(); inline void readWord(char *s); inline bool readLine(char *s); ...
module clkgen(input wire clkin, input wire clk25m_on, output wire clkout, output wire [3:0] clk25m, output wire locked); //reg cnt ; wire clkout_div ; //always @ ( posedge clkout ) // cnt <= ~cnt ; //assign clk25m = cnt ; //assign clk25m = clkout_div ; ODDR2 ODDR2_inst0 ( .Q (clk25m[0]), // 1-bit DDR output data ...
#include <bits/stdc++.h> using namespace std; const int MAX = 18; string color[MAX]; int r[MAX], b[MAX]; map<pair<int, int>, int> dp[1 << MAX]; int n; int func() { dp[0][make_pair(0, 0)] = 0; int ans = INT_MAX; for (int mask = 0; mask < (1 << n); mask++) { int R = 0, B = 0; for (in...
/* * Copyright (c) 2000 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) * ...