text
stringlengths
59
71.4k
`define RegBankP4_NOP 4'h0 `define RegBankP4_LD0 4'h1 `define RegBankP4_LD1 4'h2 `define RegBankP4_LD2 4'h3 `define RegBankP4_LD3 4'h4 `define RegBankP4_State_Reset 2'h0 `define RegBankP4_State_Ready 2'h1 `define RegBankP4_State_Error 2'h2 module RegBankP4(clock,reset,inst,inst_en,out_0,out_1,out_2,out_3); input w...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n % 47 == 0 || n % 744 == 0 || n % 4 == 0 || n % 7 == 0 || n % 44 == 0 || n % 444 == 0 || n % 777 == 0 || n % 74 == 0 || n % 447 == 0 || n % 474 == 0 || n % 477 == 0) { cout << YES ; } else { ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 09:55:21 04/14/2015 // Design Name: // Module Name: BCD7segment // Project Name: // Target Devices: // Tool versions: // Description: // // Dep...
#include <bits/stdc++.h> using namespace std; const long long inf = (long long)1e18; const long long mod = (long long)1e9 + 7; const double eps = (double)1e-9; const double pi = acos(-1.0); const int dx[] = {0, 0, 1, 0, -1}; const int dy[] = {0, 1, 0, -1, 0}; const int N = 300500; int n, dp[N]; vect...
/* * 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() { long long t; cin >> t; while (t--) { long long n; cin >> n; long long k = (n + 1) / 2; k = k - 1; long long ans = 0; for (long long i = 1; i <= k; ++i) { ans += 8 * i * i; } cout << ans << ...
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 5; long long INF = 1e18; int n, s; vector<int> ans; long long ansV = 0; long long dis[N]; int edge[N], val[N]; vector<pair<int, int> > adj[N]; void solve() { for (int i = 1; i <= n; i++) dis[i] = INF; priority_queue<pair<long ...
#include <bits/stdc++.h> using namespace std; int n; bool check(vector<vector<char>>& v, int x, int y) { if (x + 2 >= 0 && y - 1 >= 0 && y + 1 < n && v[x + 1][y] == # && v[x + 2][y] == # && v[x + 1][y + 1] == # && v[x + 1][y - 1] == # ) { v[x][y] = v[x + 1][y] = v[x + 2][y] = v[x + 1][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 la...
module main; wire [7:0] bus; reg [7:0] HiZ; assign bus = HiZ; reg E; reg D; reg CLK; BUFT drv (bus[0], D, E, CLK); bufif0 drv0 (bus[0], D, E); initial begin HiZ = 8'hzz; D = 1; E = 1; CLK = 0; #1 CLK = 1; #1 if (bus !== 8'bzzzzzzz...
#include <bits/stdc++.h> using namespace std; int kmp(string s) { vector<int> lps(s.size(), 0); for (int i = 1; i < s.size(); ++i) { int index = lps[i - 1]; while (index > 0 && s[i] != s[index]) index = lps[index - 1]; if (s[i] == s[index]) lps[i] = index + 1; else lp...
////////////////////////////////////////////////////////////////////// //// //// //// uart_tfifo.v //// //// //// //// ...
/** * 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 Maxn = 1005; int n, m, k; long long s[Maxn][Maxn], sl[Maxn][Maxn], sr[Maxn][Maxn]; inline int get() { char ch; while (!isdigit(ch = getchar())) ; int v = ch - 48; while (isdigit(ch = getchar())) v = v * 10 + ch - 48; return v; ...
#include <bits/stdc++.h> using namespace std; #define int long long void solve() { int n, m, k; cin >> n >> m >> k; vector<tuple<int, int, int>> edges(m + 2), edges_large, edges_small; vector<int> values; for (int i = 1; i <= m; i++) { int a, b, c; c...
module demo_text ( input wire clk, input wire [10:0] pix_x, pix_y, output wire [3:0] text_on, output reg [2:0] text_rgb ); // signal declaration wire [10:0] rom_addr; reg [6:0] char_addr, char_addr_s, char_addr_l, char_addr_r, char_addr_o; reg [3:0] row_addr; wire [3...
// megafunction wizard: %RAM: 2-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: cordic_ram.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // =============================...
#include <bits/stdc++.h> using namespace std; long long mod = 1e9 + 7; long long min(long long a, long long b) { return (a < b) ? a : b; } long long max(long long a, long long b) { return (a > b) ? a : b; } long long fp(long long a, long long b) { if (b == 0) return 1; long long x = fp(a, b / 2); ...
// ============================================================== // 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 = 5000; const int B = 33; const int P = 1e6 + 3; string s[2]; int ans, Max[2][maxn], dp1[maxn][maxn], dp2[maxn][maxn], dp3[maxn][maxn]; inline void make(const string &x, const string &y, int dp[maxn][maxn]) { for (int i = 0; i < x.size(); i+...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 40; const long long INFLL = 1e18; long long dp[N][3][2][2]; signed main() { srand(time(NULL)); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; long long r1, r2, r3, d; cin >> n >> r1 >> r2 >> r3 >> ...
/** * 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...
/** * bsg_cache_non_blocking_pkt_decode.v * * @author tommy * */ `include "bsg_defines.v" module bsg_cache_non_blocking_decode import bsg_cache_non_blocking_pkg::*; ( input bsg_cache_non_blocking_opcode_e opcode_i , output bsg_cache_non_blocking_decode_s decode_o ); always_comb begin case...
#include <bits/stdc++.h> using namespace std; void err(istream_iterator<string> it) {} template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << = << a << n ; err(++it, args...); } long long powMod(long long x, long long y) { long lon...
/** * 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 long long N = 505, M = 1e9 + 7; long long K, m, n, a[N], H[N], num[N], F[N], G[N], x, ans[N], C[N]; inline long long ksm(long long x, long long y) { long long ans = 1; for (; y; y >>= 1, x = x * x % M) if (y & 1) (ans *= x) %= M; return ans; ...
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } void dv(vector<int> v) { for (int i = 0; i < v.size(); i++) cout << v[i] << ; } bool check_prime(int a) { for (int i = sqrt(a); i > 1; i--) { if (a % ...
#include <bits/stdc++.h> using namespace std; int N, M; int main() { cin >> M >> N; if (M == N) { cout << N << 1 << << N << 2 ; return 0; } if (N - M == 1) { cout << M << 9 << << N << 0 ; return 0; } if (M == 9 && N == 1) { cout << 9 10 ; ...
#include <bits/stdc++.h> using namespace std; int n, m; vector<pair<int, int> > a; long long sum, ans; int e, deg; int get_e(int num, int deg) { if (num == 1) return 0; if (num == 2) return 1; int res = num * (num - 1) / 2; if (deg & 1) { int bad = num - 2; res += bad / 2; } ...
#include <bits/stdc++.h> using namespace std; ifstream input; ofstream output; int main(int argc, char *argv[]) { input.sync_with_stdio(false); output.sync_with_stdio(false); int n, tmp, tmp2; priority_queue<int> y; set<int> used; cin >> n; for (int i = 0; i < n; i++) { cin >> ...
#include <bits/stdc++.h> using namespace std; const long long N = 50, INF = 0, MOD = 0; long long n, m, a[N], tmp; vector<long long> v; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> m >> n; for (long long i = 0; i < n; i++) { cout << 1 << endl; fflush(std...
//------------------------------------------------------------------- //-- prescaler_tb.v //-- Banco de pruebas para el prescaler //------------------------------------------------------------------- //-- BQ August 2015. Written by Juan Gonzalez (Obijuan) //--------------------------------------------------------------...
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; const int N = 100005; long long f[N]; long long inverse(long long x) { if (x >= mod) return inverse(x % mod); assert(x != 0); if (x == 1) return 1; return inverse(mod % x) * (mod - mod / x) % mod; } int main() ...
/** * 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, a[10], b[10]; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < m; i++) { cin >> b[i]; } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (a[i] == b[...
#include <bits/stdc++.h> using namespace std; long long int a, b, c, d, n, i, cnt = 0, snt = 0; float f, flo, fload = 0; string s, h, o, name; int main() { ios_base::sync_with_stdio(0); setlocale(LC_ALL, Russian ); ; string t; size_t i; getline(cin, t, n ); while ((i = t.find( ...
// test_simulation_mod_1_xx.v module f1_test(in1, in2, out); input in1; input in2; output out; wire synth_net_0; wire synth_net_1; BUF synth_BUF_0(.in(synth_net_1), .out(out )); DIV1 synth_DIV(.in1(in1), .in2(in2), .rem(synth_net_0), .out(synth_net_1 )); endmodule // test_simulation_always_31_tt.v module f2...
#include <bits/stdc++.h> using namespace std; int main() { int a1, a2, k1, k2; int n; cin >> a1 >> a2 >> k1 >> k2 >> n; int n1 = n, n2 = n; n1 -= (a1 * (k1 - 1)); n1 -= (a2 * (k2 - 1)); if (n1 <= 0) cout << 0 << ; else cout << n1 << ; if (k1 > k2) { if (n2...
#include <bits/stdc++.h> using namespace std; const int N = 20009; int INF = 2e9; struct edge { int to, cap, rev; edge() {} edge(int tt, int cc, int rr) { to = tt; cap = cc; rev = rr; } }; vector<edge> Graph[N]; int level[N]; int iter[N]; void add_edge(int from, int t...
/** * Module: arbiter * * Description: * A look ahead, round-robing parametrized arbiter. * * <> request * each bit is controlled by an actor and each actor can 'request' ownership * of the shared resource by bring high its request bit. * * <> grant * when an actor has been given ownership of shared reso...
#include <bits/stdc++.h> using namespace std; int size_n, size_m; set<int> result; vector<char> marks(0); vector<string> mrk(0); int main() { int ii, jj; string str; cin >> size_n >> size_m; marks.resize(size_m); mrk.resize(size_n); cin.ignore(); for (ii = 0; ii < size_m; ii++) m...
#include <bits/stdc++.h> using namespace std; bool comp(int x, int y) { return x > y; } int main() { int t = 1; cin >> t; int n; while (t--) { cin >> n; if (n == 1 || n == 2) { cout << 1 << n ; continue; } if (n & 1) cout << n / 2 + 1 << n ; ...
/** * 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 premuat_4( i_0, i_1, i_2, i_3, o_0, o_1, o_2, o_3 ); // ******************************************** // // INPUT / OUTPUT...
/** * 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...
// -*- Mode: Verilog -*- // Filename : pb_display.v // Description : Seven Segment Display // Author : Philip Tracton // Created On : Thu May 28 23:25:10 2015 // Last Modified By: Philip Tracton // Last Modified On: Thu May 28 23:25:10 2015 // Update Count : 0 //...
#include <bits/stdc++.h> using namespace std; double dist(long long int a, long long int b, long long int c, long long int d) { return sqrt(((a - c) * (a - c)) + (b - d) * (b - d)); } struct p { double val; long long int index; }; int comp(const void* a, const void* b) { if (((...
module top; reg passed = 1'b1; wire out, cout0, cout1; reg sel, in_1, in_0; reg pout; assign cout0 = sel ? 1'bz : in_0; assign cout1 = sel ? in_1: 1'bz; assign out = sel ? in_1: in_0; task automatic check; input bit, in_1, in_0; input [63:0] comment; reg z2x; begin if (sel === 1'...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimization( unroll-loops, no-stack-protector ) #pragma GCC target( avx,avx2,fma ) using namespace std; using pii = pair<int, int>; using pll = pair<long long, long long>; using vb = vector<bool>; using vi = vector<int>; using vl = ve...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long x; cin >> x; for (long long i = 0; i <= 1000; i++) { for (long long j = 0; j <= 10000; j++) { long long g = i * 1234567 + j * 123456; long l...
/** * 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 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 = int(1e5 + 3); using namespace std; bool is_prime(int n) { if (n == 2) return true; if (n % 2 == 0) return false; for (int i = 2; i * i <= n; ++i) if (n % i == 0) return false; return true; } void solve() { long long n; cin >> n; long lon...
#include <bits/stdc++.h> using namespace std; string s; long long fastpow(int b, int e) { if (!e) return 1; if (e & 1) return b * fastpow(b, e - 1); long long temp = fastpow(b, e / 2); return temp * temp; } int notwork(char a, char b) { set<char> s; s.insert(a); s.insert(b); if...
#include <bits/stdc++.h> using namespace std; struct Number { array<int, 4> x = {{0, 0, 0, 0}}; Number() {} Number(int a) { if (a != -1) x[a]++; } long double log_value() const { if (x[0] > 0) return -INFINITY; return x[2] * log(2L) + x[3] * log(3L); } int mod() const {...
#include <bits/stdc++.h> using namespace std; int n, r; vector<pair<int, int> > pos, L, R; vector<int> ans; map<pair<int, int>, int> vis; bool cmp(pair<int, int> a, pair<int, int> b) { return a.first + a.second < b.first + b.second; } int main() { cin >> n >> r; for (int i = 0; i < n; i++) {...
#include <bits/stdc++.h> using namespace std; struct graph { int n; vector<vector<int>> adj; graph(int n) : n(n), adj(n) {} void add_edge(int u, int v) { adj[u].push_back(v); } vector<int> &operator[](int u) { return adj[u]; } }; vector<vector<int>> scc_gabow(graph &adj) { int n = adj.n;...
#include <bits/stdc++.h> using namespace std; vector<long long> primes; bool vis[20000000]; vector<long long> a, b; long long v[20000000]; void genp() { for (long long i = 2; i < 20000000; i++) { if (!vis[i]) { primes.push_back(i); for (long long j = 1; j * i < 20000000; j++) vis[j...
/* This file is part of JT51. JT51 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. JT51 is distributed in the hope tha...
// 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 : Wed Mar 01 09:54:10 2017 // Host : GILAMONSTER running 64-bit major release (...
//----------------------------------------------------------------------------- // // (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 ...
#include <bits/stdc++.h> using namespace std; struct pt { double x, y; }; pt a[1005]; long long n; double kv(double g) { return g * g; } double dist(pt a, pt b) { return sqrt(kv(a.x - b.x) + kv(a.y - b.y)); } double visina(pt a, pt b, pt c) { return abs((b.y - a.y) * c.x - (b.x - a.x) * c.y + b....
#include <bits/stdc++.h> using namespace std; void code() { int n; cin>>n; string s; cin>>s; set<char> used; char last= - ; bool possible=true; for(char& c:s) { if(c!=last) { if(used.find(c)!=used.end()) { possible=false; break; } } ...
#include <bits/stdc++.h> using namespace std; int main() { long n, m, i, j; char x[2], y[2], t; cin >> n >> m; cin >> x[0]; for (i = 2; i < n; i++) cin >> t; cin >> x[1] >> y[0]; y[0] = (y[0] == ^ ) ? > : < ; for (j = 2; j < m; j++) cin >> t; cin >> y[1]; y[1] = (y[1] == ...
#include <bits/stdc++.h> using std ::vector; template <typename Tp> Tp Max(const Tp &a, const Tp &b) { return a > b ? a : b; } template <typename Tp> Tp Min(const Tp &a, const Tp &b) { return a < b ? a : b; } template <typename Tp> Tp Abs(const Tp &a) { return a > 0 ? a : -a; } templat...
#include <bits/stdc++.h> using namespace std; int main() { long long int c, hr, hb, wr, wb; cin >> c >> hr >> hb >> wr >> wb; long long int ret = 0, ret1 = 0; int cnt = 0; for (long long int i = 0; i <= (c / wr); i++) { long long int r = i * wr; long long int l = c - r; long lo...
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000; int main() { ios_base::sync_with_stdio(0); int n; cin >> n; vector<string> a(n); map<string, int> M; for (int i = 0; i < n; ++i) { cin >> a[i]; M[a[i]] = i; } vector<vector<int> > Inv(1 << n, vect...
#include <bits/stdc++.h> using namespace std; template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } const int maxn = 1000100; char s[maxn]; vector<int> a[maxn]; void solve() { cin >> s; int n = strlen(s); int c = 0; for (int i = 0; i < n; i++) { c += s[i] == 0 ...
// This module performs a rounding of a floating-point number. This rounding is expected to happen after the barrel shifter // shifts the data to a position with leading 1 in the most significant bit of the input. module acl_fp_custom_round_post( clock, resetn, mantissa, exponent, sign, mantissa_out, exponent_out, ...
#include <bits/stdc++.h> using namespace std; int m, n, cnt = 0; vector<vector<int> > g; vector<int> outgroup; int main() { cin >> n >> m; vector<int> emptyg; g.push_back(emptyg); for (int i = 1; i <= n; i++) { vector<int> subg; g.push_back(subg); } for (int i = 0; i < m; i...
// https://coredocs.s3.amazonaws.com/Libero/12_0_0/Tool/sf2_mlg.pdf module ADD2 ( input A, B, output Y ); assign Y = A & B; endmodule module ADD3 ( input A, B, C, output Y ); assign Y = A & B & C; endmodule module ADD4 ( input A, B, C, D, output Y ); assign Y = A & B & C & D; endmodule module CFG1 ( outpu...
#include <bits/stdc++.h> using namespace std; int main() { long long n, l, x, y; set<long long> Set; while (cin >> n >> l >> x >> y) { for (int i = 1; i <= n; ++i) { long long t; scanf( %I64d , &t); Set.insert(t); } bool checkx = 0; bool checky = 0; ...
#include <bits/stdc++.h> using namespace std; char s[2000]; int n, len, ans; int dpmin[120][55][2], dpmax[120][55][2]; bool u[120][55][2]; int inf = 10005000; bool go(int i, int n, int d) { if (i == len) { if (n % 2 == 0) return 1; return 0; } if (u[i][n][d]) return 1; u[i][n][...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 21.02.2016 14:56:48 // Design Name: // Module Name: sandbox // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revis...
#include <bits/stdc++.h> using namespace std; char g[10][10]; int ax[10 * 10], n; bool use[10 * 10]; int q[2][100], ct[2], vst[8][8]; int dx[9] = {0, 0, 0, 1, -1, 1, 1, -1, -1}; int dy[9] = {0, 1, -1, 0, 0, -1, 1, -1, 1}; bool check(int x, int y) { if (x < 0 || y < 0 || x >= 8 || y >= 8) return 0; ...
#include <bits/stdc++.h> using namespace std; int main() { set<char> s; char a[100005]; s.insert( A ); s.insert( H ); s.insert( I ); s.insert( M ); s.insert( O ); s.insert( T ); s.insert( U ); s.insert( V ); s.insert( W ); s.insert( X ); s.insert( Y ); scanf( ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 5 * 105000; int n; int a[MAXN]; bool can(int x) { if (x == 0) return true; if (n - x < x) return false; int r = n; for (int i = x; i >= 1; i--) { if (r <= x) return false; while (a[r] < 2 * a[i]) { r--; ...
#include <bits/stdc++.h> using namespace std; int n, m, a[5001], i, j, b[5001], ans; int main() { scanf( %d%d , &n, &m); for (i = 1; i <= n; i++) { scanf( %d , &a[i]); b[i] = a[i]; } for (i = 1; i <= n; i++) if (a[i] == b[i]) for (j = 1; j <= n; j++) if (a[i] !=...
#include <bits/stdc++.h> using namespace std; const int maxn = (int)3e5 + 10; const int inf = (int)1e9 + 5; const long long llinf = (long long)1e18 + 5; long long a[maxn]; long long d, i, n, k, l, query, first, second, pruf, pruf2, j, m, p, last, sum, h, z, r; int main() { cin >> n; for (i =...
#include <bits/stdc++.h> using namespace std; long long mod = 1e9; void err(istream_iterator<string> it) {} template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << = << a << endl; err(++it, args...); } long long powm(long long a, long l...
// ------------------------------------------------------------- // // File Name: hdl_prj\hdlsrc\controllerPeripheralHdlAdi\controllerHdl\controllerHdl_Calculate_Rotor_Velocity.v // Created: 2014-09-08 14:12:04 // // Generated by MATLAB 8.2 and HDL Coder 3.3 // // ----------------------------------------------------...
#include <bits/stdc++.h> using namespace std; int main() { int t, n, k; scanf( %d , &t); while (t-- && scanf( %d %d , &n, &k)) { if ((k & 1) == (n & 1) && (long long)(k)*k <= n && n >= k) printf( YES n ); else printf( NO n ); } return 0; }
#include <bits/stdc++.h> using namespace std; int n, m, q; pair<int, int> a[400004]; long long ans[200004], d[400004], sum; int fa[400004], l[400004], r[400004], s[400004]; vector<pair<int, int> > v, ask; int F(int x) { return fa[x] == x ? x : fa[x] = F(fa[x]); } long long got(int v) { return d[r[v]] - ...
//====================================================================== // // sha256_w_mem_regs.v // ------------------- // The W memory. This version uses 16 32-bit registers as a sliding // window to generate the 64 words. // //====================================================================== module sha256_w_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...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 10:40:46 05/12/2015 // Design Name: // Module Name: ID_EX // Project Name: // Target Devices: // Tool versions: // Description: // // Dependenc...
/* * 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 t, x, y, z; cin >> t; while (t--) { cin >> x >> y >> z; if ((x != y && y != z && x != z) || ((x == y && x < z) || (y == z && y < x) || (z == x && z < y))) { cout << NO n ; continue; } else { ...
#include <bits/stdc++.h> using namespace std; const int N = 300010; const long long inf = 4e18; int n, k, x1[N], var[N], x2[N], y2[N], x[N], y[N]; pair<pair<int, int>, int> px[N], py[N], py1[N]; long long ans; long long solve(pair<pair<int, int>, int> *p, int n, int k, int w) { int j = n - k; long...
`include "top.vh" module top( input ice_clk_i, output [7:0] led_o, output vs_o, output hs_o, output [3 : 0] red_o, output [3 : 0] blue_o, output [3 : 0] green_o ); reg [31:0] ctr; reg vs = 0, hs = 0; reg [9 : 0] ctr_x = 0; reg [8 : 0] ctr_y = 0; ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, m, k; cin >> n >> m >> k; vector<int> lx(n), ly(m); vector<int> x(k), y(k); for (int& i : lx) cin >> i; for (int& i : ly) cin >> i; for (int i = 0; i < k; i++) { ...
/////////////////////////////////////////////////////////////////////////////// // // Module: dma_engine_rr_arb.v // Project: CPCI (PCI Control FPGA) // Description: Arbiter for choosing from input queues // // Note: read and write are from the perspective of the driver. // Read means retrieve a packet fro...
/** * 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 long long read() { long long x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(...
// file: out_skew_dcm.v // // (c) Copyright 2008 - 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 disclai...
#include <bits/stdc++.h> using namespace std; const int MX = 1e5 + 10; int n, a[MX], out[MX], mn[MX]; int bs(int L, int R, int val) { if (R - L == 1) return L; int mid = (R + L) / 2; if (val <= mn[mid]) return bs(L, mid, val); else return bs(mid, R, val); } int main() { cin >...
#include <bits/stdc++.h> using namespace std; int main() { int t; double a, b, Zero = 0.5, One = 1.0; scanf( %d , &t); while (t--) { scanf( %lf%lf , &a, &b); if (a == 0 && b == 0) printf( %.10lf n , One); else if (a == 0) printf( %.10lf n , Zero); else if (b =...