text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; long long n, a[100069], dv; int main() { long long i, j, z = 1; scanf( %lld%lld , &n, &dv); if (n > dv) { printf( 0 n ); return 0; } for (i = 1; i <= n; i++) { scanf( %lld , a + i); for (j = 1; j < i; j++) { z = z * ...
#include <bits/stdc++.h> using namespace std; int main() { unsigned long long n; cin >> n; if (n % 2 == 0) { cout << n - (n / 2) << endl; } else { cout << - << (n + 1) / 2 << endl; } return 0; }
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; const int N = 1e4 + 100; int n, k; char str[N]; bool f[N]; int main() { scanf( %s , str + 1), n = strlen(str + 1); while (1 << k < n) ++k; if (1 << k > n) --k; memset(f, 1, sizeof(f)); for (int i = 1; i <= n - (1 << k) + 1; ++i) { char ...
#include <bits/stdc++.h> int main() { int a, b, c, d, e, f, L; scanf( %d%d%d%d%d%d , &a, &b, &c, &d, &e, &f); L = a + b + c; printf( %d n , L * L - a * a - c * c - e * e); }
#include <bits/stdc++.h> using namespace std; vector<int> scs(const string& s) { int n = s.size(); vector<int> p(n), c(s.begin(), s.end()); vector<vector<int>> g(max(n, 256)); for (int i = 0; i < n; i++) g[c[i]].push_back(i); int b = 0; for (auto& gr : g) { for (int x : gr) p[b++] = x;...
#include <bits/stdc++.h> using namespace std; struct block { string str; int pos; }; static bool compare(block b1, block b2) { int n = b1.str.length(); for (int i = 0; i < n; i++) { if (b1.str[i] != b2.str[i]) { if ((i + 1) % 2) { return (b1.str[i] < b2.str[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 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; using ll = long long; using ld = long double; const int maxn = 1e6 + 2; const int base = 31; const int mod = 1e9 + 7; ll t; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin >> t; while (t--) { ...
// -- (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...
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); string s; cin >> s; string v = aeiou ; string c = bcdfghjklmnpqrstvwxyz ; map<char, int> cnt; map<char, int> mp; for (auto i : v) mp[i] = 1; for (auto i : c...
#include <bits/stdc++.h> using namespace std; long long blk = 300; struct data { long long l, r, i; data() { l = r = i = 0; } data(long long v1, long long v2, long long v3) { l = v1; r = v2; i = v3; } bool operator<(const data &x) const { if (l / blk != x.l / blk) ...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (lin64) Build Wed Dec 14 22:35:42 MST 2016 // Date : Sat Jan 21 16:36:06 2017 // Host : natu-OMEN-by-HP-Laptop running 64-bit Ubunt...
`timescale 1ns/1ps module dv_elink_tb(); parameter AW=32; parameter DW=32; parameter PW=104; parameter CW=2; //number of clocks to send int parameter MW=104; parameter MAW=10; parameter MD=1<<MAW;//limit test to 1K transactions //TODO:generealize /* verilator lint_off STM...
#include <bits/stdc++.h> using namespace std; const int mod = 1000 * 1000 * 1000 + 7; const int INF = 1e9 + 100; const long long LINF = 1e18 + 100; long long x, k; const int n = 1e5; vector<long long> divs; vector<long long> ddv[7010]; vector<long long> fk[7010]; void getnxt(const vector<long long> ...
module transmit_test_entity_tb ; //input reg clk_in ; reg reset_n ; //output wire Sample_Gate ; wire [15:0] P ; wire [15:0] N ; wire HV_SW_CLR ; wire HV_SW_LE ...
#include <bits/stdc++.h> using namespace std; const long long inf = 1e18; long long fn(string a, string b) { long long n = a.size(), m = b.size(), j = 0; for (long long i = 0; i < m; i++) { if (b[i] == a[j]) { j++; if (j >= n) { return m - n; } } } if ...
#include <bits/stdc++.h> using namespace std; double n, m, k; int main() { while (scanf( %lf %lf %lf , &n, &m, &k) != EOF) { if (m > n + k) { printf( %.6lf n , 0.0); continue; } double resp = 1.0; for (int i = 0; i <= k; i++) { resp *= ((m - i) / (n + k + 1 - 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> long long T, n, k; long long a, sum, num; int main() { scanf( %I64d%I64d , &n, &k); for (long long i = 1; i <= n; i++) { scanf( %I64d , &a); if (sum - (i - 1 - num) * (n - i) * a >= k) sum += a * (i - 1 - num); else { printf( %I64d n , i); ...
#include <bits/stdc++.h> using namespace std; bool options(long a, long b) { return a > b; } int main() { long n, i, *arr, *arrSort, *index; map<long, long> res; cin >> n; arr = new long[n]; arrSort = new long[n]; index = new long[n]; for (i = 0; i < n; i++) { cin >> arr[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...
/* Servo motor control demo module Causes connected servos to swing back and forth with different periods, individually adjustable. */ module mojo_top( // 50MHz clock input input clk, // Input from reset button (active low) input rst_n, // cclk input from AVR, high when AVR is ready input ...
#include <bits/stdc++.h> using namespace std; int mat[6][7] = { {0, 0, 0, 1, 1, 1, 1}, {0, 1, 1, 0, 0, 1, 1}, {1, 0, 1, 0, 1, 0, 1}, {0, 1, 1, 1, 1, 0, 0}, {1, 0, 1, 1, 0, 1, 0}, {1, 1, 0, 0, 1, 1, 0}, }; int aux[6][7]; int res[7]; bool solve() { int p, div; for (int i = 0; i < 6; ++i) {...
// ================================================================== // >>>>>>>>>>>>>>>>>>>>>>> COPYRIGHT NOTICE <<<<<<<<<<<<<<<<<<<<<<<<< // ------------------------------------------------------------------ // Copyright (c) 2006-2011 by Lattice Semiconductor Corporation // ALL RIGHTS RESERVED // -------...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; std::cin >> n >> m; getchar(); int a[n][m], nums[m]; for (int i = 0; i < m; i++) { nums[i] = 0; } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { a[i][j] = getchar() - 0 ; nums[j...
// // Copyright 2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is dis...
// DESCRIPTION: Verilator: Dedupe optimization test. // // This file ONLY is placed into the Public Domain, for any use, // without warranty. // Contributed 2012 by Varun Koyyalagunta, Centaur Technology. // // Test consists of the follow logic tree, which has many obvious // places for dedupe: /* ...
`ifndef DIVIDER_V `define DIVIDER_V `ifndef WIDTH `define WIDTH 32 `endif module divider( input start, input clk, input [`WIDTH-1:0] dividend, input [`WIDTH-1:0] divisor, output reg [`WIDTH-1:0] quotient, output [`WIDTH-1:0] remainder, output ready); reg [`WIDTH+`WIDTH-1:0] dividend_c...
#include <bits/stdc++.h> using namespace std; const int N = 100010; int ans, tot, head[N], ver[N], Next[N], val[N], n, m, deg[N]; queue<int> q[2]; bool vis[N]; inline void add(int x, int y) { ver[++tot] = y; Next[tot] = head[x]; head[x] = tot; deg[y]++; } int main() { cin >> n >> m; ...
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y, count = 0; cin >> n; pair<int, int> a[3005]; set<pair<int, int>> s; for (int i = 0; i < n; i++) { cin >> x >> y; a[i] = pair<int, int>(x, y); s.insert(a[i]); } for (int i = 0; i < n; i++) { fo...
#include bits/stdc++.h using namespace std; #define ffor(n) for(int i = 0; i < n; i++) #define fffor(n) for(int j = 0; j < n; j++) #define uwu ios_base::sync_with_stdio(false);cin.tie(NULL); #pragma GCC optimize( Ofast ) const int INF = 1e9 + 7; const long long INF2 = 1e15; void solve(void) {...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: bw_io_jp_sstl_dq_bscan.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 redistribu...
#include <bits/stdc++.h> using namespace std; const int N = 1000008; int n, m, k, d, i, j, e; int tmp[N], pos[N], p[N], c[N]; char s[N]; int main() { scanf( %s %d , s, &m); n = strlen(s); while (m--) { scanf( %d%d , &k, &d); for (i = 0; i < n; i++) { c[i] = (i + 1) % n; ...
#include <bits/stdc++.h> using namespace std; int main() { int n, x[100002] = {0}, j, t; cin >> n; t = n; for (int i = 0; i < n; i++) { cin >> j; x[j] = 1; while (t >= 1 && x[t] == 1) { cout << t << ; t--; } cout << endl; } return 0; }
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.3 (win64) Build Mon Oct 10 19:07:27 MDT 2016 // Date : Wed Oct 25 12:44:01 2017 // Host : vldmr-PC running 64-bit Service Pack 1 ...
/* * This demonstrates a basic dynamic array */ module main; real foo[]; int idx; initial begin if (foo.size() != 0) begin $display("FAILED -- foo.size()=%0d, s.b. 0", foo.size()); $finish; end foo = new[10]; if (foo.size() != 10) begin $display("FAILED -- foo.size()=%0d, s....
#include <bits/stdc++.h> using namespace std; int main(void) { int n, S; scanf( %d , &n); scanf( %d , &S); string st; map<int, int> b, s; for (int i = 0; i < n; i++) { cin >> st; int p, q; scanf( %d , &p); scanf( %d , &q); if (st[0] == B ) { b[p] += q; ...
//Legal Notice: (C)2014 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...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, ans; while (cin >> a >> b) { if (a == 0 && b == 0) cout << NO << endl; else { ans = abs(a - b); if (ans <= 1) cout << YES << endl; else cout << NO << endl; } }...
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; long long ii = 1; vector<long long> prime; bitset<1000000> bs; void sieve() { bs.set(); bs[0] = bs[1] = 0; prime.push_back(2); for (long long i = 3; i <= 1000000; i += 2) { if (bs[i]) { for (long long j = i ...
#include <bits/stdc++.h> using namespace std; int main() { int ent; long long int a, b; cin >> ent; while (ent--) { int div = 0, pls = 0; cin >> a >> b; if (a % b == 0) { cout << 0 << endl; continue; } div = a / b; pls = (div + 1) * b; cout <...
#include <bits/stdc++.h> using namespace std; int main() { int n, l = 0; char a; cin >> n; for (int i = 0; i < n; i++) { cin >> a; if (a - 0 == 1) l++; else l--; } cout << abs(l); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[1000000]; for (int i = 0; i < n; i++) { cin >> a[i]; } int cur = a[n - 1]; long long total = a[n - 1]; for (int i = n - 2; i >= 0; i--) { cur = min(cur - 1, a[i]); cur = max(0, cur); ...
#include <bits/stdc++.h> using namespace std; const int Mx = 1e5 + 5; const long long inf = 1e9 + 1; struct Point { long long x, y; } point[Mx]; int n; long long ans, hmax[Mx], emax[Mx], hmin[Mx], emin[Mx]; template <class T> bool cmp(T a, T b) { return a.x < b.x; } bool judge(long long mi...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define rep(a, b) for(ll a = 0; a < (b); ++a) #define pb push_back #define st first #define nd second #define all(a) a.begin(), a.end() #define lg(a) (31-__builtin_clz(a)) void solve() { int n; ...
#include <bits/stdc++.h> using namespace std; bool comp(pair<unsigned long long, unsigned long long> a, pair<unsigned long long, unsigned long long> b) { unsigned long long s1, s2, h1, h2; tie(s1, h1) = a; tie(s2, h2) = b; if (s1 * h2 > s2 * h1) return true; return false; } int m...
/* Author: EndlessK * Time: 2021-05-06 20:40:25 **/ #include<bits/stdc++.h> #define maxn 100010 #define pb push_back #define ll long long #define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0) using namespace std; int main() { fast; int t; cin>>t; map<int,int> mp; ...
/** * 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) 2016 Andrew Zonenberg and contributors * * ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 200010; const int MODD = 1000000007; struct Stop { int s, t; bool operator<(const Stop &ss) const { return t < ss.t; } } bus[MAXN]; int n, m, nn, dp[MAXN], sum[MAXN]; int main() { while (scanf( %d%d , &n, &m) != EOF) { map<in...
#include <bits/stdc++.h> using namespace std; vector<long long> adj[200001]; long long a[200001]; vector<long long> start; stack<long long> last; long long ans; bool f; void dfs(long long); signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n; ...
#include <bits/stdc++.h> const int maxn = 200000; using namespace std; int a[maxn], b[maxn]; int l[maxn], r[maxn]; int main() { int n, q; scanf( %d%d , &n, &q); a[0] = 0; for (int i = 1; i <= n; i++) scanf( %d , &a[i]), b[i - 1] = abs(a[i] - a[i - 1]); for (int i = 1; i <= q; 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...
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> inline ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << ( << p.first << , << p.second << ) ; } template <typename T, size_t N> inline ostream &operator<<(ostream &os, const array<T, N> &a) { ...
#include <bits/stdc++.h> using namespace std; const long long maxn = 6e6; const long long inf = 1e18; const long long maxv = 2e8 + 100; const int miniinf = 1e9; const long double eps = 1e-6; const long long flowconst = 1e9; void init() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ...
// usb_avalon.v `timescale 1 ns / 1 ps module usb_avalon_16bit ( input clk, input reset, // avs_ctrl input avs_ctrl_address, input avs_ctrl_write, input [7:0]avs_ctrl_writedata, input avs_ctrl_read, output [7:0]avs_ctrl_readdata, // asi_uplink output ready, input valid, input [15:0]data, input startof...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; int n, k, h; struct Node { int m, v; int id; bool operator<(const Node &x) const { if (m != x.m) return m < x.m; return v < x.v; } } q[100005]; bool ok(double times) { int i, j; for (j = 1, i = 0; i < n; i++) { if (q[i].v ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 07:04:40 06/02/2013 // Design Name: // Module Name: alu // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // Rev...
#include <bits/stdc++.h> using namespace std; template <typename T> void dbg(T t) { cerr << t << endl; } template <typename T, typename... Args> void dbg(T t, Args... args) { cerr << t << ; dbg(args...); } int main() { ios::sync_with_stdio(0); cin.tie(0); int n, a, spec = 3; ...
#include <bits/stdc++.h> using namespace std; const long long OO = 1e18; vector<int> prs = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29}; long long solve(long long num, int in, int lst) { if (in == prs.size() || lst == 0) return num == 1 ? 1 : -1; long long res = -1; long long cur = 1; long long cp = num...
#include <bits/stdc++.h> using namespace std; int n, m, i, j, k, s, p, x[100001], t[100001], w[100001]; void sort1(int l, int r) { int i, j, y, z; i = l; j = r; y = x[(l + r) / 2]; do { while (x[i] < y) { i++; } while (x[j] > y) { j--; } if (!(i > ...
#include <bits/stdc++.h> using namespace std; const int buf_size = 1e5 + 5; char buf[buf_size], *S, *T; inline char gc() { if (S == T) T = (S = buf) + fread(buf, 1, buf_size, stdin); return S != T ? *(S++) : EOF; } inline int in() { int x = 0, f = 1; char c = gc(); while (c < 0 || c > ...
/** * 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_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, x; cin >> n >> x; long long count = 0; if (n >= x) { for (long long i = 1; i < n + 1; i++) { if (x % i == 0) { count++; } }...
////////////////////////////////////////////////////////////////// // // // Arithmetic Logic Unit (ALU) for Amber 2 Core // // // // This file is part of the Amber project ...
#include <bits/stdc++.h> using namespace std; long long first[60]; void do_it(long long n2, long long k2, long long x) { if (n2 == 1) { cout << x + 1; return; } if (n2 == 2) { if (k2 == 1) cout << x + 2 << << x + 1; else cout << x + 1 << << x + 2; ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long test, i, j, xy, flag = 0, n, u, count, d, o1 = 0, o2 = 0, s, e, l, r, x, y, m, z, max1, x1, y1, k, x2, y2, z1, sum, f, ...
/** * 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 2013(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // - Redistrib...
#include <bits/stdc++.h> using namespace std; long long n, mod; long long expsq(long long base, long long exp) { if (exp == 0) return 1ll; if (exp == 1) return base; if (exp & 1) return (base * expsq((base % mod * base % mod) % mod, (exp - 1) / 2)) % mod; return expsq((base % mod * base % mo...
module io1_sub( /*AUTOARG*/); wire [42:0] bscan_data; // boundary scan stitch parameter bscan_count = 0; assign bscan_data[0] = bscan_in; /* * Emacs template to auto instaniate MD[31:0] pads */ /* autoinst_lopaz_srpad AUTO_TEMPLATE ( .pin(MD[@]), .pin_in({SDRAM_DQ...
// zhiyang ong // andrew mattheisen module mux(ina, inb, out, sel); //INPUTS input [0:127] ina, inb; input sel; // OUTPUTS output [0:127] out; // REGISTERS reg [0:127] out; always @ (ina or inb or sel) begin out<= sel ? ina : inb; end // always @ (ina or inb or sel) endmodule `include control....
#include <bits/stdc++.h> using namespace std; long long parent[1000001]; long long result[1000005]; map<int, list<int>> g; long long getPoints(int p, int t) { return max((3 * p) / 10, (p - (p / 250) * t)); } struct Score { int p, t; }; bool chc(Score a, Score b) { if (a.p == b.p) { r...
#include <bits/stdc++.h> using namespace std; int n, m, dfsCont, dfs_num[2005], dfs_low[2005], numComp; vector<vector<int> > lista; string ans[2005]; vector<int> pila, comp; map<string, int> names; bool vis[2005]; void tarjan(int u) { dfs_low[u] = dfs_num[u] = dfsCont++; vis[u] = 1; pila.pus...
#include <bits/stdc++.h> using namespace std; inline bool EQ(double num4, double b) { return fabs(num4 - b) < 1e-9; } const int INF = 1 << 29; inline int two(int len) { return 1 << len; } inline int test(int len, int b) { return (len >> b) & 1; } inline void set_bit(int &len, int b) { len |= two(b); } inl...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 23:07:47 01/05/2017 // Design Name: // Module Name: Counter // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // //...
/** * 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 = 102; int t, n, m, r[N], b[N]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> t; for(int ti = 1; ti <= t; ++ti) { cin >> n; for(int i = 1; i <= n; ++i) { cin >> r[i]; r[i] += r[i - 1]; } cin >> m; ...
`timescale 1ns/1ps /*************************************************************************** Name: Date: 7/18/2016 Founction: I2C top module Note: ****************************************************************************/ module I2C_MASTER_SUBAD(clk,rst_n,sda,scl,RD_EN,WR_EN,receive_status ); input clk; input rs...
#include <bits/stdc++.h> using namespace std; int n; long long dp[4]; int a[100005]; string s; int main() { cin >> n; cin >> s; for (int i = 0; i < n; i++) { cin >> a[i]; if (s[i] == h ) dp[0] += a[i]; else if (s[i] == a ) dp[1] = min(dp[0], dp[1] + a[i]); ...
#include <bits/stdc++.h> using namespace std; template <typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << ( << p.first << , << p.second << ) ; } template <typename T_container, typename T = typename enable_if< !is_same<...
#include <bits/stdc++.h> using namespace std; multiset<int, greater<int>> m1, m2; int n, m; int main() { cin >> n >> m; for (int i = 0; i < n; ++i) { int a; cin >> a; m1.insert(a); } for (int i = 0; i < n; ++i) { int a; cin >> a; m2.insert(a); } vector...
#include <bits/stdc++.h> using namespace std; int dirx[] = {1, 0, -1, 0}; int diry[] = {0, 1, 0, -1}; int a; vector<int> graph[100005]; int dist[100005]; bool visit[100005]; int cnt = 0; bool flag = false; int dfs(int u, int par) { visit[u] = true; for (int i = 0; i < graph[u].size(); i++) {...
module vga( clk, reset, // Horizontal counter h_counter_next, // Horizontal sync h_sync, // Vertical counter v_counter_next, // Veritcal sync v_sync, // The next pixel will be displayed. will_display ); // Initialize parameters as 640 x 480 @ 60Hz parameter HOR...
#include <bits/stdc++.h> const int MAXN = 3e5 + 10; const double eps = 1e-8; using namespace std; struct edge { int t, v; edge *next; } e[MAXN << 1], *h[MAXN], *o = e; void add(int x, int y, int vul) { o->t = y; o->v = vul; o->next = h[x]; h[x] = o++; } long long read() { lon...
#include <bits/stdc++.h> using namespace std; int main() { int p, x, ans = 0; bool b; cin >> p; for (int i = 1; i < p; i++) { b = 1; x = 1; for (int j = 1; j < p - 1; j++) { x = (x * i) % p; if ((x - 1) % p == 0) b = 0; } if (((x * i) - 1) % p != 0) b = ...
module iir (clk, reset, start, din, params, dout, ready,iir_start,iir_done); input clk, reset, start; input [7:0] din; input [15:0] params; output [7:0] dout; reg [7:0] dout; output ready; reg ready; reg temp_ready; reg [6:0] finite_counter; wire count0; input iir_start; output iir_done; wire iir_done; reg del_count0; ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2009 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc = 0; reg [63:0] crc; ...
/** * 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...
#include <bits/stdc++.h> long long sum(long long val) { if (val % 2) return (val + 1) / 2 * val; return val / 2 * (val + 1); } int main() { long long n, x, d[200005], i, xx, l, ans = 0, now, tmp; scanf( %lld%lld , &n, &x); for (i = 0; i < n; i++) scanf( %lld , &d[i]); l = n - 1; xx = x...
// Copyright 2020 Efabless Corporation // // 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 agr...
#include <bits/stdc++.h> using namespace std; vector<int> f[100005]; int n, m, temp, flag = 0; int main() { cin >> n >> m; for (int i = 0; i < n; i++) { cin >> temp; f[temp].push_back(i + 1); } int j = 0, ans[100005]; for (int i = 0; i < m; i++) { cin >> temp; if (f[t...
#include <bits/stdc++.h> using namespace std; const int maxn = 300005; int n, u, v, x, trie[maxn << 1][26], sz[maxn << 1], tot, cnt[maxn], res; char op[2]; int merge(int a, int b) { if (!a || !b) return a + b; int rt = ++tot; memset(trie[rt], 0, sizeof trie[rt]); sz[rt] = 1; for (int i = 0...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...