text
stringlengths
59
71.4k
module test_1; // Very simple testbench to check A = 1234 B = 1234, Winning in the first step. reg I1,I2,I3,I4,enter,reset; wire win,lose; wire equal,bigger,smaller; wire [0:3]nums; test test_v1(I1,I2,I3,I4,enter,win,lose,reset,equal,bigger,smaller,nums); initial begin I1 = 0; I2 = 0; I3 = 0; ...
#include <bits/stdc++.h> using namespace std; const int M = 1e5 + 10; int n, S; long long tot; struct Node { long long val; long long num; long long sum; bool operator<(const Node &rhs) const { return num < rhs.num; } }; vector<Node> a, b; long long work(long long ls, vector<Node> &a) { ...
#include <bits/stdc++.h> using namespace std; long long c[100001]; void init() { long long n, x; long long ans = 0; cin >> n >> x; for (int i = 0; i < n; i++) cin >> c[i]; sort(c, c + n); for (int i = 0; i < n; i++) { ans += c[i] * x; if (x > 1) x--; } cout << ans << en...
/** * 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 comment(linker, /STACK:36777216 ) using namespace std; const double pi = acos(-1.0); const double eps = 1e-11; const int oo = 0x3f3f3f3f; template <class T> inline void checkmin(T &a, T b) { if (b < a) a = b; } template <class T> inline void checkmax(T &a, T b) ...
/* * HIFIFO: Harmon Instruments PCI Express to FIFO * Copyright (C) 2014 Harmon Instruments, LLC * Author: Darrell Harmon * * 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 ...
#include <bits/stdc++.h> using namespace std; const int Maxn = 55, p = 1e9 + 7; int n, m; long long inv[Maxn], f[Maxn][Maxn], g[Maxn][Maxn], sum[Maxn][Maxn]; long long get_inv(int x) { return x <= 1 ? 1 : (p - p / x) * get_inv(p % x) % p; } int main() { scanf( %d%d , &n, &m); for (int i = 1; i...
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-8; const long long SZ = 1010, SSZ = 100010, APB = 26, one = 93, INF = 0x3f3f3f3f3f3f3f3f, mod = 1000000007; long long n, m, bg, fn, cnt; long long to[SSZ], wt[SSZ], head[SZ]; long long nex[SSZ], mk[SSZ]; long long dfn[SZ...
// file: clk_wiz_v3_6_exdes.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 disclaimer ...
#include <bits/stdc++.h> using namespace std; bool solve(string temp, string p) { int i = 0, j = 0; while (i != temp.size()) { if (temp[i] == p[j]) { i++; j++; } else i++; if (j == p.size()) break; } if (i <= temp.size() && j >= p.size()) return true; ...
/*===========================================================================*/ /* Copyright (C) 2001 Authors */ /* */ /* This source file may be used and distributed without restriction provided */ ...
#include <bits/stdc++.h> int main() { long long int a, b = 1, i; scanf( %I64d , &a); for (i = 1; i <= a; i++) { b += 12 * (1 + i - 2); } if (a == 1) printf( 1 ); else printf( %I64d , b); return 0; }
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 08:30:15 03/30/2016 // Design Name: MAIN // Module Name: Y:/TEOCOA/EXP3/TEST.v // Project Name: EXP3 // Target Device: // Tool versions: // Descripti...
#include <bits/stdc++.h> using namespace std; void test_case(); long long power(int n, int p); int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { test_case(); } return 0; } void test_case() { int n, x; cin >> n >> ...
#include <bits/stdc++.h> using namespace std; void openfile() { freopen( input.txt , r , stdin); freopen( output.txt , w , stdout); } const int nmax = 1 << 16; int n, k; int a[nmax]; vector<string> name; map<string, int> num; vector<vector<int> > g; int main() { cin >> n >> k; g.re...
#include <bits/stdc++.h> using namespace std; const int inf = 1000 * 1000 * 1000 + 7; const int N = 1000 * 1000 + 7; long long a[N]; multiset<long long> st; int main() { int n; cin >> n; for (int i = 0; i < n; ++i) scanf( %I64d , a + i); long long ans = 0; for (int i = 0; i < n; ++i) { ...
#include <bits/stdc++.h> using namespace std; template <typename type> type input() { type var; cin >> var; return var; } template <typename type> void input(type &var) { cin >> var; return; } template <typename type> void output(type &var, const char *ch) { cout << var << ch; ...
#include <bits/stdc++.h> using namespace std; int n, x, zhan[100500], tree[100500], o, ans[100500], now = 1; struct edge { int x, t, id, r; bool operator<(const edge &xx) const { if (x != xx.x) return x < xx.x; return id < xx.id; } } aa[100500]; void add(int x, int y) { for (int i ...
module test(); typedef bit [63:0] bit64; typedef logic [63:0] vec64; byte byte_array []; bit [15:0] bit_array []; logic [31:0] vec_array []; real real_array []; bit64 bit_result; vec64 vec_result; reg failed = 0; initial begin byte_array = new [8]; fore...
// delay_in.v `timescale 1 ns / 1 ps /* parameter delay [ns] sampling point position 0_0000_0 0.00 19 0_0000_1 1.25 18 0_0001_0 2.50 17 0_0001_1 3.75 16 0_0011_0 5.00 15 0_0011_1 6.25 14 0_0111_0 7.50 13 0_0111_1 8.75 ...
/* * 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; struct box { long long int x1, x2, y1, y2; box() : x1(0), x2(0), y1(0), y2(0) {} box(int x1, int x2, int y1, int y2) : x1(x1), x2(x2), y1(y1), y2(y2) {} }; struct edge { long long int to, c, f; edge() : to(0), c(0), f(0) {} edge(int to, long ...
#include <bits/stdc++.h> using namespace std; char getDiffColor(char a, char b) { map<char, bool> mp; mp[a] = true, mp[b] = true; if (mp.find( R ) == mp.end()) return R ; else if (mp.find( G ) == mp.end()) return G ; else return B ; } int main() { int cnt = 0; st...
#include <bits/stdc++.h> using namespace std; int main() { long long t; t = 1; while (t--) { long long n, m; cin >> n; cin >> m; string s[n]; for (long long i = 0; i < n; i++) { string cur = ; for (long long i = 0; i < m; i++) { long long k; ...
/** * ------------------------------------------------------------ * Copyright (c) All rights reserved * SiLab, Institute of Physics, University of Bonn * ------------------------------------------------------------ */ `timescale 1ps/1ps `default_nettype none module sram_fifo #( parameter BASEADDR = 16'h000...
module grid_PWM( input rsi_MRST_reset, input csi_MCLK_clk, input [31:0] avs_pwm_writedata, output [31:0] avs_pwm_readdata, input [2:0] avs_pwm_address, input [3:0] avs_pwm_byteenable, input avs_pwm_write, input avs_pwm_read, output avs_pwm_waitrequest, input rsi_PWMRST_reset, input csi...
#include <bits/stdc++.h> using namespace std; int a[3010], id[3010], num[3010]; vector<int> ans; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); } int m; scanf( %d , &m); int need = n - m; while (true) { int tot = 0; memse...
/** * 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 maxn = 300100, maxv = 100, mod = 1e9 + 7, maxa = 1005, maxs = 820, maxb = 20, base = 737, base2 = 3079, mod3 = 998244353, delt = 10513; const long long inf = 2e16; const long long infint = 1e9 + 11; long long max...
/* * Copyright (c) 2015 Steven Stallion * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of cond...
/* * Programing Notes: 1, there are four SPRs in uartlite, access using mtspr/mfspr instructions 2, the four register are: control register ctrl[0]: tx_start ctrl[1]: rx_disenable ctrl[2]: tx_interrupt_ebable - currently not in use ctrl[3]: rx_interrupt_ena...
// Copyright 1986-2018 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2018.2 (win64) Build Thu Jun 14 20:03:12 MDT 2018 // Date : Sun Sep 22 03:32:42 2019 // Host : varun-laptop running 64-bit Service Pac...
/* * data_ram.v * Synchronous RAM module used for data storage * * Copyright (C) 2013 James Cowgill * * 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 ...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, max1 = 0; cin >> n; long long int a[n]; long long int b[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } b[n - 1] = 0; max1 = a[n - 1]; for (int i = n - 2; i >= 0; i--) { if (a[i] > max1) { ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2020 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 typedef enum {TEN=10, ELEVEN=11, SIXTEEN=16} enum_t; module t (/*AUTOARG*/ ...
// 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; parameter [31:0] TWENTY4 = 24; parameter [31:0] PA = TWENTY4/8; parameter [1:0] VALUE = ...
// // 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) // ...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 15:06:24 05/25/2014 // Design Name: qdiv // Module Name: D:/temp/TestDiv1/TestDiv.v // Project Name: TestDiv1 // Target Device: // Tool versions: // ...
#include <bits/stdc++.h> using namespace std; long long fact[3000002], n, inv[3000002]; long long pw(long long b, long long e) { long long ans = 1; while (e) { if (e & 1) ans = (ans * b) % 1000000007; b = (b * b) % 1000000007; e >>= 1; } return ans; } int main() { ios_bas...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2017.1 // Copyright (C) 1986-2017 Xilinx, Inc. All Rights Reserved. // // ============================================================== `timescale 1 ns / 1 ...
////////////////////////////////////////////////////////////////////// //// //// //// OR1200's IC RAMs //// //// //// //// This file is part of the OpenR...
// file: Clock70MHz_tb.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 disclaimer is no...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 2e5 + 10; struct node { int l, r, id; friend bool operator<(node A, node B) { return A.r == B.r ? A.l < B.l : A.r < B.r; } }; node a[N]; bool add[N]; int main() { ios::sync_with_stdio(0); cin.tie(...
#include <bits/stdc++.h> using namespace std; const long long int mod = 1000000007ll; const long long int MOD = 1000000009ll; int local_debug = 0; long long int bit_count(long long int _x) { long long int _ret = 0; while (_x) { if (_x % 2 == 1) _ret++; _x /= 2; } return _ret; } ...
#include <bits/stdc++.h> #pragma warning(disable : 4996) #pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) #pragma GCC optimize( -ffloat-store ) using namespace std; clock_t time_p = clock(); void aryan...
/** * 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 = 105; long long l, r, dp[N]; long long gao(long long n) { long long m = n, ans = 0; int bit[N], len = 0; while (n) { bit[++len] = n % 2; n /= 2; } for (int i = 2; i < len; i++) { memset(dp, 0, sizeof(dp)); dp[...
/* * 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 a[n], b[n]; for (int i = 0; i < n; ++i) cin >> a[i]; for (int i = 0; i < n; ++i) cin >> b[i]; int ans = 0; for (int i = 0; i < n; ++i) { int x = a[i], y = b[i]; ans = max(ans, x + y); for (i...
#include <bits/stdc++.h> using namespace std; const int maxn = 100000 + 10; struct Edge { int from, to, w; } edges[maxn]; int val[maxn]; long long ans; int size[maxn], fa[maxn]; bool cmp(Edge a, Edge b) { return a.w > b.w; } int Getfa(int x) { if (fa[x] == x) return x; else ret...
/** * 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 i, j; char map[9][9]; bool ok = false, ok1 = false; for (i = 0; i < 8; ++i) { scanf( %s , map[i]); for (j = 1; j < 8; ++j) { if (i == 0 && map[i][j] == W ) ok1 = true; if (map[i][j] == map[i][j - 1]) ok = tru...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2020 by engr248. // SPDX-License-Identifier: CC0-1.0 module t(/*AUTOARG*/ // Inputs clk ); input clk; wire [31:0] in = 0; wire [31:0] out; Tes...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; long long c[N], d[N]; int main() { long long sum = 0, ans = 0; int n, k; scanf( %d %d , &n, &k); for (int i = 1; i <= n; i++) { scanf( %lld , &c[i]); sum += c[i]; } for (int i = 1; i <= k; i++) { scan...
#include <bits/stdc++.h> using namespace std; int t, x, y, a, b; int main(void) { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> t; while (t--) { cin >> x >> y >> a >> b; int tmp = (y - x) / (a + b); if (x + tmp * a == y - tmp * b) cout << tmp << n ; else...
module counter_n (clk,sig,n_clk_out); /*This module takes an input signal and implements a period counter, taking the reciprocal to deliver the frequency in kHz. USAGE: counter c(clk,sig,f); clk and sig are 1-bit inputs representing the clock and RF signal whose frequency is to be measured. f is a 4-bit output corre...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 17:05:44 03/13/2014 // Design Name: // Module Name: Longest_Run_of_Ones // Project Name: // Target Devices: // Tool versions: // Description: // // Dependen...
#include <bits/stdc++.h> template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } constexpr long long MAX = 5100000; constexp...
/* * 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; void solve(void) { string a, b, c; cin >> a >> b >> c; int n = a.length(); for (int i = 0; i < n; i++) { if (c[i] != a[i] && c[i] != b[i]) { cout << NO n ; return; } } cout << YES n ; } int main(void) { ios_b...
#include <bits/stdc++.h> using namespace std; int t, n, i, k, j, lg, el, maxi, ok2; int ok[5010][5010]; char v[5010], sol[5010]; int main() { cin >> t; for (; t--;) { cin >> v + 1; n = strlen(v + 1); int st = 1, dr = n; while (st <= dr && v[st] == v[dr]) st++, dr--; if (s...
/* Copyright (c) 2015-2016 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; using ll = long long; using db = double; using pii = pair<int, int>; using pll = pair<ll, ll>; const int N = 2e5 + 10; const ll inf = 1e15 + 42; vector<vector<int> > g(100007); int flg, root, cnt; vector<int> ans; void dfs(int u, int par) { if (flg...
#include <bits/stdc++.h> using namespace std; int main() { int tc; cin >> tc; while (tc--) { int test = 0; int t[1005]; int n, x, nb1 = 0, nb2 = 0, i; cin >> n >> x; for (i = 0; i < n; i++) { cin >> t[i]; if (t[i] % 2 == 0) nb1++; else ...
#include <bits/stdc++.h> using namespace std; const int base = 998244353; int sum(int a, int b) { int c = a + b; if (c >= base) return c - base; return c; } int diff(int a, int b) { int c = a - b; if (c < 0) return c + base; return c; } int mul(int a, int b) { return (int)(a * (lon...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int t[n]; for (int i = 0; i < n; i++) cin >> t[i]; int left_cnt, left_time, right_cnt, right_time; int left_idx = 0, right_idx = n - 1; left_time = left_cnt = right_time = right_cnt = 0; while (left_idx <= ri...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; long long a, b, c[101], d[101], mx = -1e9, cnt; int main() { cin >> a >> b; for (int i = 1; i <= a; ++i) { cin >> c[i]; } for (int i = 1; i < a; ++i) { d[i] = c[i] - c[i + 1] - b; } for (int i = 1; i <= a; ++i) { mx = max(d[i]...
module VGA1Interface(clock,reset,framebuffer,vga_hsync,vga_vsync,vga_r,vga_g,vga_b); input wire clock; input wire reset; input wire [63:0] framebuffer; output wire vga_hsync; output wire vga_vsync; output wire vga_r; output wire vga_g; output wire ...
#include <bits/stdc++.h> using namespace std; int n, pos, l, r, ind, ans = 0, ans1 = 0, ans2 = 0; int main(void) { ios ::sync_with_stdio(0); cin.tie(0); cin >> n >> pos >> l >> r; if (pos < l) { ans += l - pos + 1; if (n - r > 0) { ans += r - l + 1; } } else if (pos >...
#include <bits/stdc++.h> using namespace std; int a[26][26]; int main() { int n; cin >> n; memset(a, 0, sizeof(a)); char ch[20]; int len; for (int i = 1; i <= n; i++) { scanf( %s , ch); for (len = 0; ch[len]; len++) ; for (int j = 0; j < 26; j++) if (a[j]...
/************************************************************************** UART Receiver Module -Sampling speed x4 -parameter BAUDRATE_COUNTER Uart Baudrate Parameter (Clock / Baudrate)/4-1 BAUDRATE_COUNTER is must be greater than 4. (BAUDRATE_COUNTER >= 20'h4) Example : Clock : 50MHz 9600bps : 13'd1301 1...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); map<pair<int, int>, int> f; int t, it, n, res, tmp, x, y, resr, resl, i; string s; cin >> t; for (it = 1; it <= t; it++) { cin >> n; cin >> s; s = ...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: pcx_buf_p0_odd.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 an...
// 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:55:26 2017 // Host : GILAMONSTER running 64-bit major release (...
#include <bits/stdc++.h> using namespace std; long long n, h[100005], num = 0, lt = 0, rt, dp[100005], dp1[100005], cur; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> h[i]; for (long long i = 1; i <= n; i++) { long long temp = dp[lt] + (i - lt); if (h[i] - cur <= 0 || temp <= ...
#include <bits/stdc++.h> char s[100][100]; int main() { int n, m, ans = 0; scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) scanf( %s , s[i] + 1); for (int i = 1; i < n; i++) { for (int j = i + 1; j <= n; j++) { int f = 0, g = 0; for (int k = 1; k <= m; k++) if (s[...
#include <bits/stdc++.h> using namespace std; int n, m, k; int n1, n2, n3; int c[510]; int sc[510]; int pai[100010]; int type[100010]; int peso[100010]; int dp[510][510]; vector<pair<pair<int, int>, int> > edges; int find(int i) { return pai[i] = (pai[i] == i) ? i : find(pai[i]); } void join(int...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; long long a[maxn], x[maxn], y[maxn], c[7], d[7], ans; int n, m; bool cmp(long long x, long long y) { return x > y; } void sol(int pos, int num, int flag) { memset(d, 0, sizeof(d)); if (flag) { for (int i = 1; i <= pos; i++...
#include <bits/stdc++.h> using namespace std; int main() { long long sumfirst = 0, sumsecond = 0; long long n; vector<long long> first, second; long long arr[200000]; cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; if (arr[i] > 0) sumfirst += arr[i]; else if ...
module QcmMasterControllerMain(clk, sig, codeSer, codePar, enableSer, enablePar, ioPowerEnable, clkEnable, serCodeOutput, parCodeOutput, nclkOutput); /* This is the master controller module which instantiates the sub-modules responsible for master controller operation: counter=frequency counter (really, a period counte...
#include <bits/stdc++.h> using namespace std; FILE *in; FILE *out; const int MAX = 1048576; const int TREE = 2097152; const int MOD = 1000000007; int n; int a[MAX]; int tree[TREE]; bool seen[MAX]; int query(int idx1, int idx2) { idx1 += (TREE >> 1); idx2 += (TREE >> 1); if (idx1 == idx...
#include <bits/stdc++.h> template <typename T> class IntegerIterator : public std::iterator<std::input_iterator_tag, T, std::ptrdiff_t, T*, T> { public: explicit IntegerIterator(T value) : value(value) {} IntegerIterator& operator++() { ++value; return *this; } IntegerIterator o...
#include <bits/stdc++.h> using namespace std; template <class TH> void _dbg(const char *sdbg, TH h) { cerr << sdbg << = << h << endl; } template <class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) { while (*sdbg != , ) cerr << *sdbg++; cerr << = << h << , ; _dbg(sdbg + 1...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int MX = 2e2 + 5; const long long INF = 1e18; const long double PI = 4 * atan((long double)1); const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; namespace io { void setIn(string second) { freopen(second.c_str(), r , stdi...
`timescale 1ns/1ns module Timer_tb(); reg clk, rstn; reg[1:0] set; wire ready; Timer DUT ( .clk(clk), .rstn(rstn), .set(set), .ready(ready) ); always #20 clk = ~clk; always@(ready or rstn or set) begin $display("\tTEMPO: %0t // reset: %b // ready: %b // set: %b\n", $time, rstn, rea...
// megafunction wizard: %ROM: 2-PORT%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: cm_rom_final.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // ===========...
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 7; const long long int N = 1e5 + 5; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int i, j, tc; cin >> tc; while (tc--) { long long int n, w; cin >> n >> w; ...
#include <bits/stdc++.h> using namespace std; int n, m, ans = 0; string s; void go(vector<char> k, pair<int, int> start, vector<string> a) { for (int i = 0; i < s.size(); i++) { if (s[i] == k[0]) { start.first--; } if (s[i] == k[1]) { start.first++; } if (s[i] =...
/* RC4 PRGA module implementation Copyright 2012 - Alfredo Ortega This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later vers...
// (C) 2001-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 simulation // files), and any associated doc...
/* * 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...
module uart ( input[15:0] din, output[15:0] dout, input a0, input rnw, input clk, input reset_b, input cs_b, input rxd, output txd); // CLKSPEED is the main clock speed parameter CLKSPEED = 32000000; // BAUD is the desired serial baud rate parameter BAUD = 115200; // DIVISOR is the number of clk cycle...
/******************************************************************************* * This file is owned and controlled by Xilinx and must be used * * solely for design, simulation, implementation and creation of * * design files limited to Xilinx devices or technologies. Use ...
/** * 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); cin.tie(NULL); ; long long t, i, j, r, k, x, y, n, m, l, a, b, c, d = 0; cin >> t; string s, cm = abacaba ; while (t--) { cin >> l >> r; if (2 * l <= r) { cout << l << << 2 * ...
#include <bits/stdc++.h> using namespace std; int n, arr[100], res, maxi, mini, g; int gcd(int a, int b) { for (; b != 0; b = b % a) swap(a, b); return a; } int main() { scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , &arr[i]); maxi = g = arr[0]; for (int i = 0; i < n; i++) { ...
#include <bits/stdc++.h> using namespace std; int n, b, g, ans; int main() { scanf( %d%d%d , &b, &g, &n); for (register int i = 0; i <= n; ++i) { register int a = i, f = n - i; if (a <= b && f <= g) ++ans; } printf( %d n , ans); return 0; }
/*! btcminer -- BTCMiner for ZTEX USB-FPGA Modules: HDL code: hash pipelines Copyright (C) 2011 ZTEX GmbH http://www.ztex.de This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation...
/******************************************************************************* * This file is owned and controlled by Xilinx and must be used solely * * for design, simulation, implementation and creation of design files * * limited to Xilinx devices or technologies. Use with non-Xilinx ...