text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int main() { double a, v; cin >> a >> v; double l, d, w; cin >> l >> d >> w; w = min(w, v); double s = w / a; double t = a * s * s / 2; double thead = 0; double vhead = 0; if (t < d) { double t1 = v / a; double t2 = (v...
/* * Copyright (c) 2000 Stephen Williams () * * 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) * ...
`timescale 1ns/10ps module tb_mathsop; reg clock, reset; reg [15:0] x; wire [15:0] ym1, ym2, yb1, yb2, yc1, yc2; initial begin $dumpfile("vcd/mathsop.vcd"); $dumpvars(0, tb_mathsop); end initial begin $from_myhdl(clock, reset, x); $to_myhdl(ym1, ym2, yb1, yb2, yc1, ...
package pkg; typedef logic [1:0] my_type; endpackage module top; import pkg::*; /*AUTOWIRE*/ // Beginning of automatic wires (for undeclared instantiated-module outputs) pkg::my_type_t a; // From sub_2 of sub_2.v pkg::my_type_t z; // From sub_1...
/*-------------------------------------------------------------------------- -------------------------------------------------------------------------- -- File Name : diffeq.v -- Author(s) : P. Sridhar -- Affiliation : Laboratory for Digital Design Environments -- Department of Electrical & Computer Engineering -...
#include <bits/stdc++.h> int main() { long long int n, a, b, i, t; scanf( %lld %lld %lld , &n, &a, &b); t = n / a + 1; for (i = 0; i < t; i++) { if ((n - (a * i)) % b == 0 && n - (a * i) >= 0) { printf( YES n%lld %lld , i, (n - (a * i)) / b); return 0; } } printf( N...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int N = 1e6 + 10; const long long INF = 1e18; const long double EPS = 1e-12; struct Point { long double x, y; Point() {} Point(long double x, long double y) : x(x), y(y) {} Point(const Point &p) : x(p.x), y(p.y) {} ...
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 100; long long a[N]; pair<long long, long long> ask(long long l, long long r) { cout << ? << l << << r << endl; long long first; cin >> first; if (first == -1) exit(0); long long f; cin >> f; return {first...
/** * 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...
/////////////////////////////////////////////////////////////////////////////// // // Project: Aurora Module Generator version 2.2 // // Date: $Date: 2004/11/08 16:19:25 $ // Tag: $Name: i+H-38+78751 $ // File: $RCSfile: chbond_count_dec_4byte.ejava,v $ // Rev: $Revision: 1.1...
`timescale 1ns / 1ps `default_nettype none ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: Miguel Angel Rodriguez Jodar // // Create Date: 03:22:12 07/25/2015 // Design Name: SAM Coupé clone // Module Name: rom // Project Name: SAM Coupé clone ...
/** * 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 (c) 2012-2013 Ludvig Strigeus // This program is GPL Licensed. See COPYING for the full license. module VgaDriver(input clk, output reg vga_h, output reg vga_v, output reg [3:0] vga_r, output reg[3:0] vga_g, output reg[3:0] vga_b, output [9:0] vga_hcounte...
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; const int N = 200005; int prime[1100000], primesize; bool isprime[11000000]; long long f[N], invf[N]; long long inv[N]; void getlist(int listsize) { memset(isprime, 1, sizeof(isprime)); isprime[1] = false; for (int i = ...
// Copyright 2020-2022 F4PGA 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 // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed...
#include <bits/stdc++.h> using namespace std; struct node { long long y, z; long long x; int choice; }; node g[2000001]; int cmp(node head, node a) { if (head.y != a.y) return head.y < a.y; if (head.z != a.z) return head.z < a.z; return head.x > a.x; } struct info { int choice;...
#include <bits/stdc++.h> using namespace std; long long aabs(long long a) { if (a < 0) return -a; else return a; } struct node { long long num; int id; bool operator<(const node &a) const { return aabs(num) > aabs(a.num); } }; long long a[200005]; long long n, k, x; int m...
`define OP 31:26 `define RS 25:21 `define RT 20:16 `define RD 15:11 `define SHAMT 10:6 `define FUNCT 5:0 `define IMM 15:0 `define RTYPE 6'b00_0000 `define REGIMM 6'b00_0001 `define ADDU_R 6'b10_0001 `define ADD_R 6'b10_0000 `define DIVU_R 6'b01_1011 `define DIV_R 6'b01_1010 `define JR_R 6'b00_1000 `define JALR_R 6'b00...
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using vvi = vector<vi>; using ii = pair<int, int>; using vii = vector<ii>; using l = long long; using vl = vector<l>; using vvl = vector<vl>; using ll = pair<l, l>; using vll = vector<ll>; using vvll = vector<vll>; using lu = ...
/** * 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 module SPIFSM #( parameter SPPRWidth = 4, parameter SPRWidth = 4, parameter DataWidth = 8 ) ( input Reset_n_i, input Clk_i, // FSM control input Start_i, output reg Done_o, output reg [DataWidth-1:0] Byte0_o, output ...
#include <bits/stdc++.h> using namespace std; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); struct Event { long long x, t, i; Event() {} Event(long long x, long long t, long long i) : x(x), t(t), i(i) {} }; bool cmpEvents(const Event &a, const Event &b) { return tie(a.x,...
/** * 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...
//----------------------------------------------------------------- // RISC-V Top // V0.6 // Ultra-Embedded.com // Copyright 2014-2019 // // // // License: BSD //--------------------------...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 10:32:33 05/12/2015 // Design Name: // Module Name: IF_ID // Project Name: // Target Devices: // Tool versions: // Description: // // Dependenc...
#include <bits/stdc++.h> using namespace std; vector<int> a; int gcd(int a, int b) { if (b == 0) { return a; } return gcd(b, a % b); } int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int T; cin >> T; while (T--) { int n; cin >> 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...
/************************************************************************ * File Name : mod.v * Version : * Date : * Description : * Dependencies : * * Company : Beijing Soul Tech. * * Copyright (C) 2008 Beijing Soul tech. * **********************************************...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2015 by Johan Bjork. parameter N = 4; // verilator lint_off LITENDIAN interface a_if #(parameter PARAM = 0) (); logic long_name; modport source (output long_name); modport s...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 10:15:45 06/08/2013 // Design Name: // Module Name: Control // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // //...
#include <bits/stdc++.h> using namespace std; string b[1 << 15]; int x[100], y[100], n; map<string, int> mp; int main() { scanf( %d , &n); for (int i = 0, z; i < n; i++) { scanf( %d , &z); x[i] = z & ((1 << 15) - 1); y[i] = z >> 15; } for (int B = 0; B < (1 << 15); B++) { ...
#include <bits/stdc++.h> using namespace std; set<int> x, y; int vx[200006], vy[200006]; set<int> mx, my; set<int>::iterator it1, it2; void gao(set<int> &t1, set<int> &t2, int *v, int x) { if (!t1.count(x)) { it1 = t1.lower_bound(x); it2 = it1, it1--; int l = *it2 - *it1; v[l]--;...
#include <bits/stdc++.h> using namespace std; const int Nx = 200005; int ct[Nx], MMsize, A, B, tree[Nx * 4]; map<int, int> MM; vector<int> pos[Nx]; int query(int a, int b, int key) { if (A <= a && b <= B) return tree[key]; if (B < a || b < A) return 0; int m = (a + b) / 2; return query(a, m,...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using D = double; using uint = unsigned int; template <typename T> using pair2 = pair<T, T>; const int maxn = 300005; bool used[maxn]; int n, k; vector<int> all; int main() { cin >> n >> k; if (k ...
#include <bits/stdc++.h> using namespace std; int main() { long long x; cin >> x; while (x--) { string str; cin >> str; long long n, b, m, v, finl, finl2; finl2 = 0; v = 0; b = 0; m = 0; v = 0; for (n = 0; n < str.size(); n++) { finl = (int)s...
/* Copyright (C) 2015-2016 by John Cronin * * 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, merg...
#include <bits/stdc++.h> using namespace std; bool sortbysec(const pair<int, int> a, const pair<int, int> b) { return a.second < b.second; } int main() { string s1; cin >> s1; string s2; cin >> s2; bool flag = false; string ans = 0 ; for (int i = 0; i < s1.length(); i++) { ...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int main() { int n; cin >> n; vector<long long> v(2 * n); for (int i = 0; i < 2 * n; i++) cin >> v[i]; sort(v.begin(), v.end()); long long ans = (v[n - 1] - v[0]) * (v[2 * n - 1] - v[n]); long long minx = 1e9 + 10; ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; int n; cin >> n; vector<int> v(n); int mx = 0; for (int i = 0; i < n; i++) { cin >> v[i]; mx = max(mx, v[i]); } int count = 1, l = 0; fo...
#include <bits/stdc++.h> using namespace std; const int N = 10005; long long int p[N], s[N], n, c; long long int dp[2][N]; int main() { cin >> n >> c; for (int i = 0; i < n; i++) cin >> p[i]; for (int i = 0; i < n; i++) cin >> s[i]; dp[0][0] = p[0]; dp[0][1] = s[0]; int row = 1; fo...
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; long long dyn[5001][5001]; int A[300000]; int main() { int n, k; scanf( %d , &(n)); scanf( %d , &(k)); for (int(i) = 0; (i) < n; (i)++) scanf( %d , &(A[i])); sort(A, A + n); int rem = n % k; int q = n / k...
#include <bits/stdc++.h> using namespace std; const int maxn = 5e5 + 10; const int base = 31337; const int mod = 1e9 + 7; const int inf = 0x3f3f3f3f; const int logo = 20; const int off = 1 << logo; const int treesiz = off << 1; int n; char niz[maxn]; int his[maxn]; int main() { scanf( %d%s ,...
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 5; int n, k, sz, trie[MAX][26]; bool win[MAX], lose[MAX]; char s[MAX]; void dfs(int u) { int ady = 0; for (int i = 0; i < 26; i++) { if (trie[u][i] == 0) continue; ady++; int v = trie[u][i]; dfs(v); win...
#include <bits/stdc++.h> using namespace std; const int maxn = 300001; int f[maxn], a[maxn]; inline void add(int x, int val) { for (int i = x + 1; i < maxn; i += i & (-i)) f[i] += val; } inline int get(int x) { int ans = 0; for (int i = x; i > 0; i -= i & (-i)) ans += f[i]; return ans; } ...
#include <bits/stdc++.h> using namespace std; int main() { string str; getline(cin, str); str.erase(remove(str.begin(), str.end(), ), str.end()); int n = str.size(); if (str[n - 2] == a || str[n - 2] == e || str[n - 2] == i || str[n - 2] == o || str[n - 2] == u || str[n - 2]...
#include <bits/stdc++.h> long long MOD = 1e9 + 7; using namespace std; int in() { int x; scanf( %d , &x); return x; } long long lin() { long long x; scanf( %lld , &x); return x; } template <typename A, size_t NNN, typename T> void Fill(A (&array)[NNN], const T &val) { fill((T...
#include <bits/stdc++.h> template <typename T> void MACRO_VAR_Scan(T& t) { std::cin >> t; } template <typename First, typename... Rest> void MACRO_VAR_Scan(First& first, Rest&... rest) { std::cin >> first; MACRO_VAR_Scan(rest...); } template <typename T> void MACRO_VEC_ROW_Init(int n, T& t) ...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); const double eps = 1e-9; const int inf = 2000000000; const long long infLL = 9000000000000000000; inline bool checkBit(long long n, int i) { return n & (1LL << i); } inline long long setBit(long long n, int i) { return n | (1LL ...
module quad(clk, reset, quadA, quadB, count); parameter SCREENHEIGHT=0; parameter PADDLESIZE = 0; input clk, reset, quadA, quadB; output [9:0] count; reg [2:0] quadA_delayed, quadB_delayed; always @(posedge clk) quadA_delayed <= {quadA_delayed[1:0], quadA}; always @(posedge clk) quadB_delayed <= {quadB_delayed...
#include <bits/stdc++.h> using namespace std; int i, j, k, l; int n, m, d, a[100010][4]; int ms[11111]; double cx, cy, ccx, ccy; int x1, stupid_cmath, x2, y2; int main() { cin >> n; for (i = 0; i < n; ++i) { cin >> x1 >> stupid_cmath >> x2 >> y2; a[i][0] = ((x1) < (x2) ? (x1) : (x2)); ...
//Legal Notice: (C)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 //simulation files), and any associated do...
#include <bits/stdc++.h> using namespace std; template <typename T> inline void chkmin(T &x, T y) { x = min(x, y); } template <typename T> inline void chkmax(T &x, T y) { x = max(x, y); } template <typename T> inline void read(T &x) { T f = 1; x = 0; char c = getchar(); for (; ...
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll mod = 1e9 + 7; const int maxn = 1e5 + 5, maxa = 71, lim = 1 << 19; ll ev[maxn], od[maxn], dp[2][lim]; int n, a, f[lim], comp[maxa]; vector<int> p; int calc_msk(int x) { int msk = 0, b = 1; for (int y : p) { while ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: Jafet Chaves Barrantes // // Create Date: 20:32:40 05/17/2016 // Design Name: // Module Name: picture_timer // Project Name: // Target Devices: // Tool versions: // Description:...
Require Import Iron.Language.SystemF2.Preservation. Require Export Iron.Language.SystemF2.Step. Require Export Iron.Language.SystemF2.SubstExpExp. Require Export Iron.Language.SystemF2.SubstTypeExp. Require Import Iron.Language.SystemF2.TyJudge. Require Export Iron.Language.SystemF2.Exp. (* Big Step Evaluation. T...
#include <bits/stdc++.h> using namespace std; char x; int n; int main() { cin >> n; cin >> x; cout << x; cin >> x; cout << x; n -= 2; if (n % 2 == 1) { cin >> x; cout << x; n--; } for (int i = 1; i <= n; i++) { if (i % 2 == 1) cout << - ; cin >>...
#include <bits/stdc++.h> using namespace std; long long t, m, n, a, u, v; void printAnswer(vector<int> ans) { sort(ans.begin(), ans.end()); cout << ans.size() << endl; for (int i = 0; i < ans.size(); i++) { cout << ans[i] << ; } cout << endl; } int main() { cin >> t; for (...
#include <bits/stdc++.h> using namespace std; const int N = 1234567; int n, a, b, T, used, ans; int lft[N], rgt[N]; char s[N]; void fill_array(int v[]) { for (int i = 1; i < n; i++) { v[i] = v[i - 1] + a + 1 + ((s[i] == w ) ? b : 0); } } void solve(int lft[], int rgt[]) { for (int i =...
`timescale 1ns / 1ps //this code was generated by cReComp module motor_ctl( input clk, input rst_32, input [31:0] din_32, input [0:0] wr_en_32, input [0:0] rd_en_32, output [31:0] dout_32, output [0:0] full_32, output [0:0] empty_32, output dir_out_r, output dir_out_l, output en_out_r, output en_out_l ); // //cop...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 2016/05/24 12:23:27 // Design Name: // Module Name: carry_look_ahead_adder // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies...
#include <bits/stdc++.h> using namespace std; long long int scs(long long int a) { long long int u = 0; while (a) { u++; a /= 10; } return u; } long long int mul(long long int a, long long int b, long long int m) { if (b == 1) return a % m; if (b == 0) return 1 % m; a %= ...
#include <bits/stdc++.h> using namespace std; long long int dp[100000 + 10]; vector<int> ma[100000 + 10]; int a[100000 + 10]; long long int dp1[100000 + 10]; long long int gcd(long long int x, long long int y) { return y == 0 ? x : gcd(y, x % y); } long long int lcm(long long int x, long long int y)...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; char str[MAXN]; class Value { public: char c1, c2, last_c1, last_c2; int pos, l1, sz; Value() { c1 = 0; c2 = 0; pos = 0; l1 = 0; last_c1 = 0; last_c2 = 0; } void push_front(char c) ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k, a, b, i = 0, arr[100000], j = 0; cin >> n >> k; for (int x = 0; x < n; x++) { cin >> a >> b; i++; while (a != b) if (a < b) a++, i++; else a--, i++; } while (i % k != 0) { ...
#include <bits/stdc++.h> using namespace std; unsigned long long gcd(unsigned long long a, unsigned long long b) { if (b == 0) { return a; } return gcd(b, a % b); } int main() { unsigned long long n, m, k; cin >> n >> m >> k; unsigned long long h = 2 * n * m; if (h % k == 0) { ...
#include <bits/stdc++.h> using namespace std; int n, m, a[100010], s[100010], sp, cnt; long long tot, sum, pj; int main() { cin >> n >> m; for (register int i = 1; i <= n; i++) cin >> a[i], tot += a[i]; if (tot % m != 0) { cout << No << endl; return 0; } pj = tot / m; for (...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int t; cin >> t; while (t--) { long long int n; string s; cin >> n >> s; map<long long int, vector<long long int>> mp; for (long...
#include <bits/stdc++.h> using namespace std; int a[100500]; int sp[2005]; int f[100500], l[100500]; int n, m; int ns[2 * 100500]; int ps[2 * 100500]; int used[2 * 100500]; int lp[100500]; int rp[100500]; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; ++i) { scanf( %d , ...
// megafunction wizard: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: scfifo // ============================================================ // File Name: ff_64x256_fwft.v // Megafunction Name(s): // scfifo // // Simulation Library Files(s): // altera_mf // ========================================...
/** * 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...
// nios_dut_mm_interconnect_0_avalon_st_adapter.v // This file was auto-generated from altera_avalon_st_adapter_hw.tcl. If you edit it your changes // will probably be lost. // // Generated using ACDS version 15.1 185 `timescale 1 ps / 1 ps module nios_dut_mm_interconnect_0_avalon_st_adapter #( parameter inBitsPe...
// *************************************************************************** // *************************************************************************** // 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; inline int read() { int res = 0, f = 1; char ch; while (ch = getchar(), ch < 0 || ch > 9 ) if (ch == - ) f = -1; while (ch >= 0 && ch <= 9 ) res = res * 10 + ch - 0 , ch = getchar(); return res * f; } const int N = 14, M = 4782969, ...
/* * SBN machine with hardwired FSM control * (c) Volker Strumpen * * modified to halt execution * if result address is C all fff's * i.e. ff for fwidth=8 * by Martin Polak */ module sbn (clk, state, PC, a, b); parameter fwidth = 8; // field width of sbn operand parameter dwidth = 32; input ...
module ram0( // Read port input rdclk, input [9:0] rdaddr, output reg [35:0] do); (* ram_style = "block" *) reg [35:0] ram[0:1023]; genvar i; generate for (i=0; i<1024; i=i+1) begin initial begin ram[i] <= i | (i << 16); end e...
#include <bits/stdc++.h> using namespace std; int main() { long long int m, n, row[1010], col[1010], ans = 0, sum = 0; char a[1010][1010]; cin >> m >> n; memset(row, 0, sizeof row); memset(col, 0, sizeof col); for (long long int i = 0; i < m; i++) for (long long int j = 0; j < n; j++) ...
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(0); int n, r1 = 0, r2 = 0; cin >> n; vector<int> r(n); for (int &i : r) cin >> i; for (int i = 0; i < n; i++) { int a; cin >> a; if (a != r[i]) { if (a) r1++; ...
#include <bits/stdc++.h> using namespace std; string s; pair<int, int> st[3000002]; void build(int v, int l, int r) { if (l == r) { st[v] = make_pair(s[l] == ( , s[l] == ) ); return; } int lv, rv, mid; lv = 2 * v; rv = 2 * v + 1; mid = (l + r) / 2; build(lv, l, mid); ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100 * 1000 + 7, MAX_LOG = 20; int n, m; vector<int> adj[MAXN]; bool isPassed[MAXN]; int par[MAXN][MAX_LOG], cycleCnt[MAXN], h[MAXN]; void pre(int root) { isPassed[root] = true; for (auto nei : adj[root]) { if (!isPassed[nei]) { ...
/** * 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; void doicho(int &t1, int &t2) { if (t1 > t2) swap(t1, t2); } void sapxep(pair<double, int> result[], int n) { for (int i = 0; i < n - 1; i++) { for (int j = i + 1; j < n; j++) { if (result[i].first < result[j].first) { swap(result[i]....
//---------------------------------------------------------------------------- //--By Kyle Williams, 11/20/2012----------------------------------------------------- //--MODULE DESCRIPTION--------------------------------------------------------------- //----------------Simple single Port Ram used to store data----------...
#include <bits/stdc++.h> using namespace std; long long n, c, r[200001], u, v, i, t, k; vector<long long> graph[200001], ans; bool dfs(long long x, long long p) { long long s = 0; for (auto i : graph[x]) if (i != p) s += dfs(i, x); if (r[x] && !s) ans.push_back(x); return s + (long long)(r...
/** * 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/linux/ion.h * * Copyright (C) 2011 Google, Inc. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and * may be copied, distributed, and modified under those terms. * * This program is distributed in the hope t...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2014. // SPDX-License-Identifier: CC0-1.0 module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc = 0; reg [63:0] crc; reg [255:0] sum; // Take CRC ...
#include <bits/stdc++.h> using namespace std; int a[105]; int f[105]; int v[105]; bool cmp(int i, int j) { return a[i] > a[j]; } int main() { int n, w; while (cin >> n >> w) { int sum = 0; int sum2 = 0; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; ...
// File: elevator.v // Generated by MyHDL 0.8.1 // Date: Sun Jun 14 22:11:56 2015 `timescale 100ms/1ms module elevator ( clk, reset, en, F, D, Q, A, B, A_latch, B_latch, LED, io_seg ); input clk; input reset; input en; input [3:0] F; output [3:0] D; wire [3:0] D; out...
#include <bits/stdc++.h> using namespace std; int n, x, y, neg, pos; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> x >> y; if (x < 0) neg++; else pos++; } if (pos <= 1 || neg <= 1) cout << Yes ; else cout << No ; return 0; } ...
#include <bits/stdc++.h> int cut; int q[100005] = {0}; int totalnode, totaledge, i, j, k, l, a, b, t1, t2; int c(int q) { if (q == 2) { return cut; } else if (q == cut) { return 2; } else return q; } int main() { for (i = 0; i < 100005; i++) q[i] = i; scanf( %d %d %d , ...
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; while (T--) { int n; cin >> n; int a[n]; bool ok = true; bool f = true; for (int i = 0; i < n; i++) { cin >> a[i]; if (!ok) continue; if (f && a[i] < i) { f =...
#include <bits/stdc++.h> using namespace std; vector<vector<int> > g; bool flag[100003]; int down[100003]; int max1[100003]; int max2[100003]; int up[100003]; void dfs(int x) { flag[x] = true; int i; for (i = 0; i < g[x].size(); i++) { if (!flag[g[x][i]]) { dfs(g[x][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...
/** * This is written by Zhiyang Ong * and Andrew Mattheisen */ // Design of the 2-bit pipe module pipeline_buffer_2bit (in,out,clock,reset); // Output signal for the design module output [1:0] out; // Output data signal // Input signals for the design module input [1:0] in; // Input data signal inp...
#include <bits/stdc++.h> using namespace std; const long long INF = 9e18; const int mod = 4e4 + 7; vector<int> prime; bool p[100005]; void init() { p[1] = true; for (int i = 2; i <= 100005; i++) { if (!p[i]) { prime.push_back(i); for (int j = i + i; j < 100005; j += i) p[j] = t...
// (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 F[100000], S[100000]; int main(int argc, char *argv[]) { int n, x, adg, i, j, k, L, A, B; cin >> n >> x; for (i = 0; i < n; i++) cin >> F[i]; for (i = 0; i < n; i++) cin >> S[i]; if (n == 1) cout << 1 << << 1; else { 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...