text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int main() { int a, b, t = 0, c = 0; cin >> a >> b; t += a; while (b <= a) { c = a % b; a /= b; t += a; a += c; } cout << t << endl; return 0; }
#include <bits/stdc++.h> using namespace std; void hike() { int64_t n; cin >> n; string s, t; cin >> s >> t; vector<int64_t> f; for (int64_t i = 0; i < n; ++i) { if (s[i] != t[i]) { f.push_back(i); } } if (f.size() != 2) { cout << No n ; return; }...
#include <bits/stdc++.h> using namespace std; int main() { pair<int, int> orig[3]; int a, b, x1, y1, t = 0; for (int i = 0; i < 3; i++) { cin >> orig[i].first >> orig[i].second; } cout << 3 << endl; a = (orig[0].first + orig[1].first) / 2; b = (orig[0].second + orig[1].second) / ...
module fetch( dispatch2cu_wf_dispatch, dispatch2cu_wf_tag_dispatch, dispatch2cu_start_pc_dispatch, dispatch2cu_vgpr_base_dispatch, dispatch2cu_sgpr_base_dispatch, dispatch2cu_lds_base_dispatch, dispatch2cu_wf_size_dispatch, dispatch2cu_wg_wf_count, buff_ack, w...
#include <bits/stdc++.h> using namespace std; const int jly = 1000000007; const unsigned long long bas = 31; int f[2][1000005], *p[2]; unsigned long long q[1000005]; char t[1000005]; struct bxt { int l; char *s; unsigned long long *h; inline void init(char *u) { for (l = 0; u[l]; ++l...
#include <bits/stdc++.h> using namespace std; map<int, int> mp; int read() { int c = 0; char ch = getchar(); while (ch < 0 || 9 < ch) ch = getchar(); while ( 0 <= ch && ch <= 9 ) c = c * 10 + ch - 0 , ch = getchar(); return c; } int main() { int n = read(), P = read(), k = read(...
// megafunction wizard: %FIFO%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: scfifo // ============================================================ // File Name: rule_32_30.v // Megafunction Name(s): // scfifo // // Simulation Library Files(s): // altera_mf // ============================...
#include <bits/stdc++.h> using namespace std; int MIN(int a, int b) { return a < b ? a : b; }; int MAX(int a, int b) { return a > b ? a : b; }; int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } int n, m, q; int h; int a[20] = {2, 4, 3, 9, 5, 25, 7, 49, ...
/************************************************************************ * File Name : copy.v * Version : * Date : * Description : * Dependencies : * * Company : Beijing Soul Tech. * * Copyright (C) 2008 Beijing Soul tech. * *********************************************...
#include <bits/stdc++.h> using namespace std; int n, a[2005]; long long sum[10005], D[5005]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) D[abs(a[i] - a[j])]++; sum[5000] = 0; double ans = 0...
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 1; const long long LINF = 1e18 + 1; int n; int X1_1 = 1; int Y1_1 = 1; int X2_1 = 2; int Y2_1 = 2; int X1_2 = 4; int Y1_2 = 4; int X2_2 = 5; int Y2_2 = 5; int ask(int x1, int y1, int x2, int y2) { cout << ? << x1 << ...
// megafunction wizard: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: scfifo // ============================================================ // File Name: fifo_144x128.v // Megafunction Name(s): // scfifo // // Simulation Library Files(s): // altera_mf // ==========================================...
#include <bits/stdc++.h> using namespace std; long long tree[4 * 100100]; long long a[100100]; int n; void build(int from, int to, int node) { if (from == to) { tree[node] = a[from]; return; } int mid = (from + to) / 2; build(from, mid, 2 * node); build(mid + 1, to, 2 * node + ...
#include <bits/stdc++.h> using namespace std; int main() { const long long MOD = 1000000009; int n, m; cin >> n >> m; long long ret = 1; long long x = 1; for (int i = 0; i < (int)(m); i++) x = x * 2 % MOD; x = (x - 1 + MOD) % MOD; for (int i = 0; i < (int)(n); i++) { ret = ret ...
#include <bits/stdc++.h> using namespace std; double cp(const complex<double> &a, const complex<double> &b) { return a.real() * b.imag() - b.real() * a.imag(); } inline complex<double> line_inter(const complex<double> &a, const complex<double> &b, ...
#include <bits/stdc++.h> using namespace std; int a[1000000], l[1000000], r[1000000]; int main() { int n; cin >> n; int minn = 10000000; int kol = 0; int ans = 0; int m = 2 * n - 1; for (int i = 0; i < m; i++) { cin >> a[i]; if (a[i] < 0) { kol++; a[i] = -a[...
#include <bits/stdc++.h> int main() { int n, m; scanf( %d%d , &n, &m); if (n % 2 != 0) { printf( %d , n); } else { int a[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { scanf( %d , &a[i][j]); } } bool isSymmetric = true; ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// module fft32_TB; parameter total_bits = 32; reg ED; reg RST; reg CLK; reg START; reg ifft; wire [total_bits-1:0] DImag; wire [total_bits-1:0] DReal; wire signed [total_bits-1:0] DOImag; wire signed ...
///////////////////////////// //LAB01 29/05 - Atividade 1// ///////////////////////////// module Mod_Teste( input CLOCK_27, input CLOCK_50, input [3:0] KEY, input [17:0] SW, output [6:0] HEX0, output [6:0] HEX1, output [6:0] HEX2, output [6:0] HEX3, output [6:0] HEX4, output [6:0] HEX5, outpu...
// $Id: c_decr.v 5188 2012-08-30 00:31:31Z dub $ /* Copyright (c) 2007-2012, Trustees of The Leland Stanford Junior University All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of so...
/* * 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...
`timescale 1 ns / 1 ps module axi_axis_reader # ( parameter integer AXI_DATA_WIDTH = 32, parameter integer AXI_ADDR_WIDTH = 16 ) ( // System signals input wire aclk, input wire aresetn, // Slave side input wire [AXI_ADDR_WIDTH-1:0] s_axi_awaddr, // AXI4-Lit...
#include <bits/stdc++.h> using namespace std; double PI = 3.14159265358979323843; int BS(int arr[], int sz, int n) { int l = 0, r = sz - 1, mid; while (l <= r) { if (arr[mid] >= n) r = mid - 1; else l = mid + 1; } return l; } bool prime(long long x) { for (int i...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2015 Xilinx, Inc. // All Rights Reserved /////////////////////////////////////////////////////////////////////////////// // ____ ____ // / /\/ / // /___/ \ / Vendor: Xilinx // \ \ \/ Version: 1.0...
#include <bits/stdc++.h> const int N = 1e5 + 5; struct ooo { int v, id; } p[N << 1]; bool operator<(const ooo& a, const ooo& b) { return a.v < b.v; } int n, ans, id, h, m, k, x; int main() { scanf( %d%d%d%d , &n, &h, &m, &k); m /= 2; for (int i = 1; i <= n; i++) scanf( %d%d , &x, &p[i]...
#include <bits/stdc++.h> const double PI = acos(-1); int N; long long A; struct point { long long x, y; } p[100001]; struct line { double start, end; } q[100001]; inline long long sqr(long long x) { return x * x; } inline double tan_360(double x, double y) { if (x == 0) return PI * (y > 0 ...
# include <bits/stdc++.h> # define int long long using namespace std; const int N=505; const int mo=998244353; int a[2*N][N],b[N][N]; bool f[2*N]; int Pow(int x,int n) { int ans=1; while (n) { if (n&1) ans=ans*x%mo; x=x*x%mo; n>>=1; } return ans; } ...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 21:07:01 10/14/2013 // Design Name: Logica_Pong // Module Name: C:/Users/Fabian/Documents/GitHub/taller-diseno-digital/Lab4/lab_pong/test_logica_pong.v // Project Nam...
#include <bits/stdc++.h> const int inf = (1 << 30) - 1; const double eps = 1e-9; using namespace std; int a[111111], n, k, mx = 0, aa; long long s[111111]; int main() { scanf( %d%d , &n, &k); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); sort(a + 1, a + n + 1); for (int i = 1; i <= n; i++...
#include <bits/stdc++.h> using namespace std; template <typename T> void chkmax(T &x, T y) { x = x > y ? x : y; } template <typename T> void chkmin(T &x, T y) { x = x > y ? y : x; } const int INF = (1ll << 30); template <typename T> void read(T &x) { x = 0; bool f = 1; char ch; ...
//############################################################################# //# Purpose: SPI slave # //############################################################################# //# Author: Andreas Olofsson # ...
//***************************************************************************** // (c) Copyright 2008 - 2010 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 /...
/* * 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 argc, char** argv) { ios_base::sync_with_stdio(false); cin.tie(NULL); int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; double slope; slope = x2 == x1 ? INT_MAX : (double)(y2 - y1) / (double)(x2 - x1); if (slope == 0 || abs(slope)...
#include <bits/stdc++.h> using namespace std; int n, m; int ans; int a[400050]; int back[400050]; vector<int> edge[400050]; int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1, u, v; i <= m; i++) { ...
#include <bits/stdc++.h> using namespace std; const int maxN = 3 * (int)1e5 + 100; int b[maxN]; int t[4 * maxN]; int a[maxN]; void build(int v, int tl, int tr) { if (tl == tr) { t[v] = a[tl]; return; } int tm = (tl + tr) / 2; build(v + v, tl, tm); build(v + v + 1, tm + 1, tr)...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2013 Xilinx Inc. // All Right Reserved. /////////////////////////////////////////////////////////////////////////////// // // ____ ___ // / /\/ / // /___/ \ / Vendor : Xilinx // \ \ \/ Versi...
/** * 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 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...
#include <bits/stdc++.h> using namespace std; struct item { long long val; int ind; bool operator<(const item& o) const { return val < o.val; } }; long long n, m, k, s; vector<long long> dollar, pound, dday, pday; vector<item> ditems, pitems; void readIt() { cin >> n >> m >> k >> s; lo...
/* 00: Set master reset 01: Shift register 10: Storage register 11: Output Enable */ module shift( input clk , input rst , input vld , input [1:0] cmd , input cmd_oen , input [7:0] din , output done , output sft_shcp , output sft_ds , outp...
#include <bits/stdc++.h> using namespace ::std; const long long maxn = 1e5 + 500; const long long mod = 1e9 + 7; const long long inf = 1e9 + 500; long long out[maxn]; long long in[maxn]; long long a[maxn]; long long b[maxn]; long long dp[2][maxn]; int main() { fill(out, out + maxn, -1); fill...
#include <bits/stdc++.h> using namespace std; const int N = 20; char s1[N], s2[N], ans[N]; int main() { scanf( %s%s , s1, s2); int n1 = strlen(s1), cnt = 0; ans[cnt++] = s1[0]; for (int i = 1; i < n1; i++) { if (s1[i] >= s2[0]) break; ans[cnt++] = s1[i]; } ans[cnt++] = s2[0];...
//doing a 800 difficulty question using dynammic programming #include<bits/stdc++.h> #define ll long long using namespace std; int main(){ int t; cin>>t; while(t--){ ll n,m,k; cin>>n>>m>>k; ll dp[n][m]; for(ll i=0;i<n;i++){ for(ll j=0;j<m;j...
/** * 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...
//altclkctrl CBX_SINGLE_OUTPUT_FILE="ON" CLOCK_TYPE="Global Clock" DEVICE_FAMILY="Cyclone IV E" ENA_REGISTER_MODE="falling edge" USE_GLITCH_FREE_SWITCH_OVER_IMPLEMENTATION="OFF" ena inclk outclk //VERSION_BEGIN 16.1 cbx_altclkbuf 2016:11:22:18:30:39:SJ cbx_cycloneii 2016:11:22:18:30:39:SJ cbx_lpm_add_sub 2016:11:22:18:...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int maxn = 2e5 + 9; void test_case(int tc) { int k; cin >> k; int n = 12; int arr[12]; for (int i = 0; i <= 11; ++i) cin >> arr[i]; sort(arr, arr + 12, greater<int>()); int ans = 0; int temp = 0; if ...
// (C) 2001-2011 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 main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, k; cin >> n >> k; int hash[201] = {0}; vector<pair<int, int>> v; for (int i = 0; i < n; i++) { int l, r; cin >> l >> r; v.push_back(mak...
#include <bits/stdc++.h> using namespace std; const int sz = 1e6 + 9; int n, m, k; long long tr[sz], tr_sum, tr_cnt; long long ret[sz], ret_sum, ret_cnt; int d, first, t, c; vector<pair<pair<int, int>, pair<int, int>>> v; vector<pair<long long, long long>> home; long long home_ans[sz]; long long ans...
#include <bits/stdc++.h> using namespace std; int depth[200005], dad[200005]; int dep = 0; void node_depth(vector<int> vec[], int i) { dep = depth[i] + 1; for (auto j : vec[i - 1]) { if (j != dad[i]) { depth[j] = dep; } } for (auto j : vec[i - 1]) { if (j != dad[i]) { ...
// trigger_delay.v `timescale 1 ns / 1 ps module trigger_delay #(parameter N=3) ( input clk, input sync, input reset, input [7:0]delay, input trg_in, input [(N-1):0]data_in, output reg trg_out, output reg [(N-1):0]data_out ); // time stamp counter reg [7:0]t; always @(posedge clk or posedge reset) ...
#include <bits/stdc++.h> using namespace std; int main() { long long n, s = 1; char a; string b[10], c; cin >> n; b[0] = ; b[1] = ; b[2] = 2 ; b[3] = 3 ; b[4] = 322 ; b[5] = 5 ; b[6] = 53 ; b[7] = 7 ; b[8] = 7222 ; b[9] = 7332 ; int k = 0; ...
#include <bits/stdc++.h> using namespace std; int a[111][111], x[111], k; int main() { int n, m; cin >> n >> m; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> a[i][j]; int in = 0; for (int i = 0; i < n; i++) if (a[i][0] < a[in][0]) in = i; for (int i = 0; i < n;...
#include <bits/stdc++.h> using namespace std; vector<pair<int, double>> ans[52]; int main() { int n, w, m; cin >> n >> w >> m; double s = (n * w) / (m * 1.0), c = w, b = 1, k = 0; for (int i = 0; i < m; i++) { double ne = s; while (1) { if (ne + 10e-7 > c) { ans[i].pu...
#include <bits/stdc++.h> using namespace std; void dropAny(const vector<int> &a, int offset, vector<bool> &used) { vector<int> next(used.size(), a.size()); for (int i = int(a.size()) - 1; i >= offset; --i) { next[a[i]] = i; } int best = -1; for (int i = 0; i < (int)used.size(); ++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; const int N = 3e5 + 10; long long ans, res; int L[N], R[N]; int n, a[N]; long long dp[40][2]; void solve(int d, int l, int r) { if (l >= r) return; if (d == -1) return; int nl = 0, nr = 0; long long tmp1 = 0, tmp2 = 0; ; for (int i = l;...
#include <bits/stdc++.h> using namespace std; int main() { int n, k, temp; cin >> n >> k; int arr[n], sum[n]; for (int i = 0; i < n; i++) cin >> arr[i]; for (int i = 0; i < n; i++) { if (arr[i] == 0) sum[i] = 0; else sum[i] = sum[arr[i] - 1]; temp = i > k ? k : ...
#include <bits/stdc++.h> using namespace std; bool vis[1000][1000]; bool lab[1000][1000]; vector<int> ans; int comp[1000][1000]; int cur_ans; int cur_comp = 0; int dfs(int x, int y) { if (!lab[x][y]) { ++cur_ans; return 0; } if (!vis[x][y]) { comp[x][y] = cur_comp; vi...
#include <bits/stdc++.h> using namespace std; int a[100100]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n, k; cin >> n >> k; for (int i = 0; i < n; i++) cin >> a[i]; const long long max_pow = 1e9 * 1e5; vector<long long> powers = {1}; if ...
/** * 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 MemAlu( /* verilator lint_off UNUSED */ clk, mode, baseAddr, idxAddr, idxDisp, outAddr ); input clk; input[2:0] mode; input[63:0] baseAddr; input[31:0] idxAddr; input[31:0] idxDisp; output[63:0] outAddr; reg[31:0] tIdxAddr; reg[63:0] tIdxAddr2; reg[63:0] tOutAddr; parameter[2:0] MD_NONE = 3'b000; pa...
#include <bits/stdc++.h> using namespace std; const int N = 601000; struct SuffixArray { int s[N], sa[N], rk[N], height[N], t[N], t2[N], c[N], n; void clear() { n = 0; } void build_sa(int m) { int *x = t, *y = t2; for (int i = 0; i < m; i++) c[i] = 0; for (int i = 0; i < n; i++) c[x[...
// In the name of Allah. // We re nothing and you re everything. // Ya Ali! #include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAX_N = 1e5 + 14, MAX_K = 40; int n, k; struct XorKeeper { int a[MAX_K]{}; XorKeeper operator^(const XorKeeper &o) { ...
// ulight_fifo_hps_0.v // This file was auto-generated from altera_hps_hw.tcl. If you edit it your changes // will probably be lost. // // Generated using ACDS version 17.1 593 `timescale 1 ps / 1 ps module ulight_fifo_hps_0 #( parameter F2S_Width = 0, parameter S2F_Width = 1 ) ( output wire h2f_rst_n...
//============================================================= // // Copyright (c) 2017 Simon Southwell. All rights reserved. // // Date: 30th May 2017 // // This code 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 So...
#include <bits/stdc++.h> using namespace std; long long res, n, k, d = 0, f, s, moy, mx; long long t[300003]; bool b = true; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> k; for (long long i = 0; i < n; i++) cin >> t[i]; reverse(t, t + n); f = k - 1; while (d <...
module center_pos(x_row , y_col ,reset , clk ,center_x,center_y,valid); input [15:0] x_row; input [15:0] y_col ; input reset; input clk ; input [15:0] valid ; output [15:0] center_x; output [15:0] center_y; reg [15:0] center_x; reg [15:0] center_y; reg [31:0] center_x_temp; reg [31:0] center_y_temp; ...
/* * MBus Copyright 2015 Regents of the University of Michigan * * 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 ...
// fixme: clock gating - возможно делить частоту через ena плохо // // http://electronics.stackexchange.com/questions/73398/gated-clocks-and-clock-enables-in-fpga-and-asics // // // learn // // fixme: syn 4 tgrs - why? // https://www.altera.com/support/support-resources/design-examples/design-software/verilog/ver-stat...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int otg = 1 << 30, i; for (i = 0; i < m; i++) { int l, r; cin >> l >> r; if (r - l + 1 < otg) otg = r - l + 1; } cout << otg << endl; for (i = 0; i < n; i++) cout << i % otg << ; ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int b[m]; for (int i = 0; i < m; cin >> b[i++]) ; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (b[j] <= i + 1) { cout << b[j] << ; break; } ...
#include <bits/stdc++.h> const int N = 2005; using namespace std; bitset<N> f[N]; int n; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { int t; scanf( %d , &t); if (t > 0) f[i][j] = 1; } } for (int i = 1; i <= n; i...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 15:06:53 11/19/2013 // Design Name: // Module Name: top_module // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: //...
#include <bits/stdc++.h> using namespace std; int n, m; int mat[505][505]; const int N = 3e5 + 10, C = 26, inf = 1e7; bool check(int i, int j) { if ((i - 1 > 0 || i - 1 == 0) && mat[i - 1][j] == 1) { return 1; } if ((j - 1 > 0 || j - 1 == 0) && mat[i][j - 1] == 1) { return 1; } ...
//Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. //-------------------------------------------------------------------------------- //Tool Version: Vivado v.2016.2 (lin64) Build Thu Jun 2 16:32:35 MDT 2016 //Date : Thu Jul 27 14:59:42 2017 //Host : wi18as33032 running 64-bit Red Hat Enterprise Li...
#include <bits/stdc++.h> using namespace std; vector<long long> v[10001]; long long n, ass1, ass2; int main() { v[1].push_back(1); v[1].push_back(2); v[2].push_back(1); v[2].push_back(3); v[3].push_back(2); v[3].push_back(3); cin >> n; ass1 = ass2 = 3; while (ass1 + ass2 <= n...
`define ADDER_WIDTH 024 `define DUMMY_WIDTH 128 `define 3_LEVEL_ADDER module adder_tree_top ( clk, isum0_0_0_0, isum0_0_0_1, isum0_0_1_0, isum0_0_1_1, isum0_1_0_0, isum0_1_0_1, isum0_1_1_0, isum0_1_1_1, sum, ); input clk; input [`ADDER_WIDTH+0-1:0] isum0_0_0_0, isum0_0_0_1, isum0_0_1_0, isum0_0_1_1, isum0_1_0_0,...
/* * yosys -- Yosys Open SYnthesis Suite * * Copyright (C) 2012 Clifford Wolf <> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * T...
#include <bits/stdc++.h> using namespace std; int n, m, f, vis[101][101][101]; char a[1001][1001]; int valid(int x, int y) { return (x >= 1 && x <= n && y >= 1 && y <= m); } int occupies(int x, int y, int turn) { y = y + (turn - 1) * 2; if (valid(x, y) && a[x][y] >= A && a[x][y] <= Z ) return 1; ...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long LL_INF = 0x3f3f3f3f3f3f3f3f; const int maxn = 3e5 + 10; const int mod = 1e9 + 7; long long a[maxn]; int main() { long long n, m; scanf( %I64d%I64d , &n, &m); for (int i = 0; i < n; i++) { scanf( %I6...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 2015/03/31 15:48:05 // Design Name: // Module Name: wildcard_counter // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // ...
// megafunction wizard: %RAM: 1-PORT%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: RAMB16_S4_altera.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // =======...
#include <bits/stdc++.h> using namespace std; int main() { long long n, c = 0; cin >> n; for (long long i = 1; i < n; ++i) { if (n % i == 0) c++; } cout << c << endl; return 0; }
/** * This is written by Zhiyang Ong * and Andrew Mattheisen * for EE577b Troy WideWord Processor Project */ `timescale 1ns/10ps /** * `timescale time_unit base / precision base * * -Specifies the time units and precision for delays: * -time_unit is the amount of time a delay of 1 represents. * The time unit ...
#include <bits/stdc++.h> const int mod = 1000000007, maxn = 200005, maxk = 105; int n, m; int a[maxn], fac[maxn], nfac[maxn], inv[maxn], sum[maxn][maxk]; inline int C(int a, int b) { return 1ll * fac[a] * nfac[b] % mod * nfac[a - b] % mod; } int main() { fac[0] = fac[1] = nfac[0] = nfac[1] = inv[1] ...
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int testCase; cin >> testCase; while (testCase--) { vector<int> balls; int ball; cin >> ball; while (ball--) { int num; cin >> num; balls.push_back(num); } int maxNum ...
//------------------------------------------------------------------------ //-- //-- Filename : xlconcat.v //-- //-- Date : 06/05/12 //- //- Description : Verilog description of a concat block. This //- block does not use a core. //- //-----------------------------------------------...
#include <bits/stdc++.h> using namespace std; const long long N = 1e3 + 5; long long C[N][5], dif_fact[5]; void calc() { for (long long i = 0; i < N; i++) { for (long long j = 0; j <= min(i, 4LL); j++) { if (j == 0 || j == i) { C[i][j] = 1; } else { C[i][j] = C[i - ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n, i = 0, j, k = 0, l = 0, m = 10e9, a = 0, b = 0, c, sum = 0, x = 0, y = 0, z = 0; cin >> n; long long arr[n + 1]; for (i = 1; i <= n; i...
//----------------------------------------------------------------------------- // // (c) Copyright 2012-2012 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 ...
//----------------------------------------------------- // Design Name : parallel_crc_ccitt // File Name : parallel_crc.v // Function : CCITT Parallel CRC // Coder : Deepak Kumar Tala //----------------------------------------------------- module parallel_crc_ccitt ( clk , reset , enable , init , ...
#include <bits/stdc++.h> using namespace std; bool light[123456]; vector<int> v[123456]; bool visited[123456]; int connected[123456]; int main() { int n; cin >> n; string s, t; vector<string> rat, man, woman, child, capt; for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n)); ...
#include <bits/stdc++.h> using namespace std; using ll = long long; ll c[10]; int dx[] = {1, 0, -1, -1, 0, 1}; int dy[] = {1, 1, 0, -1, -1, 0}; int main() { int t; cin >> t; while (t--) { ll x, y; cin >> x >> y; for (int i = 0; i < 6; ++i) cin >> c[i]; long long ans = 5e1...
// file: system_clk_wiz_0_0.v // // (c) Copyright 2008 - 2013 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> const long long mod = 1000000007; const long long Inf = 1e9; using namespace std; bool valid(string s) { for (int i = 0; i < s.length(); ++i) { if (s[i] == || s[i] == # ) { if (s[i] == # ) return true; } else return false; } return false; ...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } const int MAXLEN = 15; long long dp[MAXLEN + 1][2]; long long dpleq[MAXLEN + 1][2]; inline int conv(char c) { if (isdigit(c)) return c - 0 ; if (islower(c)) return c - a + ...
// DESCRIPTION: Verilator: Verilog Test module // // Copyright 2021 by Geza Lore. This program is free software; you can // redistribute it and/or modify it under the terms of either the GNU // Lesser General Public License Version 3 or the Perl Artistic License // Version 2.0. // SPDX-License-Identifier: LGPL-3.0-only...
#include <bits/stdc++.h> using namespace std; const double PI = 3.141592653589793238460; using namespace std; const int N = 200200; vector<int> g[N]; int w[N], vis[N], done[N]; int can_back[N]; int n, m, s; long long maximum = 0; void dfs(int u, int par) { vis[u] = 1; for (auto v : g[u]) { ...