text
stringlengths
59
71.4k
//Legal Notice: (C)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 do...
#include <bits/stdc++.h> using namespace std; long long min(long long x, long long y) { return (x < y) ? x : y; } long long max(long long x, long long y) { return (x > y) ? x : y; } const int N = 100009; int x, y, n, m, i, u, w, z, sum, best, j, k, t, mx; int a[N]; string s, ans; int main() { ios_ba...
// // 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 void gn(T &first) { char c, sg = 0; while (c = getchar(), (c > 9 || c < 0 ) && c != - ) ; for ((c == - ? sg = 1, c = getchar() : 0), first = 0; c >= 0 && c <= 9 ; c = getchar()) first = (first << 1) +...
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); long long pow(long long x, long long n) { long long res = 1; while (n) { if (n & 1) res = (res * x); x = (x * x); n >>= 1; } return res; } int32_t main() { i...
// Copyright 1986-2014 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2014.3.1 (lin64) Build Thu Oct 30 16:30:39 MDT 2014 // Date : Wed Apr 8 23:17:41 2015 // Host : parallella running 64-bit Ubuntu 14.04.2 ...
#include <bits/stdc++.h> using namespace std; int n, k, a, ok, ans, occ[10]; int main() { scanf( %d %d , &n, &k); for (int i = 0; i < n; i++) { scanf( %d , &a); int total = k + 1; memset(occ, 0, sizeof(occ)); while (a) { if (!occ[a % 10] && (a % 10 <= k)) { total-...
/** * 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 law...
`include "bch_defs.vh" module xilinx_error_tmec #( parameter T = 2, parameter DATA_BITS = 5, parameter BITS = 1, parameter REG_RATIO = 1, parameter PIPELINE_STAGES = 0, parameter ACCUM = 1 ) ( input clk_in, input in, output reg out = 0 ); `include "bch_params.vh" localparam TCQ = 1; localparam P = bch_par...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 19:39:57 03/02/2016 // Design Name: Ctr // Module Name: G:/ceshi/lab3c/test_for_Ctr.v // Project Name: lab3c // Target Device: // Tool versions: // D...
/** * 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: 16:30:25 05/05/2013 // Design Name: // Module Name: multplr // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // //...
#include <bits/stdc++.h> using namespace std; long long n, m; long long side[300001]; vector<long long> edges[300001]; bool vis[300001]; bool res = 1; map<long long, long long> mp; long long dfs(long long u, long long s) { vis[u] = 1; side[u] = s; ++mp[s]; long long ret = 1; for (lon...
/* * 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 1ns / 1ps //////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 06/23/2015 05:17:53 PM // Design Name: // Module Name: testcase_basic // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revis...
module ram_wb ( // Inputs wbm0_adr_i, wbm0_bte_i, wbm0_cti_i, wbm0_cyc_i, wbm0_dat_i, wbm0_sel_i, wbm0_stb_i, wbm0_we_i, // Outputs wbm0_ack_o, wbm0_err_o, wbm0_rty_o, wbm0_dat_o, // Inputs wbm1_adr_i, wbm1_bte_i, wbm1_cti_i, wbm1_cyc_i, wbm1_dat_i, wbm1_sel_i, wbm1_stb_i, wbm1_we_i, /...
/*********************************************************************** Array access test cases Copyright (C) 2001 Eric LaForest, Licenced under GPL ***********************************************************************/ module wire_test_case (array_out, clock, reset); output [15:0] array_out; input cloc...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; const int sieve_size = 5e6; void solve() { int n; cin >> n; vector<int> a(n); for (int &x : a) cin >> x; vector<int> primes; vector<bool> sieve(sieve_size); for (int i = 2; i < int((siev...
#include <bits/stdc++.h> using namespace std; int num[1005]; char num0[1005]; int res1[1005]; int N; int query() { int res = 0; for (int i = 0; i < N; i++) { if (num[i] != 0) { res *= 10; res += num[i]; } else if (num[i] == 0) { res *= 10; } } return...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; bitset<100015> A[4096]; int n, m, k, q, lp, S, a[12][100015], t[100015], x[100015], y[100015], p[100015]; int main() { int i, j, l; scanf( %d %d %d , &n, &k, &q); for (i = 0; i < k; i++) for (j = 1; j <= n; j++) scanf( %d , &a[i][j]); for...
#include <bits/stdc++.h> using namespace std; map<long long, long long> mp1, mp2; long long n, k; long long a[200001]; int main() { ios_base::sync_with_stdio(false); cin >> n >> k; long long res = 0; for (int i = 1; i <= n; ++i) cin >> a[i]; for (int i = n; i >= 1; --i) { res += mp1[...
/* * 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...
(************************************************************************) (* v * The Coq Proof Assistant / The Coq Development Team *) (* <O___,, * INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2014 *) (* \VV/ **************************************************************) (* // * Th...
#include <bits/stdc++.h> using namespace std; int main() { int t, s, x; scanf( %d%d%d , &t, &s, &x); if (x < t) { puts( NO ); return 0; } int temp = (x - t) % s; if (temp == 0 || temp == 1) { if (x == t + 1) puts( NO ); else puts( YES ); } else ...
#include <bits/stdc++.h> using namespace std; int add(int x, int y) { return ((x + y) % 998244353 + 998244353) % 998244353; } int mul(int x, int y) { return (long long)x * y % 998244353; } int mypow(int x, int c) { int ret = 1; while (c > 0) { if (c & 1) { ret = mul(ret, x); } ...
#include <bits/stdc++.h> using namespace std; int main() { string s1, s2; cin >> s1 >> s2; int flag = 0; for (int i = 0, j = s2.length() - 1; i < s1.length(), j >= 0; i++, j--) { if (s1[i] == s2[j]) { flag++; } } if (flag == s1.length()) cout << YES << endl; e...
/** * ------------------------------------------------------------ * Copyright (c) All rights reserved * SiLab, Institute of Physics, University of Bonn * ------------------------------------------------------------ */ `timescale 1ps/1ps `default_nettype none module fei4_rx #( parameter BASEADDR = 32'h0000,...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; string s[n + 1]; for (int i = 0; i < n; i++) { cin >> s[i]; } long long ans = 1; for (int i = 0; i < m; i++) { unordered_set<char> b; for (int j = 0; j < n; j++) { b.insert(s[j][...
#include <bits/stdc++.h> using namespace std; int solve() { long long n; cin >> n; vector<long long int> a, b; long long x; for (long long int i = 0; i < n; i++) { cin >> x; if (x > 0) a.push_back(x); else b.push_back(x); } long long sum1 = accumulate(a....
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; const int maxn = 700 + 7; const int MOD = 1e9 + 7; const int INF = 1e9 + 7; int a[maxn]; int g[maxn][maxn]; int n; struct as { int l, r, v; bool operator<(const as& b) const { if (l < b.l) return true; if (l > b.l) return false; if ...
module main; localparam BYTESIZE = 8; localparam STRLEN = 4; localparam [15:0] CHAR = "10"; function [STRLEN*BYTESIZE - 1 : 0] bits2text; input [STRLEN-1:0] use_map; integer idx; begin bits2text = 0; for (idx = 0 ; idx < STRLEN ; idx = idx+1) begin bits2text[(idx*BYTESIZE) +:...
module top(); localparam width_lp = 32; localparam debug_lp = 0; // These declarations export the functions from the leaf // modules. There may be a cleaner way to do this but I haven't // found it yet. logic ns_clk, ns_by2_clk, ns_reset, debug_o; parameter lc_cycle_time_p = ; bsg_nonsynt...
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; using ll = long long; using ull = unsigned long long; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n; int k; cin >> n >> k; ll s = n * (n - 1) / 2; s %= n; ll t = 0; ll cnt...
/** * 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; long long n, m, ans, x, i, j, s; double a[100], b[100]; map<double, pair<long long, long long> > mp; map<double, pair<long long, long long> >::iterator it, it2; long long num(long long x) { s = 0; while (x) { s++; x -= x & -x; } retur...
// file: Clock48MHZ.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 disclaime...
//wishbone_interconnect.v /* Distributed under the MIT licesnse. Copyright (c) 2011 Dave McCoy () 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 ...
//***************************************************************************** // DISCLAIMER OF LIABILITY // // This file contains proprietary and confidential information of // Xilinx, Inc. ("Xilinx"), that is distributed under a license // from Xilinx, and may be used, copied and/or disclosed only // pursuant to the...
`timescale 1ns / 1ps `default_nettype none ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: Miguel Angel Rodriguez Jodar // // Create Date: 03:34:47 07/25/2015 // Design Name: SAM Coupé clone // Module Name: ram // Project Name: SAM Coupé clone ...
// // Copyright (c) 2013 Colin Rothwell // Copyright (c) 2014 A. Theodore Markettos // All rights reserved. // // This software was developed by SRI International and the University of // Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237 // ("CTSRD"), as part of the DARPA CRASH research programme...
#include <bits/stdc++.h> using namespace std; int const INF = 100 + (int)1e9; long long const INFL = 100 + (long long)1e18; long double const PI = 3.141592653589793238462643L; mt19937 tw(960172); bool is_prime(long long x) { for (long long y = 2; y * y <= x; ++y) if (x % y == 0) return 0; retu...
/* * 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...
module deserializer( clk, //serialized data proper clock enable, //suspend while enable on low reset, //set output to zero and reset counter to 0 on high framesize, //number of bits to be deserialized - 1 in, //serialized data out, //deserialized data complete //reset counter to 0 and hold out's data 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...
//Copyright 1986-2017 Xilinx, Inc. All Rights Reserved. //-------------------------------------------------------------------------------- //Tool Version: Vivado v.2017.2 (win64) Build Thu Jun 15 18:39:09 MDT 2017 //Date : Tue Sep 19 00:28:00 2017 //Host : DarkCube running 64-bit major release (build 92...
#include <bits/stdc++.h> using namespace std; inline pair<int, int> best(pair<int, int> a, pair<int, int> b) { if ((a.first > b.first) || ((a.first == b.first) && (a.second < b.second))) return a; return b; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n...
#include<bits/stdc++.h> using namespace std; typedef pair<int,int> pii; typedef pair<string,int> psi; typedef pair<int,string> pis; typedef array<int,2> aii; typedef array<int,3> aiii; typedef array<int,4> aiiii; typedef unsigned long long ull; typedef long long int ll; typedef array<ll,2> all; ...
#include <bits/stdc++.h> using namespace std; bool within(int x1, int x2, int y1, int y2, int px, int py) { if (x1 <= px and px <= x2 and y1 <= py and py <= y2) { return true; } return false; } int main() { ios::sync_with_stdio(false); int y, x, v, n; cin >> y >> x >> v >> n; i...
#include <bits/stdc++.h> using namespace std; int ABS(int a) { if (a < 0) return (-a); return a; } void input() {} int n, table; int a[55]; double dp[55][55][55][55]; int aim; double f(int idx, int sum, int k, int cnt) { if (idx == n) { if (sum != aim || cnt == 0) return 0; ret...
#include <bits/stdc++.h> using namespace std; int n, m, q; std::vector<int> val(500005); std::map<int, pair<int, int> > edges; std::vector<pair<int, int> > query(500005); int vis[500005]; int par[500005]; set<pair<int, int> > ss[500005]; int sz[500005]; std::vector<pair<int, int> > changes[500005]; ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int x = 0, y = 0, dp = 0, tmp; int sum = 0; for (int i = 0; i < s.length(); i++) { if (s[i] == U ) { y++; if (x < y) { if (dp == 2) sum++; dp = 1; ...
/* qmem_decoder.v */ module qmem_decoder #( parameter QAW = 32, // address width parameter QDW = 32, // data width parameter QSW = QDW/8, // byte select width parameter SN = 2 // number of slaves )( // system input wire clk, input wire rst, // slave port for ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, i; cin >> n; string s; int ans = 0; cin >> s; for (i = 1; i < n; i++) { if (s[i] != s[0]) break; } if (i != n) { int c = 1; for (int j ...
// (C) 1992-2014 Altera Corporation. All rights reserved. // Your use of Altera Corporation's design tools, logic functions and other // software and tools, and its AMPP partner logic functions, and any output // files any of the foregoing (including device programming or simulati...
#include <bits/stdc++.h> using namespace std; inline int setBit(int N, int pos) { return N = N | (1 << pos); } inline int resetBit(int N, int pos) { return N = N & ~(1 << pos); } inline bool checkBit(int N, int pos) { return (bool)(N & (1 << pos)); } int main() { long long n, k, x, sum = 0; scanf( %ll...
#include <bits/stdc++.h> using namespace std; struct rec { int l, r; }; rec f[2222][2223]; bool can[2222][2223]; int n, m, k, x, y, xx, yy; void del(int x, int y) { can[x][y] = false; for (int i = 1; i <= m; i++) { f[x][i].l = f[x][i - 1].l; if (can[x][i - 1]) f[x][i].l = 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 law...
#include <bits/stdc++.h> using namespace std; const int MaxN = 1005; string a[MaxN], start[MaxN], finish[MaxN], st[MaxN], Fans[MaxN]; int n, m, ind, Find; int b[MaxN]; void check() { int flag = 0, flag1 = 0, i, j; ind = 0; for (i = 1; i <= n; i++) { if (b[i] == 1) { ind++; ...
module soc_system ( clk_clk, hps_0_f2h_sdram0_data_address, hps_0_f2h_sdram0_data_burstcount, hps_0_f2h_sdram0_data_waitrequest, hps_0_f2h_sdram0_data_readdata, hps_0_f2h_sdram0_data_readdatavalid, hps_0_f2h_sdram0_data_read, hps_0_f2h_sdram1_data_address, hps_0_f2h_sdram1_data_burstcount, hps_0_f2h_sdram1_d...
// Copyright (c) 2016 CERN // Maciej Suminski <> // // 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) // any late...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, k; int a[N]; void solve(int l, int r) { if (k <= 0) { return; } if (l == r - 1) { return; } int mid = (l + r) / 2; swap(a[mid - 1], a[mid]); --k; --k; solve(l, mid); solve(mid, r); ...
`define BigEndianCPU 1 module dm_4k (addr, din, byteExt, wEn, clk, dout); input [11:0] addr; input [31:0] din; input [1:0] byteExt; input [1:0] wEn; input clk; output reg [31:0] dout; reg [31:0] dm [1023:0];// 32-bit*1024; wire [1:0] byteSel; wire [9:0] gpAddr; reg [7:0] byteIn; reg [...
`include"axi2ocp.v" /* * AXI to OCP translation block test bench * Author: Michael Walton * * This module validates the AXI to OCP translation block */ module axi2ocp_tb(); // Declarations/*{{{*/ // axi2ocp hookups reg clk; reg reset; // AXI FIFO/*{{{*/ reg m_aclk; wire s_aclk; reg m_axis_tvalid; wire m_axis_tr...
#include <bits/stdc++.h> using namespace std; const long double pi = 3.14159265358979323; const double EPS = 1e-12; const int N = 1e6 + 5; const int MOD = 1e9 + 7; long long int n, m; long long int dp[2005][2005]; long long int ad(long long int a, long long int b) { return ((a % MOD + b % MOD) % MOD...
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; const int N = 1e5 + 5; void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } voi...
#include <bits/stdc++.h> using namespace std; void setIO(const string &name = ) { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); if (name.length()) { freopen((name + .in ).c_str(), r , stdin); freopen((name + .out ).c_str(), w , stdout); } } template <typ...
#include <bits/stdc++.h> using namespace std; const int MAX_N = 101; int a[MAX_N]; int n; vector<vector<int>> ans; pair<int, int> pop(multiset<pair<int, int>, std::greater<pair<int, int>>> &s) { pair<int, int> x = *s.begin(); s.erase(s.begin()); return x; } bool check(int d) { ans.clear(...
#include <bits/stdc++.h> using namespace std; int main() { int t, x = 0, k = 0; cin >> t; while (t--) { int m, n, x, y = 0; cin >> m; cin >> n; x = m * n; int a[x]; for (int i = 0; i < x; i++) { cin >> a[i]; if (a[i] < 0) { a[i] = 0 - a[i]; ...
// -- (c) Copyright 2009-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 p...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; int n, d[22]; int f[22], g[22], L[22], memF[22]; void moveG(int n, int a, int b, int c) { if (n == 0) return; moveG(n - L[n], a, c, b); for (int i = 0; i < L[n]; i++) printf( %d %d n , a, c); moveG(n - L[n], b, a, c); } void moveF(int n, int a, i...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9 + 7; const int N = 1e6 + 10; int main() { int n; cin >> n; map<int, int> mc; for (int i = 1; i <= n; i++) { int x; cin >> x; mc[x] = i; } pair<int, int> ans = {INF, INF}; for (auto &p : mc) { ...
#include <bits/stdc++.h> using namespace std; const int N = 501; int a[N][N], b[N][N]; void solve() { int n, m; cin >> n >> m; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> a[i][j]; } } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) {...
#include <bits/stdc++.h> using namespace std; template <typename TYPE> inline TYPE sqr(const TYPE& a) { return a * a; } const long double EPS = 1e-9; const long double PI = 2 * acos(0.0); const int N = 300010; int a[N]; int main() { int n; scanf( %d , &n); long long s = 0; for (int...
#include <bits/stdc++.h> using namespace std; struct event { int x, size, val, ent; bool operator<(const event& rhs) const { if (x == rhs.x) return ent < rhs.ent; return x < rhs.x; } }; int main() { ios_base::sync_with_stdio(false), cin.tie(0); int n, x; cin >> n >> x; ve...
#include <bits/stdc++.h> using namespace std; int a[50]; int main() { int f = 2, ct[110]; ct[0] = 0; ct[1] = 0; ct[2] = 1; for (int i = 3; i <= 101; i++) { ct[i] = ct[i - 1] + f; f++; } string s; int n, m; cin >> n; for (int i = 0; i < n; i++) { cin >> s; ...
#include <bits/stdc++.h> int x[1000], y[1000]; using namespace std; int main() { int n, counter = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> x[i] >> y[i]; if (x[i] != y[i]) { cout << rated ; return 0; } } for (int i = 0; i < n; i++) { if (x[i] < ...
#include <bits/stdc++.h> using namespace std; struct SuffixArray { char* T; int n; vector<int> RA, tempRA; vector<int> SA, tempSA, c; vector<int> phi, pLCP, LCP; SuffixArray(string& t) { n = t.length(); T = new char[n + n]; for (int i = 0; i < n; T[i] = t[i], i++) ;...
//move some stuff to minitests/ncy0 module top(input clk, stb, di, output do); localparam integer DIN_N = 256; localparam integer DOUT_N = 256; reg [DIN_N-1:0] din; wire [DOUT_N-1:0] dout; reg [DIN_N-1:0] din_shr; reg [DOUT_N-1:0] dout_shr; always @(posedge clk) begin din_shr <= {din_shr, di}; dout_shr <...
/* * Control Unit for simple 8-bit CPU. * Copyright (C) 2015, 16 John Tzonevrakis. * Licensed under the LGPL license. For more details, read the COPYING file. * */ module control (input clk, reset, interrupt, input [7:0] datamem_data, datamem_address, regfile_out1, input [7:0] regfile...
`timescale 1ns / 1ps `include "Defintions.v" module MiniAlu ( input wire Clock, input wire Reset, output wire [7:0] oLed ); wire [15:0] wIP,wIP_temp; reg rWriteEnable,rBranchTaken; wire [27:0] wInstruction,wInstruction_Pre; wire [3:0] wOperation,wOperationPost; reg signed [15:0] rResult; w...
#include <bits/stdc++.h> using namespace std; struct MaxFlow { int T; struct node { int to, nxt, cap; } ed[811 * 811 << 1]; int head[811], cur[811], cnt, ans; int h[811]; void addedge(int u, int v, int cap) { ed[cnt].to = v, ed[cnt].cap = cap, ed[cnt].nxt = head[u], head[u] = cnt...
#include <bits/stdc++.h> using namespace std; int main() { int n, f = 0; cin >> n; for (int i = 1; i < 50; i++) { if ((i * (i + 1)) / 2 == n) { f = 1; break; } if (i > n) break; } if (f) cout << YES << endl; else cout << NO << endl; retur...
#include <bits/stdc++.h> using namespace std; const int Maxn = 500005; int n; int a[Maxn]; long long L[Maxn], R[Maxn]; int delt[Maxn]; long long res; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); L[i] = L[i - 1] + a[i]; } if (L[n] % 3) ...
#include <bits/stdc++.h> int main() { int n, k; int h[1001] = {0}; scanf( %d%d , &n, &k); int i, j; for (i = 1; i <= n; i++) scanf( %d , &h[i]); int min = 9999999, nn = 1; for (i = 1; i <= n; i++) { if (h[i] < 1 + k * (i - 1)) continue; int ans = 0; for (j = 1; j <= n; j+...
#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 long double DINF = pow(2, 100); const int MAXN = 1007; const int MOD = static_cast<int>(1e9 + 7); const lo...
#include <bits/stdc++.h> using namespace std; const long long mx = 223456; long long n, a[mx], b[mx], sum1, sum2, ca, cb; int32_t main() { cin >> n; for (long long i = 0; i < n; i++) { cin >> a[i]; } for (long long i = 0; i < n; i++) { cin >> b[i]; } sort(a, a + n); sort(...
#include <bits/stdc++.h> using namespace std; int main() { int t , x , k; cin >> t; while(t--) { cin >> x; k = (int)(sqrt(8 * x + 1)) / 2; if((k * (k + 1) - 2 * x)!=2 && (k * (k + 1) - 2 * x) >= 0) cout << k << n ; ...
#include <bits/stdc++.h> struct node { int same, rev; } T[524288]; int N, Q, a[100001]; inline void down(int p) { if (T[p].same) { T[p << 1].same = T[p].same; T[p << 1 | 1].same = T[p].same; T[p << 1].rev = T[p << 1 | 1].rev = 0; T[p].same = 0; } else if (T[p].rev) { 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 law...
#include <bits/stdc++.h> using namespace std; bool found; int n, x, nums[1000], smaller, larger, eq; void Naive() { int median = ((n + 1) / 2); sort(nums, nums + n); if (nums[--median] == x) { printf( 0 ); return; } if (found) { for (int i = 0; i < n && nums[i] <= x; i++) ...
#include <bits/stdc++.h> using namespace std; const long long INF = (long long)1e15 + 696969; long long n, k; long long a[1LL << 20], b[1LL << 20]; long long opt[20][1LL << 20]; signed main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); memset(opt, -1, sizeof opt); cin >...
#include <bits/stdc++.h> using namespace std; struct edge { int u; int v; long long cost; edge() {} edge(int u, int v, long long c) : u(u), v(v), cost(c) {} }; long long comb2(long long n) { return (n * (n - 1)) / 2; } const int MAXN = 100100; int n; vector<int> G[MAXN]; edge es[MAXN...
#include <bits/stdc++.h> using namespace std; long long n; int k; long long a[100050]; int main() { cin >> n >> k; for (int i = 1; i <= k; i++) cin >> a[i]; long long A = 1, B = 0, C = 0; for (int i = 1; i <= k; i++) { if (n - n % a[i] > C) { A = 1ll * i, B = n / a[i]; C ...
/* -- ============================================================================ -- FILE NAME : clk_gen.v -- DESCRIPTION : ʱÖÓÉú³ÉÄ£¿é -- ---------------------------------------------------------------------------- -- Revision Date Coding_by Comment -- 1.0.0 2011/06/27 suito ´´½¨ -- 1.0.1 2014/06/...