text stringlengths 59 71.4k |
|---|
/**
* 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 nC2(int n) { if (n == 0) return 0; return ((long long)n * (n - 1)) / 2; } void solve() { int n, m; scanf( %d %d , &n, &m); long long Kmin, Kmax; int r = n % m; Kmin = nC2((n + m - 1) / m) * r + nC2(n / m) * (m - r); Kmax = n... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; template <class c> struct rge { c b, e; }; template <class c> rge<c> range(c i, c j) { return rge<c>{i, j}; } template <class c> auto dud(c* x) -> decltype(cerr << *x, 0); template <class c> char dud(...); struct ... |
/**
* 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 arbitrator(
//input
reset,
clk,
request0,
release0,
request1,
release1,
request2,
release2,
request3,
release3,
request4,
release4,
request5,
release5,
//output
permit0,
permit1,
permit2,
permit3,
permit4,
permit5
//state
);
input reset;
input clk;
input request0;
input re... |
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> inline T1 max(T1 a, T2 b) { return a < b ? b : a; } template <typename T1, typename T2> inline T1 min(T1 a, T2 b) { return a < b ? a : b; } const char lf = n ; namespace ae86 { const int bufl = 1 << 15; cha... |
#include <bits/stdc++.h> using namespace std; int n, m, k; vector<vector<int> > v; bool transponer; void escribe() { if (transponer) { vector<vector<int> > nextv(m + 2, vector<int>(n + 2, 0)); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) nextv[j][i] = v[i][j]; swap(n... |
////////////////////////////////////////////////////////////////////////////////
//
// MIT License
//
// Copyright (c) 2017 Smartfox Data Solutions Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// ... |
#include <bits/stdc++.h> using namespace std; int n, mm, s, it; int a[200005], r[200005], so[200005], ne[200005]; bool u[200005]; string ss, na[200005]; vector<int> v[200005]; queue<int> q; map<string, int> m; inline string sb(string v) { for (int i = 0; i < v.size(); i++) if (v[i] < a ) v[... |
#include <bits/stdc++.h> using namespace std; const long long MAX = 2e5 + 10; int n; string s, xx = RGB ; int getID(char c) { if (c == R ) return 1; else if (c == G ) return 2; return 3; } int last[4]; int dp[MAX][4][4][4]; int mn = 1e9; vector<char> v, ans; int tokyoGho... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e3 + 5; int n, a[maxn], belong[maxn], bn = 1; int ans[maxn][maxn]; struct node { int l, r; } block[maxn]; bool cmp(node x, node y) { return (x.r - x.l) > (y.r - y.l); } int main() { int l, r, flag; cin >> n; for (int i = 1; ... |
#include <bits/stdc++.h> using namespace std; const int size_c = 26; const int Maxn = 500010 << 1; string s[100020]; int w[100020]; int n; struct Suffix_Automaton { int ch[Maxn][size_c]; int f[Maxn]; int ml[Maxn]; int sz, head, tail; long long val[Maxn]; int cnt[Maxn], id[Maxn]; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int arr[n + 1]; for (int i = 1; i <= n; i++) cin >> arr[i]; int x; cin >> x; int w, l; while (x--) { cin >> w >> l; if (w == 1) { arr[2] += arr[1] - l; arr[1] = 0; continue... |
/////////////////////////////////////////////////////////////////////
//// ////
//// Non-restoring signed by unsigned divider ////
//// Uses the non-restoring unsigned by unsigned divider ////
//// ... |
#include <bits/stdc++.h> using namespace std; const int N = 300000; int parent[N], size[N]; vector<pair<int, pair<int, int>>> v; pair<int, int> q[N]; long long ans[N]; int Find(int a) { if (parent[a] == a) return a; return parent[a] = Find(parent[a]); } void Union(int a, int b) { parent[Find(b... |
#include <bits/stdc++.h> using namespace std; int a[41][1001][1001]; int bir(int n) { int s = 0; while (n > 0) { s += n % 2; n /= 2; } return s; } bool fun(int x, int i) { if (i < 0) return 0; return ((x >> i) & 1); } bool funk(int a, int b, int c, int m) { for (int... |
/**
* 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... |
`define Seq_NO 4'h0
`define Seq_CI 4'h1
`define Seq_CR 4'h2
`define Seq_JI 4'h3
`define Seq_JR 4'h4
`define Seq_JZ 4'h5
`define Seq_JN 4'h6
`define Seq_WZ 4'h7
`define Seq_WN 4'h8
`define Seq_State_Reset 3'h0
`define Seq_State_Ready 3'h1
`define Seq_State_WaitZ 3'h2
`define Seq_State_WaitN 3'h3
`define Seq_State_Error... |
/**
* 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 = 1e5 + 5; int n, a[N], fa[N], head[N], p, deep[N]; long long Chuan1[N], Chuan2[N], Ans; queue<int> q; struct wfh { int to, last; } d[N << 1]; inline void add(int a, int b) { d[++p] = (wfh){b, head[a]}, head[a] = p; } inline long long max(l... |
// (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... |
// DM9000A.v
// This file was auto-generated as part of a SOPC Builder generate operation.
// If you edit it your changes will probably be lost.
`timescale 1 ps / 1 ps
module DM9000A (
input wire iCLK, // clk.clk
input wire iOSC_50, // avalon_slave_0_export.export
... |
/*******************************************************************************
* 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 ... |
/*
* These source files contain a hardware description of a network
* automatically generated by CONNECT (CONfigurable NEtwork Creation Tool).
*
* This product includes a hardware design developed by Carnegie Mellon
* University.
*
* Copyright (c) 2012 by Michael K. Papamichael, Carnegie Mellon University
*
* ... |
// MBT 11/9/2014
//
// Synchronous 1-port ram.
// Only one read or one write may be done per cycle.
`define bsg_mem_1rw_sync_mask_write_bit_macro(bits,words) \
if (els_p == words && width_p == bits) \
begin: macro \
saed90_``bits``x``words``_1P_bit mem \
(.CE1 (clk... |
module master(
input wire [6:0] address,
input wire [7:0] register,
input wire refresh_clk,
input wire sys_clk,
input wire mode,
input wire en,
input wire reset,
input wire Start,
input wire Stop,
input wire repeat_start,
output reg [7:0] out,
output reg ack,
inout wire sda,
inout wire scl
... |
#include <bits/stdc++.h> using namespace std; long long int mod; long long int power(long long int a, long long int b) { if (b == 0) return 1; if (b % 2 == 1) return (power(a, b - 1) * a) % mod; long long int q = power(a, b / 2); return (q * q) % mod; } int32_t main() { ios_base::sync_with... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100 + 10; char s[maxn]; int f(char ch) { if (ch == A ) return 1; if (ch == B ) return 2; if (ch == C ) return 4; return 0; } int main() { scanf( %s , s + 1); int l = strlen(s + 1); for (int i = 1; i <= l - 2; ++i) ... |
// Copyright 1986-2018 Xilinx, Inc. All Rights Reserved.
// --------------------------------------------------------------------------------
// Tool Version: Vivado v.2018.2 (win64) Build Thu Jun 14 20:03:12 MDT 2018
// Date : Tue Sep 17 19:44:40 2019
// Host : varun-laptop running 64-bit Service Pac... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, i, j, sum = 0, x, y, b; cin >> n >> m; int a[n][m]; vector<pair<int, int>> v; for (i = 0; i < n; i++) { for (j = 0; j < m; j++) { cin >> a[i][j]; sum += a[i][j]; if (a[i][j] == 0) v.push_back(make_... |
#include <bits/stdc++.h> using namespace std; char s[200000], t[200000]; int equi(int a, int b, int c, int d) { bool x = 1; for (int i = 0; i <= b - a; i++) { x &= (s[i + a] == t[i + c]); } if (x) return 1; if (b <= a) return 0; int n = b - a + 1; if (n % 2 == 1) return 0; if... |
#include <bits/stdc++.h> using namespace std; const long long int N = 1e5 + 5; map<long long int, long long int> m; long long int n, ans; void init() { m[-1] = -1; m[2e9] = 2e9; m[1] = n; ans = n; } void add(long long int l, long long int r) { m[l] = r; ans += r - l + 1; } void... |
/**
* 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... |
// megafunction wizard: %FIFO%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: dcfifo
// ============================================================
// File Name: tx_fifo.v
// Megafunction Name(s):
// dcfifo
//
// Simulation Library Files(s):
// altera_mf
// ===================================... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100000; int a, b, m, n, C[MAXN], I[MAXN]; queue<int> Q; vector<int> A, B, E[MAXN]; int main() { cin >> n >> m; while (m--) { cin >> a >> b; --a; --b; E[a].push_back(b); E[b].push_back(a); I[a] = I[b] =... |
#include <bits/stdc++.h> using namespace std; int solve(int i, int a, int b, int c) { if (i == 0) return a + b + c; if (i == 1) return max((a + b) * c, a + b * c); if (i == 2) return max(a * (b + c), a * b + c); return a * b * c; } int main() { ios::sync_with_stdio(0); cin.tie(0); in... |
// ========== Copyright Header Begin ==========================================
//
// OpenSPARC T1 Processor File: pcx_dp_macc_l.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 and... |
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long n; cin >> n; long long a[n], b[n]; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) cin >> b[i]; long long flag = 0, p = 0, ne = 0; if (... |
#include <bits/stdc++.h> using namespace std; const int inf = (1 << 30); const int N = 100005; int n, k; int g[105][105]; int main() { int i, j, t, cas = 0; memset(g, 0, sizeof(g)); scanf( %d , &k); for (n = 3; n <= 100; n++) { if ((n) * (n - 1) * (n - 2) / 6 > k) break; } n--;... |
/**
* 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: 17:00:08 11/01/2013
// Design Name: divider
// Module Name: C:/Users/Fabian/Documents/GitHub/taller-diseno-digital/Proyecto Final/proyecto-final/divider_test.v
// Pro... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 3e5 + 10; long long ans[MAXN]; int vis[MAXN], in[MAXN], worst[MAXN]; vector<int> adj[MAXN], idx[MAXN], path; vector<pair<int, int> > bad, qs[MAXN]; struct BIT { long long b[MAXN]; BIT() { fill(b, b + MAXN, 0); } void upd(int p, lon... |
// Copyright (c) 2014 Takashi Toyoshima <>.
// All rights reserved. Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
`timescale 100ps/100ps
module ParityTest;
wire w_parity_e1;
wire w_parity_e8;
wire w_parity_o1;
wire w_parity_o8;
... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; signed main() { long long n, sum = 0, temp; multiset<long long> a; cin >> n; for (long long i = 0; i < n; ++i) { cin >> temp; a.insert(temp); } while (a.size() > 1) { long long temp_sum = 0, sz = a.... |
module fifo(datain, rd, wr, rst, clk, full, empty,led_n,wei);
input [3:0] datain;
input rd, wr, rst, clk;
output [6:0] led_n;
output full, empty, wei;
reg [3:0] dataout;
reg full_in, empty_in,wei_in,div;
reg [3:0] mem [15:0];
reg [23:0]cnt;
reg [3:0] rp, wp;
reg [6:0] led_n;
assign full = full_in;
assign empty = em... |
#include <bits/stdc++.h> using namespace std; #define S size() #define EN end() #define BE begin() #define LEN length() #define endl n #define cnt count #define in insert #define er erase #define fi first #define se second #define ld double #define int long long #define gcd __gcd... |
#include <bits/stdc++.h> using namespace std; char s[100010], s1[100010], s2[100010], s3[100010], s11[100010]; int main() { scanf( %s , &s); int len; len = strlen(s); int sum = 0, a = 0; for (int i = 0; i < len; i++) { sum += s[i] - 0 ; if (s[i] == 0 ) a = 1; } if (sum % ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:40000000 ) using namespace std; const double EPS = 1e-10; const double PI = acos(-1.0); const int mod = 1000000007; const int MAXN = 200 * 200; int a[111]; int n; int main() { cin >> n; bool p = 1; for (int(i) = (0); (i) < (n); ++(i)... |
#include <bits/stdc++.h> using namespace std; const int N = 100010, C = 1000000000; int n, num; int kd[N], t[N], x[N], fr[N], nxt[N], ans[N]; map<int, int> S; int lc[N * 40], rc[N * 40], s[N * 40]; void change(int &i, int l, int r, int k, int d) { if (i == 0) i = ++num; s[i] += d; if (l == r) ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; char r[100]; if (s.length() < 6) { cout << no << endl; return 0; } int val = 0; for (int i = s.length() - 1; i >= 0; i--) { if (val == 6) { if (s[i] == 1 ) { cout << yes... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer: Jafet Chaves Barrantes
//
// Create Date: 22:16:58 05/10/2016
// Design Name:
// Module Name: receptor_teclado_ps2
// Project Name:
// Target Devices:
// Tool versions:
// Descr... |
#include <bits/stdc++.h> using namespace std; long long power(long long a, long long b) { long long res = 1; a = a % 1000000007; while (b > 0) { if (b & 1) { res = (res * a) % 1000000007; b--; } a = (a * a) % 1000000007; b >>= 1; } return res; } long l... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& _p) { return os << ( << _p.first << , << _p.second << ) ; } template <typename T> ostream& operator<<(ostream& os, const vector<T>& _V) { bool f = true; os << ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1 << 20; int bio[MAX]; vector<int> V[MAX]; int a[MAX], b[MAX]; int deg[MAX]; void dfs(int x) { if (bio[x]++) return; for (auto it : V[x]) dfs(it); } int main() { int n, m; scanf( %d%d , &n, &m); int usebe = 0; for (i... |
//////////////////////////////////////////////////////////////////////
//// ////
//// uart_debug_if.v ////
//// ////
//// ... |
// Copyright (C) 2013 Simon Que
//
// This file is part of DuinoCube.
//
// DuinoCube is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later ... |
`timescale 1 ns / 100 ps
`include "sm_cpu.vh"
`ifndef SIMULATION_CYCLES
`define SIMULATION_CYCLES 120
`endif
module sm_testbench;
// simulation options
parameter Tt = 20;
reg clk;
reg rst_n;
reg [ 4:0] regAddr;
wire [31:0] regData;
wire cpuClk;
// *... |
`timescale 1 ns / 1 ps
module axi_axis_writer #
(
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; struct P { int x, y; }; P me; P other; bool white; int N, M; P operator+(P a, P b) { return {a.x + b.x, a.y + b.y}; } P operator-(P a, P b) { return {a.x - b.x, a.y - b.y}; } bool operator==(P a, P b) { return a.x == b.x && a.y == b.y; } bool isItA... |
`timescale 1 ns / 1 ps
module led_controller_v1_0 #
(
// Users to add parameters here
// User parameters ends
// Do not modify the parameters beyond this line
// Parameters of Axi Slave Bus Interface S00_AXI
parameter integer C_S00_AXI_DATA_WIDTH = 32,
parameter integer C_S00_AXI_ADDR_WIDTH = 4
)
(... |
////////////////////////////////////////////////////////////////////////////////
// Project Name: CoCo3FPGA Version 3.0
// File Name: 6551tx.v
//
// CoCo3 in an FPGA
//
// Revision: 3.0 08/15/15
////////////////////////////////////////////////////////////////////////////////
//
// CPU section copyrighted by John Kent
... |
#include <bits/stdc++.h> using namespace std; struct tc { int cnt, count; long long p[5001]; } q[5001]; struct sc { int id; long long num; } anss[200010], s[200010]; void merge(int l, int mid, int r) { int i = l, j = mid + 1; int cc = l; while (i <= mid && j <= r) { if (ans... |
// Accellera Standard V2.5 Open Verification Library (OVL).
// Accellera Copyright (c) 2005-2010. All rights reserved.
parameter NC0 = (necessary_condition == `OVL_TRIGGER_ON_MOST_PIPE);
parameter NC1 = (necessary_condition == `OVL_TRIGGER_ON_FIRST_PIPE);
parameter NC2 = (necessary_condition == `OVL_TRIGGER_ON_F... |
#include <bits/stdc++.h> using namespace std; unsigned long long int MOD = 1000000007; unsigned long long int B = 13331; bool cmp(const int &a, const int &b) { return a < b; } int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } int lcm(int a, int b) { return a * (b / gcd(a, b)); } double func(dou... |
#include <bits/stdc++.h> using namespace std; struct info { long long int val, in; }; long long int arr[100010]; info tree[100010 * 4], temp; void init(long long int node, long long int b, long long int e) { if (b == e) { tree[node].val = arr[b]; tree[node].in = b; return; } ... |
#include <bits/stdc++.h> using namespace std; pair<int, int> a[2 * (int)(1e5 + 51)], b[2 * (int)(1e5 + 51)]; bool visited[2 * (int)(1e5 + 51)]; vector<int> g[2 * (int)(1e5 + 51)]; void dfs(int x) { visited[x] = 1; for (auto v : g[x]) { if (!visited[v]) dfs(v); } } int main() { ios_ba... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; const double PI = acos(-1.0); const double E = exp(1.0); const int M = 200010; long long a[M]; long long ans[M][2]; int main() { int n, k, x; cin >> n >> k >> x; long long temp = 1; while (k--) temp *= x; ... |
///====================== TEMPLATE STARTS HERE =====================/// #include <bits/stdc++.h> using namespace std; #define endl n #define pb push_back #define MP make_pair #define ff first #define ss second #define ABS(x) ((x)<0?-(x):(x)) #define FABS(x) ((x)+eps<0?-(x):(x)) #define LCM(x,y... |
//-----------------------------------------------------------------------------
//-- Divisor de frecuencia generico
//-- (c) BQ. August 2015. written by Juan Gonzalez (obijuan)
//-----------------------------------------------------------------------------
//-- GPL license
//--------------------------------------------... |
//////////////////////////////////////////////////////////////////////
//// ////
//// eth_fifo.v ////
//// ////
//// This file is part of the Ether... |
#include <bits/stdc++.h> using namespace std; pair<int, string> a[3005]; int h[3005]; vector<pair<string, int> > ans; int main() { int n, m; cin >> n; for (int i = 0; i < n; i++) cin >> a[i].second >> a[i].first; sort(a, a + n); for (int i = 0; i < n; i++) if (a[i].first > i) { ... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: Tecnológico de Costa Rica
// Engineer: Juan José Rojas Salazar
//
// Create Date: 30.07.2016 10:22:05
// Design Name:
// Module Name: FSM_Convert_Float_To_Fixed
// Project Name:
// Target Devices:
// ... |
//---------------------------------------------------------------------//
// Name: eval_node.v
// Author: Chris Wynnyk
// Date: 2/3/2008
// Purpose: Evaluates a single node in the Binomial Lattice.
//---------------------------------------------------------------------//
module eval_node(
clk,
nrst,
... |
`include "assert.vh"
`include "cpu.vh"
module cpu_tb();
reg clk = 0;
//
// ROM
//
localparam MEM_ADDR = 5;
localparam MEM_EXTRA = 4;
reg [ MEM_ADDR :0] mem_addr;
reg [ MEM_EXTRA-1:0] mem_extra;
reg [ MEM_ADDR :0] rom_lower_bound = 0;
reg [ MEM_ADDR :0] rom_upper_bo... |
#include <bits/stdc++.h> using namespace std; const int inf = 1e9; const int MOD = 1e9 + 7; const int N = 0; int a[5], m; long long sum(int len, int x) { return 1LL * len * x - 1LL * (x + 1) * x / 2 + x; } long long cal(int x, int y, int bar, int len) { if (len < 0) return 0; int R = min(bar... |
#include <bits/stdc++.h> using namespace std; int dp[26][26]; int main(void) { int n, i, j, a, b, l, ans = 0; char s[20]; memset(dp, 0, sizeof dp); scanf( %d , &n); for (i = 0; i < n; i++) { scanf( %s , s); l = strlen(s); a = s[0] - a ; b = s[l - 1] - a ; for (j... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 5e3 + 3; const int INF = 2000000000; inline long long ab(long long x) { return x < 0 ? -x : x; } long long a[MAXN]; int c_a[MAXN]; int l[MAXN], r[MAXN], x[MAXN], t[MAXN]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < ... |
#include <bits/stdc++.h> int n, m, i, j, k, l, a, b, c; char s[200][200]; bool bo; void fail() { bo = false; } bool work(int x, int y, int o, int p, int a, int b, int c) { int i, j; if (x > o) { return true; } if ((a < 0) || (b < 0) || (c < 0)) return false; if (x == o) { j = 0... |
#include <bits/stdc++.h> using namespace std; int main() { int TC; cin >> TC; while (TC--) { int p, f, cnts, cntw, s, w; cin >> p >> f >> cnts >> cntw >> s >> w; if (s < w) { swap(s, w); swap(cnts, cntw); } int maxi = 0; for (int i = 0; i <= min(p / w,... |
#include <bits/stdc++.h> using namespace std; int n; int main() { ios::sync_with_stdio(false); cin.tie(0); int test; cin >> test; while (test--) { cin >> n; vector<int> a; int mini = -1; int ii; for (ii = 2; ii * ii < n; ii++) { if (n % ii != 0) continue; ... |
#include <bits/stdc++.h> using namespace std; typedef struct { int freq; char l; } db; int comp(const void *a, const void *b) { db *x = (db *)a; db *y = (db *)b; return x->freq - y->freq; } int main() { db aa[30]; db e; string str; int let[30], sz, i, cnt, k, d, j; wh... |
//
// Copyright (c) 1999 Steven Wilson ()
//
// This source code is free software; you can redistribute it
// and/or modify it in source code form under the terms of the GNU
// General Public License as published by the Free Software
// Foundation; either version 2 of the License, or (at your option)
// ... |
#include <bits/stdc++.h> using namespace std; template <class _T> inline _T sqr(const _T& first) { return first * first; } template <class _T> inline string tostr(const _T& a) { ostringstream os( ); os << a; return os.str(); } const long double PI = 3.1415926535897932384626433832795L; ... |
//////////////////////////////////////////////////////////////////////
/// ////
/// Wishbone arbiter, burst-compatible ////
/// ////
/// Simple round-robin arbiter for ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, x = 0, y = 0; cin >> n >> m; x = max(m, n); for (int a = 0; a <= x; a++) { for (int b = 0; b <= x; b++) { if ((a * a) + b == n && (b * b) + a == m) { y++; } } } cout << y << endl; } ... |
#include <bits/stdc++.h> using namespace std; using namespace std; string best; void LongestPalindromicPrefix(string str) { string temp = str + ? ; reverse(str.begin(), str.end()); temp += str; int n = temp.length(); int lps[n]; fill(lps, lps + n, 0); for (int i = 1; i < n; i++) { ... |
`default_nettype none
`timescale 1ns / 1ps
`include "asserts.vh"
`include "xrs.vh"
module integration_tb();
reg [11:0] story_to;
reg fault_to;
reg clk_i, reset_i, inst_en_i;
reg [31:0] inst_i;
wire illegal_o;
wire [63:0] xrs_dec_rs1val, xrs_dec_rs2val;
wire [63:0] dec_ex_inpa, dec_ex_inpb;
wire dec_ex... |
#include <bits/stdc++.h> using namespace std; int main() { int n, t; scanf( %d%d , &n, &t); string s; cin >> s; string s1 = , s2 = ; bool ck = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == . ) ck = 1; else if (ck) s2 += s[i]; else s1 +... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1000006; int n, k; int main() { int i, j; cin >> n >> k; if (k > n) { printf( -1 ); return 0; } if (k == 1 && n == 1) { printf( a ); return 0; } if (k == 1 && n > 1) { puts( -1 ); retur... |
#include <bits/stdc++.h> using namespace std; const long long inf = (long long)(1e9 + 17); const long long mod = (long long)(1e9 + 7); int n, k; string s, t; int dp[201][201][201]; int recurse(int idx, int tot, int ct) { if (tot > k) { return -inf; } if (idx == n) { if (tot > k) re... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, h, v[1100]; multiset<long long> s; cin >> n >> h; for (int i = 0; i < n; i++) cin >> v[i]; long long k, ht; for (int i = 0; i < n; i++) { s.insert(v[i]); k = 0; ht = 0; for (multiset<long long>::r... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1010; int n, t, pop = -1, p[2 * MAX], para[2 * MAX], odw[2 * MAX]; inline void dodaj_pare(int a, int b) { para[a] = b; para[b] = a; } void wczytaj_dane() { int m; cin >> n >> m; for (int i = 0; i < (2 * n); i++) cin >> p[i]; ... |
//-----------------------------------------------------------------------------
//
// (c) Copyright 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009 Xilinx, Inc. All rights reserved.
//
// This file contains confidential and proprietary information
// of Xilinx, Inc. and is protected under U.S. and
// international copyr... |
`timescale 1ns / 1ps
/*
-- Module Name: FIFO control
-- Description: Unidad de control para FIFO. Implementa los punteros de
escritura/lectura para las operaciones PUSH y POP.
Esta implementacion no ofrece una señal para indicar que
el FIFO se encuentra vacio. existe la señal de buffer
vacio, simplem... |
// Model a simple flip flop with asynchronous reset
//
// Notes:
// - Including the reset signal in the sensitivity list is
// what makes the reset asynchronous
//
// - Most flip-flops have an asynchronous reset pin.
// This pin is inferred from the behavioral statement below.
//
// Advantages:
// - Asynchronous r... |
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 15:44:45 11/19/2015
// Design Name: MPU_controller
// Module Name: C:/Users/Camilo/Documents/Xilinx_Workspace/I2C_Module/controller_tst.v
// Project Name: I2C_Module... |
module RAM_TEST #(
parameter ADDR_WIDTH = 6,
parameter DATA_WIDTH = 1,
parameter IS_DUAL_PORT = 1,
parameter RANDOM_ITERATION_PER_LOOP = 10,
parameter LFSR_WIDTH = 16,
parameter LFSR_POLY = 16'hD008,
// How much to increment the address to move 1 full data width.
parameter ADDRESS_STEP =... |
#include <bits/stdc++.h> using namespace std; int main() { long long int t, n, a, b, p, q, z, k; cin >> t; while (t--) { z = 0; k = 0; cin >> a >> b >> n; p = max(a, b); q = min(a, b); while (k <= n) { z++; k = q + p; q = p; p = k; ... |
#include <bits/stdc++.h> using namespace std; const string st = AHIMOTUVWXY ; string s; int main() { ios::sync_with_stdio(0); cin >> s; int n = s.size(); for (int i = 0; i <= n - 1; ++i) if (st.find(s[i], 0) == -1) { cout << NO ; return 0; } string s1 = s; r... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.