text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int years[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31, ...
`default_nettype none `timescale 1ns/1ns module tb_panel(); wire clk, reset; clock clock(clk, reset); reg a_write = 0; reg a_read = 0; reg [31:0] a_writedata = 0; reg [4:0] a_address; wire [31:0] a_readdata; wire a_waitrequest; wire key_start; wire key_read_in; wire key_mem_cont; wire key_inst_cont; w...
#include<bits/stdc++.h> #define maxn 200005 #define endl n using namespace std; int n,m,a[maxn],dis[maxn]; vector<int> e[maxn]; queue<int> q; void bfs() { while(!q.empty()) { int u=q.front(); q.pop(); for(int i=0;i<e[u].size();i++) { int v=e[u][i]; if(dis[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; long long int f(long long int a, long long int b) { long long int z = b, x = 0; while (z > 1) { z /= 2; x++; } long long int y = pow(2, x); if (a == b) return a; else if (y <= a) return f(a - y, b - y) + y; else if (po...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 7; int a[N], n; double f(double x) { double sum = 0, mn = 0, mx = 0, ans = 0; for (int i = 0; i < n; i++) { mn = min(mn, sum); mx = max(mx, sum); sum += a[i] - x; ans = max(ans, abs(sum - mn)); ans = max(ans,...
module Prescaler(ins_o,ins_i,icm_i,rst_i,clk_i); output ins_o; input ins_i; input [2:0] icm_i; input rst_i; input clk_i; reg ins_o; reg next_ins_o_reg; reg [4:0] threshold_reg; reg [4:0] next_counter_reg; reg [4:0] counter_reg; //threshold: always @(icm_i ) begin case(icm_i ) 'h1, 'h2, 'h3 : begi...
#include <bits/stdc++.h> using namespace std; int n; int b[200010]; map<int, long long> S; long long solve() { S.clear(); long long df, ans = 0; for (int i = 0; i < n; i++) { df = b[i] - i; S[df] += (long long)b[i]; } map<int, long long>::iterator it; for (it = S.begin(); i...
#include <bits/stdc++.h> using namespace std; template <typename tp> inline void read(tp& x) { x = 0; char tmp; bool key = 0; for (tmp = getchar(); !isdigit(tmp); tmp = getchar()) key = (tmp == - ); for (; isdigit(tmp); tmp = getchar()) x = (x << 3) + (x << 1) + (tmp ^ 0 ); if (key) x = ...
// This is a component of pluto_step, a hardware step waveform generator // Copyright 2007 Jeff Epler <> // // 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 2 of ...
//Copyright 1986-2017 Xilinx, Inc. All Rights Reserved. //-------------------------------------------------------------------------------- //Tool Version: Vivado v.2017.2 (lin64) Build Thu Jun 15 18:39:10 MDT 2017 //Date : Wed Jul 5 01:27:13 2017 //Host : saturn running 64-bit Ubuntu 16.10 //Command ...
// part of NeoGS project // // (c) NedoPC 2007-2019 module chan_ctrl ( input wire clk, // 24.0 MHz input wire rst_n, // memory interface output reg [ 6:0] rd_addr, input wire [31:0] rd_data, // output reg [ 6:0] wr_addr, output wire [31:0] wr_data, output reg wr_stb, // 37500 Hz period strobe ...
#include <bits/stdc++.h> const int maxn = 5e5 + 10; using namespace std; int main() { string s; long long n; cin >> n; while (n--) { cin >> s; int b = 0, e = s.size() - 1; while (b < e && s[b] == s[e]) b++, e--; if (b >= e) cout << s << n ; else { st...
#include <bits/stdc++.h> using namespace std; struct MCMF { using F = int; const static F INF = 0x3f3f3f3f; struct Edge { int v, bro; F cap, cost; Edge() {} Edge(int _v, int _bro, F _cap, F _cost) : v(_v), bro(_bro), cap(_cap), cost(_cost) {} }; vector<Edge> e; ...
// $Header: /devl/xcs/repo/env/Databases/CAEInterfaces/verunilibs/data/unisims/VCC.v,v 1.5 2007/05/23 21:43:44 patrickp Exp $ /////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2009 Xilinx, Inc. // All Right Reserved. ///////////////////////////////////////////////////...
/** * 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; int main() { long double m, n, c = 0, k = 0, a = 0, b = 0, d; cin >> m >> n >> c >> d; long double s1, s2, x, y; a = (3 * m) / 10; b = m - (m / 250) * c; x = (3 * n) / 10; y = n - (n / 250) * d; s1 = max(a, b); s2 = max(x, y); if ...
#include <bits/stdc++.h> using namespace std; int main() { long long L, R; int n; cin >> n; while (n--) { cin >> L >> R; for (long long k = 0; k <= 60; ++k) { if ((1LL << k) & (L)) { continue; } else { if ((1LL << k) + L <= R) { L += (1LL <...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k; cin >> n >> m >> k; vector<int> v(n); vector<int> c(m + 5, 0); for (int i = 0; i < n; i++) { cin >> v[i]; } int l = 0, r = 0; int res = 1; c[v[0] - 1]++; int maxC = 1; int maxI = v[0] - 1; w...
/******************************************************************************* * 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 ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // New Serial Core // For Enterpoint Cairnsmore1 Icarus Derived Bitstream // By Paul Mumby // Licensed Under GNU GPL V3 ////////////////////////////////////////////////////////////////////////////////// module serial...
#include <bits/stdc++.h> using namespace std; const int N = 2010; struct point { point(int xx, int yy) : x(xx), y(yy) {} int x, y; }; int n, m; char a[N][N]; queue<point> q; int dx[4] = {-1, 1, 0, 0}; int dy[4] = {0, 0, -1, 1}; long long pp; bool uniq(int xx, int yy) { if (a[xx][yy] !=...
/* Copyright (c) 2015 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, distribute,...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3fffffff; const int SINF = 0x7fffffff; const long long LINF = 0x3fffffffffffffff; const long long SLINF = 0x7fffffffffffffff; const int MAXN = 300007; const int MAX = 130; int n; int a[MAXN]; int ps[MAXN]; int pc[MAXN][2]; void init...
/** * 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: 02:50:47 03/17/2011 // Design Name: // Module Name: contador_a // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: //...
#include <bits/stdc++.h> using namespace std; int n; int a[111]; int memo[111][1 << 17]; pair<pair<int, int>, int> child[111][1 << 17]; int bt[66]; class MathFunction { private: long long sieve_size; bitset<1010> bs; vector<int> primes; public: int primeid[1010]; bool isPrime(...
/** * 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...
// chris_pipelined.v // This file was auto-generated as a prototype implementation of a module // created in component editor. It ties off all outputs to ground and // ignores all inputs. It needs to be edited to make it do something // useful. // // This file will not be automatically regenerated. You should chec...
#include <bits/stdc++.h> using namespace std; long long n, r, l[210000], t[210000], ans, a[110000], b, x, y, c; int main() { scanf( %I64d%I64d , &n, &r); for (int i = 1; i <= n; i++) scanf( %I64d , &l[i]); for (int i = 1; i <= n; i++) scanf( %I64d , &t[i]); for (int i = 1; i <= n; i++) if (t...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const int inf = 10000000; int arr[100005]; map<int, int> mm; int main() { int n, k; cin >> n >> k; for (int i = 0; i < (n); i++) { cin >> arr[i]; mm[arr[i]] = 1; } sort(arr, arr + n); int ans = 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...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: bw_clk_cl_fpu_cmp.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...
#include <bits/stdc++.h> using namespace std; const int INF = (int)1e9 + 7, mod = (int)1e9 + 9, pw = 31, N = (int)1e5 + 123, M = (int)1e6 + 123; const double eps = 1e-11; const unsigned long long inf = 5e18 + 1; unsigned long long n, a, b, x, m, ans; bool check = 0; unsigned long long binpow(u...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 19:26:11 07/23/2010 // Design Name: // Module Name: dac_test // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // Revision:...
#include <bits/stdc++.h> using namespace std; template <class T> T sqr(T x) { return x * x; } long double pi = 3.1415926535897932384626433832795; long long mod = 1e9 + 7; const int N = 1e6 + 10; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } vector<vector<long long> > e(...
/* * 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 dist[100010], n; vector<pair<int, int> > gr[100010]; void dfs() { memset(dist, -1, sizeof(dist)); dist[1] = 0; queue<int> q; q.push(1); while (!q.empty()) { int u = q.front(); q.pop(); for (int i = 0; i < gr[u].size(); i++) ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int k = 0; while (1) { k++; if (k % m == 0) n++; n--; if (n == 0) break; } cout << k; return 0; }
/* Copyright (c) 2014-2018 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...
//----------------------------------------------------- // Design Name : serial_crc_ccitt // File Name : serial_crc.v // Function : CCITT Serial CRC // Coder : Deepak Kumar Tala //----------------------------------------------------- module serial_crc_ccitt ( clk , reset , enable , init , data_in ...
#include <bits/stdc++.h> using namespace std; const int MOD = int(1e9) + 7; long long pom[2][2] = {{0, 1}, {1, 1}}; void mulMat(long long *A, long long *B, int n) { long long res[2][2] = {{0}}; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) for (int k = 0; k < n; k++) { ...
#include <bits/stdc++.h> using namespace std; long long n, l; string s, s1, s2; int main() { cin >> n; getline(cin, s); while (n--) { getline(cin, s); s1 = ; s2 = ; l = s.length(); for (int i = 0; i <= 4; i++) s1 += s[i]; for (int i = l - 5; i < l; i++) s2 += ...
// Accellera Standard V2.5 Open Verification Library (OVL). // Accellera Copyright (c) 2005-2010. All rights reserved. wire [width-1:0] test_expr_i = ~test_expr; wire [width-1:0] test_expr_i_1 = test_expr_i - {{width-1{1'b0}},1'b1}; wire inactive_val=(inactive==`OVL_ALL_ONES)?1'b1:1'b0; `ifdef OVL_ASSERT_ON ...
#include <bits/stdc++.h> using namespace std; vector<int> computer(100, 0); int n, q, free_computers; long s; int t, k, d; void question() { cin >> t >> k >> d; free_computers = 0; for (int j = 0; j < n && free_computers < k; j++) { if (computer[j] <= t) free_computers++; } if (k >...
/*************************************************************** ** Author: Oswaldo Cadenas () ** Date: September 26 2011 ** ** Test: Intended to test parametric counter in timebase.vhd ** the counter has parameters: N for counter length and VALUE to flag when the count reaches this value ** ** Four coun...
`ifndef INCLUDE_PARAMS `include "params.v" `endif `ifndef INCLUDE_ISA `include "ISA.v" `endif module ID ( input wire clk, // Clock input wire rst_n, // Asynchronous reset active low // pipeline in input wire [`WIDTH - 1:0] IR_in, input wire [`WIDTH - 3:0] PC_in, // pipeline out output wire [`WIDTH - ...
/* * Milkymist SoC * Copyright (C) 2007, 2008, 2009, 2010 Sebastien Bourdeauducq * * 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, version 3 of the License. * * This program is distribut...
// (C) 2001-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 associated doc...
#include <bits/stdc++.h> using namespace std; int n, a, b, k, cnt = 0, ans; string s; vector<int> arr; int main(void) { ios ::sync_with_stdio(0); cin.tie(0); cin >> n >> a >> b >> k >> s; for (int i = 1; i <= n; ++i) { if (s[i - 1] == 0 ) { ++cnt; } else { cnt = 0;...
#include <bits/stdc++.h> using namespace std; long long n, ans[100001], curr, deg[100001] = {0}; vector<pair<int, int>> adj[100001]; void dfs(long long u, long long p) { for (auto v : adj[u]) { if (v.first == p) { continue; } if (ans[v.second] == -1) { ans[v.second] = curr+...
/* * yosys -- Yosys Open SYnthesis Suite * * Copyright (C) 2021 Cologne Chip AG <> * * 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 permission notice appear in all copies....
#include <bits/stdc++.h> using namespace std; const int N = 6e5; const int oo = 1e9 + 5; int du[] = {-1, 0, 0, 1}; int dv[] = {0, -1, 1, 0}; const long long mod = 1e9 + 7; long long sqr(long long x) { return x * x; } int n, x, a[N + 5], ans; bool vis[N + 5]; int main() { ios_base::sync_with_stdi...
#include <bits/stdc++.h> using namespace std; int main() { int n, s1, s2; while (cin >> n) { vector<string> array(4); array[0] = |#.#.#.#.#.#.#.#.#.#.#.|D|) ; array[3] = |#.#.#.#.#.#.#.#.#.#.#.|.|) ; array[1] = |#.#.#.#.#.#.#.#.#.#.#.|.| ; array[2] = |#........................
#include <bits/stdc++.h> using namespace std; void solve(int test_number); int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.setf(ios::fixed); cout.precision(9); cerr.setf(ios::fixed); cerr.precision(3); int n = 1; for (int i = 0; i < n; i++) { solve(i); ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2021 Yutetsu TAKATSUKASA. // SPDX-License-Identifier: CC0-1.0 `ifdef ENABLE_SPLIT_VAR `define SPLIT_VAR_COMMENT /* verilator split_var */ `else `define SPLIT_VAR_COM...
/** * 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 int gcd(long long int a, long long int b) { if (a == 0) { return b; } if (b == 0) { return a; } return gcd(b, a % b); } long long int power(long long int x, long long int n) { long long ans = 1; while (n > 0) { ...
// Accellera Standard V2.5 Open Verification Library (OVL). // Accellera Copyright (c) 2005-2010. All rights reserved. `include "std_ovl_defines.h" `module ovl_width (clock, reset, enable, test_expr, fire); parameter severity_level = `OVL_SEVERITY_DEFAULT; parameter min_cks = 1; parameter max_cks ...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimization( unroll-loops ) using namespace std; const long long large = 1e11, remi2 = 998244353; const long long remi = 1e9 + 7, inf = LLONG_MAX; const long double Pi = acos(-1); long long PowI(long long a, long long b, long long m) { ...
//Copyright 1986-2017 Xilinx, Inc. All Rights Reserved. //-------------------------------------------------------------------------------- //Tool Version: Vivado v.2017.2 (lin64) Build Thu Jun 15 18:39:10 MDT 2017 //Date : Fri Jun 23 10:19:08 2017 //Host : dshwdev running 64-bit Ubuntu 16.04.2 LTS //Comm...
#include <bits/stdc++.h> using namespace std; int a[101], res; int b[101]; int main() { int n, i, k, t; cin >> n >> k; for (i = 0; i < n; i++) { cin >> t; a[t]++; } while (1) { for (i = 1; i <= k; i++) b[i] = 0; t = 0; for (i = 1; i < k; i++) if (a[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...
// ---------------------------------------------------------------------- // Copyright (c) 2015, The Regents of the University of California All // rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met:...
#include <bits/stdc++.h> using namespace std; const double PI = 2 * acos(0.0); mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count()); const string DIGITS = 0123456789 ; const string ALPH = abcdefghijklmnopqrstuvwxyz ;...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2018 by Alex Solomatnikov. interface hex2ram_if ( input bit trigger ); string instance_path = $sformatf("%m"); string testfile = ""; bit has_testf...
#include <bits/stdc++.h> using namespace std; int n, a, b, c; int main() { ios_base::sync_with_stdio(false); cin >> n >> a >> b >> c; if (n == 1) cout << 0 << endl; else if (c >= min(a, b)) cout << (n - 1) * min(a, b) << endl; else cout << min(a, b) + (n - 2) * c << endl; ...
#include <bits/stdc++.h> using namespace std; int n, m; int ansx, ansy; int a[300005][10]; int b[300005]; int check(long long x) { memset(b, 0, sizeof(b)); for (int i = 1; i <= n; i++) { int p = 0; for (int j = 1; j <= m; j++) { if (a[i][j] >= x) p += (1 << (j - 1)); } ...
#include <bits/stdc++.h> using namespace std; template <class T> bool cmin(T &a_, T b_) { return a_ > b_ ? (a_ = b_, true) : false; } template <class T> bool cmax(T &a_, T b_) { return a_ < b_ ? (a_ = b_, true) : false; } template <class T> void OUT(T s_) { cout << s_ << n ; exit(0);...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const int maxn = 4; template <class T> struct Matrix { int r, c; T a[maxn][maxn]; Matrix() { memset(a, 0, sizeof a); } Matrix(int si) { memset(a, 0, sizeof a); r = c = si; for (int i = 0; i < si; i++...
#include <bits/stdc++.h> using namespace std; const int MAXN = 4000; long long p[MAXN + 10], v[MAXN + 10], d[MAXN + 10]; bool lft[MAXN + 10]; int n; void print(int n) { for (int i = 0; i < n; i++) cout << p[i] << ; cout << endl; for (int i = 0; i < n; i++) cout << lft[i] << ; cout << e...
#include <bits/stdc++.h> using namespace std; long long n, m, k; vector<long long> arr; void solve() { cin >> n >> m >> k; arr.resize(n); for (long long i = 0; i < n; i++) cin >> arr[i]; vector<long long> b; long long l = arr[n - 1] - arr[0]; ; for (int i = 1; i < n; i++) { b.p...
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); struct Item { int c; int x; Item() : c(), x() {} Item(int _c, int _x) : c(_c), x(_x) {} }; const long long INF = (long long)1e16; const int N = 505; int n, m, k; vector<Item...
/* * Copyright (c) 2000 Yasuhisa Kato <> * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU * General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) * ...
#include <bits/stdc++.h> using namespace std; vector<int> vec[201], v[201]; int afis[201], scor[201], n, test[201]; bool viz[201]; void elim(int val) { for (int i = 0; i < v[val].size(); i++) scor[v[val][i]]--; } bool incearca(int start) { int i, j; for (i = 1; i <= n; i++) { scor[i] = v...
#include <bits/stdc++.h> using namespace std; int main() { int n; string a, b, tem; scanf( %d , &n); a = <3 ; for (int i = 0, j = 0; i < n; ++i) { cin >> tem; a += tem; a += <3 ; } cin >> b; int len1 = a.length(), po1 = 0, po2 = 0; int len2 = b.length(); w...
/** * 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[1000005]; long long c[2000015]; long long n; int main() { ios_base::sync_with_stdio(0); cin >> n; long long ma = 0; for (int i = 0; i < n; i++) { cin >> a[i]; c[a[i]]++; ma = max(ma, a[i]); } long long ans = 0;...
#include <bits/stdc++.h> using namespace std; vector<long long> a; char op[3]; long long res; void Gao(vector<long long> a) { if (a.size() == 1) { if (res == -1) res = a[0]; else res = min(res, a[0]); return; } vector<long long> tmp; for (int i = 0; i < a.size...
module ibex_fetch_fifo ( clk_i, rst_ni, clear_i, in_valid_i, in_ready_o, in_addr_i, in_rdata_i, in_err_i, out_valid_o, out_ready_i, out_addr_o, out_rdata_o, out_err_o ); parameter [31:0] NUM_REQS = 2; input wire clk_i; input wire rst_ni; input wire clear_i; input wire in_valid_i; output wire in_ready...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 14:58:59 04/05/2017 // Design Name: // Module Name: Timing // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // ...
// file: Clock35MHz_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...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 16:53:51 09/14/2015 // Design Name: Selector_Casillas // Module Name: C:/Users/Arturo/Desktop/Proyecto Corto 1 14Set/Gato/Test_selector_casillas.v // Project...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; while (n--) { string s; cin >> s; bool b = true, b1 = false, b2 = true, b3 = false; int sum = 0; for (int i = 0; i < s.size(); i++) { sum += (int)s[i] - 48; int x = (int)s[i] - 48; ...
#include <bits/stdc++.h> using namespace std; const int MAXN = (107); const int inf = (int)1e9 + 42; struct aho_corasick { int is_end[MAXN], link[MAXN], psz; map<char, int> to[MAXN]; void clear() { for (int i = 0; i < psz; i++) is_end[i] = 0, link[i] = 0, to[i].clear(); psz = 1; is...
//////////////////////////////////////////////////////// // RS-232 RX and TX module // (c) fpga4fun.com & KNJN LLC - 2003 to 2013 // The RS-232 settings are fixed // TX: 8-bit data, 2 stop, no-parity // RX: 8-bit data, 1 stop, no-parity (the receiver can accept more stop bits of course) //`define SIMULATION // in t...
#include <bits/stdc++.h> using namespace std; int main() { long long int w, h; cin >> w >> h; long long int cnt = 0; for (int i = 2; i <= w; i += 2) { for (int j = 2; j <= h; j += 2) { cnt += ((w - i + 1) * (h - j + 1)); } } cout << cnt; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a[105]; int b[105]; int t, flag, flag1, i, n, c, sum1, sum2; scanf( %d , &n); for (i = 1; i <= n; i++) { scanf( %d , &a[i]); b[a[i]] = 1; } int count = 0; int sum = 0; flag = 1; int d = -1; c = 0; ...
`include "timescale.v" module fb_slave_statem (MRxClk, Reset, MRxDV, MRxDEqDataSoC, MRxDEq5, SlaveDataStart SlaveDataEnd, SlaveCrcEnd, LastSlave, DataFrameEnd, FrmCrcStateEnd, StateIdle, StatePreamble, StateFFS, StateData, StateSlaveData, StateSlaveCrc, StateFrmCrc ); inp...
/****************************************************************************** * License Agreement * * * * Copyright (c) 1991-2012 Altera Corporation, San Jose, California, USA. * ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // // // // // // Create Date: 12:12:51 08/04/2014 // Module Name: SpiCtrl // Project Name: ZedboardOLED // Target Devices: Zynq // Tool versions: Vivado 14.2 (64-bits) // Descript...
//`include "uart_tx_buffer.v" `timescale 1ns/1ns module uart_tx_buffer_tb(); // Declare inputs as regs and outputs as wires reg clk, rst; reg[7:0] data; reg dataReady; reg txBusy; wire txStart; wire[7:0] txData; uart_tx_buffer U0( .clk(clk), .rst(rst), .data(data), .dataReady(dat...
// Check that the >> and >>> operators with unsigned values. module top; parameter py = 8'b10101010 >> 3'b101; parameter pz = 8'b10101010 >>> 3'b101; reg passed; reg [7:0] a; reg [2:0] b; wire [7:0] wy, wz; reg [7:0] ry, rz; // Check CA code. assign wy = a >> b; assign wz = a >>> b; initial...
#include <bits/stdc++.h> using namespace std; const int Direction[4][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; const int Nmax = 303000; long double n, m; long double ans = 0; int main() { ios_base::sync_with_stdio(0); cin >> n >> m; long double r = n * m; for (int k = 1; k <= min(n, m); k++) ...
module KeyboardReader ( input wire rst, input wire clk, inout wire ps2CLK, inout wire ps2DATA, output reg[8:0] pressedKey, output reg pressed ); wire[7:0] readData; wire update; reg update_prev; always @ (posedge clk) update_prev <= update; wire update_posedge = !update_prev && update; ...
#include <bits/stdc++.h> using namespace std; int n, a, b, k, h[200010]; int main() { scanf( %d%d%d%d , &n, &a, &b, &k); int ans = 0, x; for (int i = 1; i <= n; i++) { scanf( %d , &x); if (x % (a + b) == 0) x -= (x / (a + b) - 1) * (a + b); else x -= (x / (a + b)) * (...
//----------------------------------------------------------------------------- //-- Divisor de reloj //-- Señal de periodo igual al indicado //-- El ancho del pulso positivo es de 1 ciclo de reloj //-- //-- (c) BQ. September 2015. written by Juan Gonzalez (obijuan) //---------------------------------------------------...
#include <bits/stdc++.h> using namespace std; long long n, k, x, r, z, sol; int main() { cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> x; if (r > 0) { x = x - k + r; sol++; } z = x / k; sol += z; r = x % k; } if (r > 0) { sol++; ...
#include <bits/stdc++.h> using namespace std; template <typename T> T sqr(T x) { return x * x; } template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } const int MAXN = 600; int n, m; int x, y, cnt; bool us[MAXN][MAXN]; string s; int main() { ios_base ::sync_with_s...