text
stringlengths
59
71.4k
// DESCRIPTION: Verilator: Verilog Test module // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2008 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc=0; integer v; reg i; /*AUTOWIRE*/ // Beginning of automatic wires (for...
#include <bits/stdc++.h> using namespace std; int main() { int n, t; cin >> n; vector<int> v; for (int i = 0; i < n; i++) { cin >> t; v.push_back(t); } bool is = true; for (int i = 0; i < n; i++) { bool br = false; for (int j = 1000; j >= 1; j /= 10) { for...
#include <bits/stdc++.h> using namespace std; int N, L, K; string s; int cnt[26]; string res[1000]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> N >> L >> K; cin >> s; for (int i = 0; i < N * L; i++) cnt[s[i] - a ]++; int l = 0; int t = 0; while (l...
#include <bits/stdc++.h> using namespace std; map<int, int> s; int a[2000]; int main(int argc, char const *argv[]) { int n; cin >> n; for (int i = 0; i < n; ++i) cin >> a[i]; for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { int sum = a[i] + a[j]; if (s.find(s...
/** * 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 a[20007]; int main() { ios_base::sync_with_stdio(0); int t = 1; while (t--) { int n; cin >> n; map<int, int> mp; for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; mp[x] = y; if (mp[x] == -1 *...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Wed Dec 14 22:35:39 MST 2016 // Date : Wed Mar 01 09:54:25 2017 // Host : GILAMONSTER running 64-bit major release (...
#include <bits/stdc++.h> using namespace std; long long best; int n, m, k; int main() { cin >> n >> m >> k; if (k > n + m - 2) cout << -1 << endl; else { for (int area = 1; area <= (int)sqrt(n); area++) { int x = n / area; if (n / x == area) { int cut = min(k, x...
//altiobuf_out CBX_AUTO_BLACKBOX="ALL" CBX_SINGLE_OUTPUT_FILE="ON" DEVICE_FAMILY="Cyclone V" ENABLE_BUS_HOLD="FALSE" NUMBER_OF_CHANNELS=1 OPEN_DRAIN_OUTPUT="FALSE" PSEUDO_DIFFERENTIAL_MODE="TRUE" USE_DIFFERENTIAL_MODE="TRUE" USE_OE="FALSE" USE_OUT_DYNAMIC_DELAY_CHAIN1="FALSE" USE_OUT_DYNAMIC_DELAY_CHAIN2="FALSE" USE_TE...
#include <bits/stdc++.h> typedef struct { int dollar; int cent; } money; money q[110]; int w[110]; int main() { int i, j, n, m, k = 0, l = 0; scanf( %d%d , &n, &m); for (i = 1; i <= n; i++) scanf( %d%d , &q[i].dollar, &q[i].cent); for (i = 1; i <= n; i++) { if (q[i].dollar < m ||...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
module sgpr_simx_wr_port_mux ( wr_port_select, port0_wr_en, port0_wr_addr, port0_wr_data, port0_wr_mask, port1_wr_en, port1_wr_addr, port1_wr_data, port1_wr_mask, port2_wr_en, port2_wr_addr, port2_wr_data, port2_wr_mask, port3_wr_en, port3_wr_addr, port3_wr_data, port3_wr_mask, ...
/** * 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...
// $Header: /devl/xcs/repo/env/Databases/CAEInterfaces/verunilibs/data/virtex4/BUFIO.v,v 1.4 2007/06/01 22:41:59 yanx Exp $ /////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2004 Xilinx, Inc. // All Right Reserved. /////////////////////////////////////////////////////...
#include <bits/stdc++.h> using namespace std; void bogo(vector<int>& a) { for (int i = 0; i < a.size() - 1; i++) { int biggest = i; for (int j = i + 1; j < a.size(); j++) if (a[biggest] < a[j]) biggest = j; if (biggest != i) swap(a[i], a[biggest]); } } int main(int argc, char**...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int maxn = 1e5 + 5; long long qpow(long long a, long long b, long long r) { long long ans = 1, buff = a % r; while (b) { if (b & 1) ans = (ans * buff) % r; buff = (buff * buff) % r; b >>= 1; } return a...
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // a...
#include <bits/stdc++.h> using namespace std; int f(long long p) { int ans = 0; while (p) { ans += p % 10; p /= 10; } return ans; } long long g(long long a) { if (a == 0) return 0; int digit = 0; long long b = a; while (b >= 10) { digit++; b /= 10; } ...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; long long n, q, op, root = 1; long long a[maxn]; long long head[maxn], to[maxn << 1], nxt[maxn << 1], cnt; inline void add(long long u, long long v) { nxt[++cnt] = head[u]; to[cnt] = v; head[u] = cnt; } namespace Tree_ch...
#include <bits/stdc++.h> using namespace std; int main(void) { int t; cin >> t; while (t--) { long long n, p, k; cin >> n >> p >> k; long long ans = 0, pre = 0; vector<long long> a(n, -1); for (long long i = 0; i < n; ++i) { cin >> a[i]; } sort(a.begin()...
module LED (input clk, input enable, input [3:0] val, input [2:0] sidx, output reg[7:0] digit, output reg[7:0] segment); always @(posedge clk) begin if (enable) begin case (sidx) 3'd0: begin digit <= 8'b11111110; end 3'd1: begin digit <= 8'b11111101; end 3'd2: begin digit <= 8'b11111011; end 3'd3: begin di...
/** * 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; inline long long min2(long long a, long long b) { return (a) < (b) ? (a) : (b); } inline long long max2(long long a, long long b) { return (a) > (b) ? (a) : (b); } inline long long max3(long long a, long long b, long long c) { return (a) > (b) ? ((a)...
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-7; const double PI = acos(-1.0); const double ZERO = 0; const double DOUBLE_MAX = 1 / ZERO; int main() { long double t, s, q; cin >> t >> s >> q; long double speed = (q - 1) / q; long double x = 0, d; int res = 0; wh...
/** * 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 n; int main() { cin >> n; long long int cnt = 0, c; for (long long int i = 2; i <= sqrt(n); i++) { if (n % i == 0) cnt++; } if (cnt == 0) { cout << n; goto skip; } for (long long int i = 2; i <= sqrt(n); i++)...
#include <bits/stdc++.h> using namespace std; int n, k, c[100005], visit[100005], tp = 0; vector<int> a[100005], ans; bool ok[100005]; void dfs(int u) { visit[u] = tp; for (int i = 0; i < a[u].size(); i++) { int v = a[u][i]; if (ok[v]) continue; if (visit[v] == tp) { cout << ...
/** * 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; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long t; cin >> t; while (t--) { long long a, b, c, i, j; cin >> a >> b >> c; string f, s, third; if (a) { s = string(a + 1, 0 ); ...
#include <bits/stdc++.h> using namespace std; int t; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> t; while (t--) { string s; cin >> s; s = 0 + s; s = s + 0 ; for (int i = 1; i <= s.size(); i++) { if (s[i] == ? ) { if (s[i - 1] ==...
/** * 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...
module alu_chkr(clk, reset_n, opcode_valid, opcode, data, result, overflow, done, checker_enable); parameter DATA_WIDTH = 8; input clk; input reset_n; input opcode_valid; input opcode; input [DATA_WIDTH-1:0] data; input result; input overflow; input done; input [4:0] checker_enable; reg [DATA_WIDTH:0] ...
#include <bits/stdc++.h> using namespace std; const int INF = INT_MAX; const long long INFL = LLONG_MAX; const long double pi = acos(-1); int N, M; string s[100]; long long d[1 << 20]; long double f[1 << 20]; int main() { ios_base::sync_with_stdio(0); cout.precision(15); cout << fixed; ...
#include <bits/stdc++.h> #pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( O3 ) using namespace std; const double eps = 1e-9; const double pi = acos(-1.0); const int inf = 2e5 + 10; int mod = 1e9 + 7; const int MAXN = 1e5 + 7; long double C(int n, int k) { long double res = 1.; ...
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << : << arg1 << n ; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, , ); ...
#include <bits/stdc++.h> using namespace std; long long cum[(int)1e6], input[(int)1e6], k, ans; char c; int sz, t; map<long long, vector<int>> pos; int main() { cin >> sz >> k; for (int i = 0; i < sz; i++) { scanf( %c%d , &c, &t); input[i] = t; if (i == 0) { cum[0] = t; ...
#include <bits/stdc++.h> const long long int mod = 1e9 + 7; using namespace std; bool prime(long long int n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (long long int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) r...
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 7; bool IsPowerOfTwo(long long int x) { return (x != 0) && ((x & (x - 1)) == 0); } long long int poer(long long int a, long long int b) { long long int rs = 1; while (b > 0) { if (b & 1) rs *= a; a *= a; b /=...
#include <bits/stdc++.h> using namespace std; const int mx = 2e5 + 10; const int mxb = 60; long long int a[mx], b[mx], c[mx]; int cnt[mxb][2]; int bat(int idx, long long int v) { if (v & (1ll << idx)) return 1; return 0; } int main() { int n; scanf( %d , &n); long long int sm = 0; ...
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a; if (a == 1) { cout << 1 ; return 0; } if (a == 2) { cout << 13 ; return 0; } long long sol = 1; sol += 1LL * 6 * a * (a + 1) / 2; sol += 1LL * 6 * ((a - 2) * (a - 1) / 2 - 1);...
/* * 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; string s; cin >> s; bool neg = false; for (int i = 1; i <= n / 4 && !neg; i++) { for (int k = 0; k <= n - 1 - 4 * i; k++) if (s[k] == * && s[k + i] == * && s[k + 2 * i] == * && s[k + 3...
module enc(rst_n, freq_clk, enable, pha, phb, home, index, led); input rst_n; input freq_clk; input enable; output pha; output phb; output home; output index; output led; reg pha_reg; reg phb_reg; reg home_reg; reg index_reg; reg[7:0] pha_count; //debug led reg led; // generate 100 Hz from 50 MHz reg [31:0] count_...
#include <bits/stdc++.h> using namespace std; string a[100]; int id[30]; vector<int> cn[30]; int main() { int n; scanf( %d , &n); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 1; i < n; i++) { char l1 = - ; char l2 = - ; int j = -1; int s = a[i - 1].size(); ...
/** * 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 "core.h" `default_nettype none module execute_forwarding( input wire iCLOCK, input wire inRESET, input wire iRESET_SYNC, //Writeback - General Register input wire iWB_GR_VALID, input wire [31:0] iWB_GR_DATA, input wire [4:0] iWB_GR_DEST, input wire iWB_GR_DEST_SYSREG, //Writeback - Stack Po...
/* * Milkymist SoC * Copyright (C) 2007, 2008, 2009 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 distributed in ...
/***************************************************************************** * File : processing_system7_bfm_v2_0_5_intr_rd_mem.v * * Date : 2012-11 * * Description : Mimics interconnect for Reads between AFI and DDRC/OCM * *****************************************************************************/ `timesc...
#include <bits/stdc++.h> using namespace std; int main() { long long b, deocoai, g, n, p, q, i, a[300], t, tong, z, a1, a2, k2, k1; cin >> b >> g >> n; if (min(b, g) >= n) { cout << n + 1; return 0; } if (max(b, g) >= n && min(b, g) <= n) { cout << min(b, g) + 1; 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 law...
#include <bits/stdc++.h> using namespace std; const int M = 1e6 + 10; struct node { int l, r, sum, mus; } tr[M]; int n, a[M], now[M], sz[M], place[M], q, p; vector<int> g[M]; void maket(int l, int r, int t) { tr[t].l = l; tr[t].r = r; if (l == r) { tr[t].sum += now[a[l]]; retur...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int i = k - 1; while (n % i != 0) { i--; } cout << n / i * k + i << endl; }
/* * 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 i, j, n, m, flag = 0, cnt = 0, temp; cin >> n >> m; char a[108][106]; for (i = 0; i < n; i++) { cin >> a[i]; } for (i = 0; i < n; i++) { for (j = 0; j < m; j++) { cnt = 0; if (a[i][j] == . ) { ...
#include <bits/stdc++.h> using namespace std; void solve() { long long x, y, ans; cin >> x >> y; ans = (x / 2) * y; if (x % 2) ans += y / 2; cout << ans; } int32_t main() { ios_base::sync_with_stdio(false); long long t = 1; while (t--) { solve(); } return 0; }
//Verilint 182 off // WARNING: Illegal statement for synthesis: $realtobits (in1) //Verilint 311 off // WARNING: Converting real to unsigned: $realtobits (in1) //Verilint 20 off // WARNING: Assign statement may not be synthesizable: assign out7[i] = ...; //Verilint 599 off // WARNING: This construct is not supported b...
//============================================================= // // Copyright (c) 2017 Simon Southwell. All rights reserved. // // Date: 10th June 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 S...
#include <bits/stdc++.h> using namespace std; long long a[3]; int main() { scanf( %I64d%I64d%I64d , &a[0], &a[1], &a[2]); long long ans = a[0] + a[1] + a[2]; for (int i = 0; i <= 2; i++) { long long A = a[i], B = a[(i + 1) % 3]; if (((A - B) < 0 ? -(A - B) : (A - B)) & 1) continue; a...
// megafunction wizard: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: dcfifo // ============================================================ // File Name: afifo_32x256.v // Megafunction Name(s): // dcfifo // // Simulation Library Files(s): // altera_mf // ==========================================...
/****************************************************************************** * License Agreement * * * * Copyright (c) 1991-2012 Altera Corporation, San Jose, California, USA. * ...
#include <bits/stdc++.h> using namespace std; int M[17], R[17], n, sum; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> M[i]; for (int i = 1; i <= n; i++) cin >> R[i]; for (int i = 1; i <= 720719; i++) for (int j = 1; j <= n; j++) { if (i % M[j] == R[j]) { sum++;...
// Copyright (C) 2020-2021 The SymbiFlow Authors. // // Use of this source code is governed by a ISC-style // license that can be found in the LICENSE file or at // https://opensource.org/licenses/ISC // // SPDX-License-Identifier:ISC // Basic DFF module \$_DFF_P_ (D, C, Q); input D; input C; output Q; ...
/** * 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 = 100005; int a[N], n, i, k, j, c, p, b[N], m, r, t, check, mr; struct tree { int data = 0; int rank = 1; } * ROOT[N], *f[N]; vector<int> leafs; void push(tree*& node, int number) { tree* child = new tree(); child->data = number; ...
/* Copyright (c) 2015-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...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2022 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 `define checkh(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got='h%x exp='h%x\n", ...
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); cout.tie(0); iostream::sync_with_stdio(false); long long n, m; cin >> n >> m; set<int> taken_lines, taken_cols; long long base = n * n; for (int i = 0; i < m; ++i) { int x, y; cin >> x >> y; bool...
#include <bits/stdc++.h> using namespace std; const long long N = 1e6 + 10; const long long inf = 1e18; long long n; long long arr[20]; bool flag = false; void rec(long long i, long long s) { if (i == n + 1 && s % 360 == 0) flag = true; if (i > n) return; rec(i + 1, s + arr[i]); rec(i + 1,...
/** * 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...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2003 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 module t (/*AUTOARG*/ // Inputs clk ); input clk; // verilator lint_off BLKANDNBLK // 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...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 2016/06/07 13:20:30 // Design Name: // Module Name: _3bit_binary_multiplier_control_unit // Project Name: // Target Devices: // Tool Versions: // Description: // /...
#include <bits/stdc++.h> using namespace std; const int maxk = 101, maxn = 100000 + 10; long long n, k, a[maxk], dp[maxk][maxn]; long long f(int x, long long num) { if (num == 0) return 0; if (x == k + 1) return num; if (num < maxn && dp[x][num] != -1) return dp[x][num]; long long p = f(x + 1, n...
#define DEBUG 0 #include <bits/stdc++.h> using namespace std; #if DEBUG // basic debugging macros int __i__,__j__; #define printLine(l) for(__i__=0;__i__<l;__i__++){cout<< - ;}cout<<endl #define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl #define printVar(n) cout<<#n<< : <<n<...
// Copyright 1986-2014 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2014.3 (lin64) Build Fri Oct 3 16:31:15 MDT 2014 // Date : Sun Oct 25 15:43:51 2015 // Host : arthas-ubuntu running 64-bit Ubuntu 14.04.3...
`timescale 1ns / 1ps // //////////////////////////////////////////////////////////////////////////////// // Boot CPLD design, only for u2_rev2 // //////////////////////////////////////////////////////////////////////////////// module boot_cpld (input CLK_25MHZ, output CLK_25MHZ_EN, output [2:0] LED, output ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; template <typename T, typename T1> T amax(T& a, T1 b) { if (b > a) a = b; return a; } template <typename T, typename T1> T amin(T& a, T1 b) { if (b < a) a = b; return a; } const long long N = 200005, INF = 2000000000000000000; const long lo...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef unsigned int uint; typedef pair<int, int> pii; int n, k; char s[300005]; void solve() { while (~scanf( %d%d , &n, &k)) { memset(s, 0, sizeof(s)); s[n + 1] = 0 ;...
//Legal Notice: (C)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 do...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2011 Xilinx, Inc. // // 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 // //...
#include<bits/stdc++.h> using namespace std; const int N=10,M=405,mod=998244353; int n,m,k,t,v[M],id[M][M],ch[M][30],l[N]; char s[N][N]; struct mat{int a[M][M];}; mat operator*(mat x,mat y) { mat z; for(int i=1;i<=t;i++) { for(int j=1;j<=t;j++) { z.a[i][j]=0; for(int k=1;k<=t;k+...
#include <bits/stdc++.h> using namespace std; char s[10][10]; int t, i, j, o, x[2], y[2], ok; int main() { scanf( %d , &t); while (t--) { for (i = o = 0; i < 8; i++) { scanf( %s , s + i); for (j = 0; j < 8; j++) if (s[i][j] == K ) x[o] = i, y[o++] = j; } if (...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int a[n]; map<int, int> mp; for (int i = 0; i < n; i++) { cin >> a[i]; mp[a[i]]++; } int mx = 0, p = 0; for (auto it = mp.begin(); it...
///////////////////////////////////////////////////////////////////// //// //// //// Universal FIFO Dual Clock, gray encoded //// //// //// //// ...
// date:2016/2/19 11:00 done! // engineer:ZhaiShaoMin // module name:arbiter_4_enq // module function:decide which fifo should receive coming flit according to the head flit of msg // since arbiter dequeue has done most of the selction work , this part seems much easier! module arbiter_4_enq ( // input ...
#include <bits/stdc++.h> using namespace std; inline void read(int &x) { x = 0; char c = getchar(); int f = 1; while (!isdigit(c)) { if (c == - ) f = -1; c = getchar(); } while (isdigit(c)) { x = x * 10 + c - 0 ; c = getchar(); } x *= f; } const int N = ...
#include <bits/stdc++.h> using namespace std; void solve_problem() { int n; cin >> n; set<int> s; for (int i = 1; i * i <= n; ++i) { s.insert(i * i); } for (int i = 1; i * i * i <= n; ++i) { s.insert(i * i * i); } cout << s.size() << n ; } int32_t main() { ios_b...
#include <bits/stdc++.h> using namespace std; void move(char b[], int n, int i) { for (int j = i; j < n - 1; ++j) { b[j] = b[j + 1]; } } int main() { int a[10]; char b[101]; char d[101]; int c; int n, q, nd, nn; cin >> n >> q; for (int i = 0; i < n; ++i) { cin >> ...
/** * 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...
// UART Receiver: Exercise 2.4 `include "uart_params.v" module uart_rx( input wire clk, input wire rst, input wire din, output reg valid, output reg [7:0] data_in); reg [8:0] etu_cnt; reg [2:0] bit_cnt; reg [7:0] data; reg [1:0] state; reg starting; wire etu_full = (etu_cnt == `UART_FULL_E...
#include <bits/stdc++.h> using namespace std; int main() { int n, i; cin >> n; bool t[2 * n], s[2 * n]; char tmp; for (i = 0; i < 2 * n; i++) { cin >> tmp; t[i] = (tmp == 1 ); } for (i = 0; i < 2 * n; i++) { cin >> tmp; s[i] = (tmp == 1 ); } int t_sum = ...
/** * 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 double PI = acos(-1.0); const double eps = 1e-12; const int INF = (1 << 31) - 1; const long long LLINF = ((long long)1 << 62) - 1; const int maxn = 1000 * 100 + 10; int a[maxn], sum[maxn], sum2[maxn]; int main() { int n; scanf( %d , &n); fo...
//Legal Notice: (C)2018 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 do...
#include <bits/stdc++.h> using namespace std; long long even[222222] = {0}, a[222222], odd[222222] = {0}, backEven[222222], cur, best = numeric_limits<int>::min(), besteven = 0; int main() { int n; scanf( %d , &n); for (int i = 2; i <= n; i++) cin >> a[i]; even[1] = 0; odd[1] = 0; ...
module uartmm(input clk, input rst, input RX, output TX, output reg [31:0] data_b, output reg strobe_b, input [31:0] addr_b, input [31:0] data_b_in, ...
#include <bits/stdc++.h> using namespace std; long long n, m, w, r, k, i, j, s, q, x, y, l, a[22000]; int main() { ios_base::sync_with_stdio(0); cin >> n; for (i = 1; i <= n; i++) { cin >> a[i], s += a[i]; if (a[i] < 0) k = 1; } if (k == 0) { cout << s; return 0; } ...