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...
/****************************************************************************** * License Agreement * * * * Copyright (c) 1991-2012 Altera Corporation, San Jose, California, USA. * ...
module top ( // Clocks input wire clk1, input wire clk2, // Dummy data input input wire [1:0] i_d, input wire i_t, // OSERDES output(s) inout wire [1:0] out, // Dummy outputs output wire o_d ); // ============================================================================ wire clk; wi...
// Copyright 1986-2014 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2014.1 (lin64) Build 881834 Fri Apr 4 14:00:25 MDT 2014 // Date : Thu May 1 20:55:21 2014 // Host : macbook running 64-bit Arch Linux // ...
/** * 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 = 1e5 + 100; const int maxpow = 1 << 17; const int inf = 1e9 + 7; long long h[maxn]; int par[maxn]; struct node { pair<int, int> a; node(pair<int, int> _a) : a(_a) {} node() : a(0, -1) {} void merge(node x, node y) { a = max(x.a,...
/** \file "interleave-a.v" Chain a bunch of inverters between VPI/VCS and prsim, shoelacing. Added inverters in prsim to check for proper event interleaving. $Id: interleave-a.v,v 1.3 2010/04/06 00:08:31 fang Exp $ */ `timescale 1ns/1ps `include "clkgen.v" module timeunit; initial $timeformat(-9,1," ns",9);...
#include <bits/stdc++.h> using namespace std; vector<pair<long long, pair<long long, long long> > > edges; vector<long long> wt(100005); long long sz[100005], parent[100005]; long long ans = 0; long long n, m; void make_set() { for (long long i = 1; i <= n; i++) { sz[i] = 1; parent[i] = 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 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 la...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: bw_ctu_pad_cluster.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 i...
#include <bits/stdc++.h> using namespace std; int main() { int s, x, y, a, b; cin >> s >> x >> y >> a >> b; if ((x * s) + (2 * a) < (y * s) + (2 * b)) { cout << First ; return 0; } if ((x * s) + (2 * a) > (y * s) + (2 * b)) { cout << Second ; return 0; } if ((x ...
// megafunction wizard: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: dcfifo // ============================================================ // File Name: fifo_4k_18.v // Megafunction Name(s): // dcfifo // // 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...
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) const double PI = acos(-1); using namespace std; const int MAX = 100 * 1000 + 10; int A[MAX], B[MAX], n, pos[MAX]; int diff[MAX << 1]; int mx[MAX], mn[MAX]; deque<int> dq; const int oo = 1 << 28; int main() { scanf( %d , &n); for (int i = 0...
module ID_EX(input clk, input reset, input [1:0] WB_in, input [1:0] M_in, input [3:0] EX_in, input [31:0] RDdata1_in, input [31:0] RDdata2_in, input [31:0] sign_extended_in, input [4:0] Inst_25_to_21_in, ...
/** * 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) 2014 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, distribute,...
#include <bits/stdc++.h> using namespace std; int n, k, pos; long long a[200005], sum[200005], ans; vector<long long> vec; int main() { cin.tie(0), ios::sync_with_stdio(0); cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; sum[i] = a[i]; sum[i] += sum[i - 1]; if (a...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2009 by Wilson Snyder. bit global_bit; module t (clk); input clk; integer cyc=0; typedef struct packed { bit b1; bit b0; } strp_t; typedef struct packed...
`timescale 1ns / 1ps module mac_fifo_test(); parameter IN_WIDTH = 8; parameter OUT_WIDTH = 32; reg reset; reg [IN_WIDTH-1:0] data_in; reg data_in_clock; reg data_in_enable; reg data_in_start; reg data_in_end; w...
/* * Copyright 2013, Homer Hsing <> * * 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 to ...
module top; reg pass = 1'b1; reg in; wire bf1, bf2, nt1, nt2, pd1, pd2, pu1, pu2; initial begin // $monitor(bf1, bf2,, nt1, nt2,, pd1, pd2,, pu1, pu2,, in); if (bf1 !== 1'bz && bf2 !== 1'bz) begin $display("Buffer failed, expected 2'bzz, got %b%b", bf1, bf2); pass = 1'b0; end if (nt...
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; vector<int> arr(n); for (auto &x : arr) cin >> x; int height = 1; for (int i = 0; i < n; i++) { if (i > 0 and !arr[i - 1] and !arr[i]) { cout << -1 << n ; return; } height += arr...
// 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...
/* Copyright (C) {2014} {Ganesh Ajjanagadde} <> 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 distributed i...
module OpcodeBufferTest; `include "Framework.v" reg reset; reg clk; always #10 clk = ~clk; reg [31:0] addrA; wire [31:0] addrB; reg writeEnable = 0; reg [7:0] dataIn; reg requestA; wire requestB; wire [7:0] outA; wire [7:0] outB; wire busyA; wire busyB; wire [15:0] displayIn = 0; wire [31:0] ...
#include <bits/stdc++.h> using namespace std; inline char gc() { static const long long L = 233333; static char sxd[L], *sss = sxd, *ttt = sxd; if (sss == ttt) { ttt = (sss = sxd) + fread(sxd, 1, L, stdin); if (sss == ttt) { return EOF; } } return *sss++; } inline c...
#include <bits/stdc++.h> using namespace std; long long n, a[1231231]; long long mark[1231231]; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; mark[1] = 1; for (int i = 2; i <= n; i++) { mark[i] = mark[i - 1]; mark[i] = max(mark[i], a[i] + 1); } for (int i =...
`timescale 1 ns / 1 ps module edge_detector # ( parameter integer PULSE_WIDTH = 1 ) ( input wire din, input wire clk, output wire dout ); reg din_next; always @(posedge clk) begin din_next <= din; end generate if (PULSE_WIDTH == 1) begin : ONE assign dout = !din_next && din; ...
`timescale 1ns/10ps module Computer_System_System_PLL_sys_pll( // interface 'refclk' input wire refclk, // interface 'reset' input wire rst, // interface 'outclk0' output wire outclk_0, // interface 'outclk1' output wire outclk_1, // interface 'locked' output wire locked ); altera_pll #( .fractional...
#include <bits/stdc++.h> using namespace std; map<char, int> freq; vector<int> vec; vector<char> vec2; int main() { int n, k; cin >> n >> k; string s, ans, update, alpha = abcdefghijklmnopqrstuvwxyz ; cin >> s; int size = s.size(); for (int i = 0; i < 26; i++) { for (int j = 0; ...
// Copyright 1986-2017 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2017.3 (lin64) Build Wed Oct 4 19:58:07 MDT 2017 // Date : Tue Oct 17 15:19:38 2017 // Host : TacitMonolith running 64-bit Ubuntu 16.04.3...
#include <bits/stdc++.h> using namespace std; template <typename A, typename B> inline void smin(A &a, const B &b) { if (a > b) a = b; } struct point { double x, y, z; inline point(double x = 0, double y = 0, double z = 0) : x(x), y(y), z(z) {} inline point operator-(point a) { return point(x ...
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, c, d; cin >> a >> b >> c >> d; long long w, x, y, z; bool f = 1; if (a == c && f) { w = a + abs(d - b); x = b; y = a + abs(d - b); z = d; f = 0; } if (b == d && f) { w = a; ...
//================================================================================================== // Filename : RecursiveKOA_Weighted.v // Created On : 2016-10-28 08:47:05 // Last Modified : 2016-10-28 09:00:39 // Revision : // Author : Jorge Esteban Sequeira Rojas // Company : Insti...
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; long long dp[1001][2001][4]; long long solve(long long n, long long k, long long i) { if (dp[n][k][i] != -1) { return dp[n][k][i]; } if (k < 1 || k > 2 * n) return 0; if (i == 0) { dp[n][k][i] = solve(n - ...
// (c) Copyright 1995-2017 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property // laws. // // DISCLAIMER // This disclaimer is not a license and does not grant ...
//-------------------------------------------------------------------------------- // sampler.vhd // // Copyright (C) 2006 Michael Poppitz // // 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 Found...
#include <bits/stdc++.h> using namespace std; class Computational_Geometry { public: void init(); void solve(); Computational_Geometry() { EPS = 1e-10; Pi = acos(-1.0); } private: struct node { long long x, y; } point[100010], line[100010]; struct inter { ...
#include <bits/stdc++.h> using namespace std; int n, m, G, R, d[100127], w[100127], rt, tot = 0, mi[100127 * 20], c[100127 * 20][2]; long long f[100127], s[100127], ans; void change(int &p, int l, int r, int x, int v) { if (!p) p = ++tot; mi[p] = v; if (l ...
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 5; const int INF = 1e7; struct info { pair<int, int> x = {-INF, -1}; }; struct segtree { int n; vector<info> t; segtree(int n) { this->n = n; t.resize(n * 4); } void Merge(info &node, info &l, info &r) { no...
`timescale 1ns/1ns module CPU_tb (); reg clk, rst_n, rx; reg [7:0] switch; wire tx; wire [7:0] led; wire [6:0] digi[3:0]; CPU cpu( .clk(clk), .rst_n(rst_n), .switch(switch), .led(led), .rx(rx), .tx(tx), .digi_out1(digi[0]), .digi_out2(digi[1]), ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 10:29:40 04/18/2014 // Design Name: // Module Name: display // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // //...
#include <bits/stdc++.h> using namespace std; const int N = int(3e5), mod = int(1e9) + 7; int n; int a[N], c[N]; long long t[N]; long long x[N], pref[N]; long double p[N]; long long suf[N]; void upd(int v, int val) { v += n - 1; t[v] += val; c[v]++; while (v > 1) { v >>= 1; ...
#include <bits/stdc++.h> using namespace std; int n, x, dd[270000]; int main() { cin >> n >> x; int limit = (1 << n) - 1; vector<int> Q; Q.push_back(0); for (int i = 1; i <= limit; i++) { if (i == x) continue; if (dd[i]) continue; Q.push_back(i); dd[(i ^ x)] = 1; } ...
/* * LatticeMico32 * JTAG Test Access Port For Xilinx Sparan-6 Devices * * Copyright (C) 2010 Michael Walle * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of sour...
#include <bits/stdc++.h> using namespace std; template <class T> struct Seg { const T ID = 0; T comb(T a, T b) { return a + b; } long long n; vector<T> seg; void init(long long _n) { n = _n; seg.assign(2 * n, ID); } void pull(long long p) { seg[p] = comb(seg[2 * p], seg[2 *...
#include <bits/stdc++.h> using namespace std; struct BookInfo { int t; int a; int b; int i; }; struct CombinedBook { int t; BookInfo b1; BookInfo b2; bool isCombined; }; int main() { ios_base::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed <<...
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> std::istream& operator>>(std::istream& i, pair<T, U>& p) { i >> p.first >> p.second; return i; } template <typename T> std::istream& operator>>(std::istream& i, vector<T>& t) { for (auto& v : t) { i >> v; }...
#include <bits/stdc++.h> using namespace std; const long long MAX = 1e3 + 20; long long inf = (long long)1e15; long long mod = (long long)1e9 + 7; long long n, cntr[MAX], cntc[MAX], l[MAX][MAX], used[MAX]; void swpr(long long ind1, long long ind2) { swap(cntr[ind1], cntr[ind2]); for (int i = 1; i <=...
//===----------------------------------------------------------------------===// // // Parameterized FIFO with input and output registers and ACL pipeline // protocol ports. This "FIFO" stores no data and only hands out a sequence of // numbers from 0..DEPTH-1 (tokens) in round robin fashion. // //===-----------------...
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // are...
/* Copyright (c) 2014-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...
#include <bits/stdc++.h> using namespace std; int n, m; int nd, na; int nm; int atq[124], def[124], meu[124]; int foi[124]; int killAll() { memset(foi, 0, sizeof(foi)); for (int i = 0; i < nd; i++) { int j = 0; while (j < nm && (meu[j] <= def[i] || foi[j] == 1)) j++; if (j == nm)...
//date:2016/3/11 //engineer:ZhaiShaoMin //module name:inter registers between inst fetch stage and inst decode stage module core_if_id(//input clk, rst, // stall, if_id_we, if_flush, ...
/* * 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...
// This file is part of multiexp-a5gx. // // multiexp-a5gx 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; const double eps(1e-8), Inf(1e10); const double pi(3.14159265358979); const int N = 6060; struct point { double x, y; } p[N + N] = {}; int n, q, k = 0, a, b, x[N] = {}; double ans[N] = {}; void init() { cin >> n >> q >> a >> b; for (int i = 1; ...
module Control( Inst_i, Branch_o, Jump_o, Control_o ); input [5:0] Inst_i; output reg Branch_o,Jump_o; output reg [7:0] Control_o; //WB // Control_o[0] is RegWrite // Control_o[1] is MemtoReg //M // Control_o[2] is MemRead // Control_o[3] is MemWrite //EX // Control_o[4] is ALUSrc // Control_o[...
#include <bits/stdc++.h> using namespace std; template <class A> void pr(A a) { cout << a; cout << n ; } template <class A, class B> void pr(A a, B b) { cout << a << ; pr(b); } template <class A, class B, class C> void pr(A a, B b, C c) { cout << a << ; pr(b, c); } ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; int a[n + 1]; for (int i = 1; i <= n; ++i) cin >> a[i]; int ans = 0; for (int i = 0; i < m; ++i) { int u, v; cin >> u >> v; ans += mi...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; long long a[N], b[N], x[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); long long n, t; cin >> n >> t; for (int i = 1; i <= n; ++i) cin >> a[i]; for (int i = 1; i <= n; ++i) cin >> x[i]; for (int i = 1; i ...
//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...
/** * 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 MOD = 1000000007; void sync_stdio() { cin.tie(NULL); ios_base::sync_with_stdio(false); } struct Sync_stdio { Sync_stdio() { cin.tie(NULL); ios_base::sync_with_stdio(false); } } _sync_stdio; int intersect(pair<int, int> a, ...
// vim:set shiftwidth=3 softtabstop=3 expandtab: module register_file (rsel, wsel, rdata, wdata, wen, rst, clk); input [5:0] rsel, wsel; output [32:0] rdata; input [32:0] wdata; input wen, rst, clk; register zero(.wen(wen), .rst(rst), .clk(clk)); register at(.wen(wen), .rst(rst), .clk(clk)); register v0(.wen(w...
#include <bits/stdc++.h> using namespace std; int main() { int n; int tmp; int ans = 0; cin >> n; for (int i = 1; i <= n; i++) { for (int j = 1; j <= i; j++) { tmp = i * i + j * j; if (tmp <= n * n && int(sqrt(tmp)) * int(sqrt(tmp)) == tmp) { ans++; } ...
#include <bits/stdc++.h> using namespace std; pair<int, int> a[100 * 100 + 5]; pair<int, int> as[100 * 10000 + 5]; pair<int, int> ass[100 * 1000 * 7 + 5]; int p = 0; int badbakhti(int l, int r) { if (r - l < 2) { return 1; } int h = -10000 * 100000, e = (r + l) / 2; h = a[e].first; ...
module test_def(a, y); `define MSB_LSB_SEP : `define get_msb(off, len) ((off)+(len)-1) `define get_lsb(off, len) (off) `define sel_bits(offset, len) `get_msb(offset, len) `MSB_LSB_SEP `get_lsb(offset, len) input [31:0] a; output [7:0] y; assign y = a[`sel_bits(16, 8)]; endmodule // -------------------------------...
#include <bits/stdc++.h> using namespace std; const int M = 1 << 13; const int N = 13; long long dp[M][N][2][2]; bool used[M][N][2][2]; vector<int> digits_hour, digits_minuts; long long solve(int mask, int pos, bool flag1, bool flag2) { int h = digits_hour.size(); int min = digits_minuts.size(); ...
#include <bits/stdc++.h> using namespace std; template <class T> inline void umax(T &a, T b) { if (a < b) a = b; } const int maxn = 100 + 10; const int INF = 1e9 + 7; char a[maxn][maxn]; int c[maxn], d[maxn]; inline void solve(void) { int n; cin >> n; for (int i = (0); i < (n); i++) ci...
/* * lzw - Simple, Logarithmic Right Shift * Copyright (C) 2015 Sean Ryan Moore * * 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 yo...
#include <bits/stdc++.h> using namespace std; int n; long double V; long double vx[111111], vy[111111]; int m, N; struct point { long double x, y; bool operator<(const point &b) const { return (x != b.x) ? (x < b.x) : (y > b.y); } } ans[111111], a[111111]; pair<long double, int> k[1111...
//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; const int cap = 1e5 + 10; int main() { long long a[cap]; a[1] = 0; long long n, m; long long Max, Min; cin >> n >> m; if (m == 0) Max = n; else { for (int i = 2; i <= n; i++) { a[i] = a[i - 1] + i - 1; if (a[i] >...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7, LIM = 1e5; unsigned long long int fact[2 * LIM + 1]; unsigned long long int binpow(long long int x, int y) { unsigned long long int res = 1; while (y > 0) { if (y & 1) res = (res * x) % MOD; y >>= 1; x = (x * x) % 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...
#include <bits/stdc++.h> using namespace std; long long n, k, l, r, sz, i, len, q, p, mid, anspos, ans[1000001]; long long mxl, mxr; long long pos[1000001], t[1000001], pr[100001]; struct Pair { long long pos; long long x; long long d; }; Pair a[100001], b[100001]; bool cmp(Pair p1, Pair p2)...
module counter_16bit (En, Clk, Clr, Q); input En, Clk, Clr; output [15:0] Q; wire [15:0] T, Qs; t_flipflop T0 (En, Clk, Clr, Qs[0]); assign T[0] = En & Qs[0]; t_flipflop T1 (T[0], Clk, Clr, Qs[1]); assign T[1] = T[0] & Qs[1]; t_flipflop T2 (T[1], Clk, Clr, Qs[2]); assign T[2] = T[1] & Qs[2]; t_...
#include <bits/stdc++.h> using namespace std; int n, m, w1[555][555], w2[555][555], w3[555][555], gl, Pre[300011], anslen; char ch; struct AnsNode { int x, y, z; void init(int _x, int _y, int _z) { x = _x, y = _y, z = _z; } } Ans[1000111]; struct Node { int x, y; void init(int _x, int _y) { ...
#include <bits/stdc++.h> #pragma GCC target( avx2 ) #pragma GCC optimization( O3 ) #pragma GCC optimization( unroll-loops ) const long long INF = 0x3f3f3f3f3f3f3f3f; const long long llinf = (1LL << 62); const int inf = (1 << 30); const long long nmax = 3e5 + 50; const int mod = 1e9 + 7; const int lim ...
/** * 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> int n, fac[1000005], inv[1000005], ans; int qpow(int a, long long b) { int s = 1; for (; b; b >>= 1, a = 1ll * a * a % 998244353) if (b & 1) s = 1ll * s * a % 998244353; return s; } int C(int n, int m) { return 1ll * fac[n] * inv[n - m] % 998244353 * inv[m] % 99824...
// $Header: /devl/xcs/repo/env/Databases/CAEInterfaces/versclibs/data/simprims/X_INV.v,v 1.5 2005/03/14 21:05:15 yanx Exp $ /////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2009 Xilinx, Inc. // All Right Reserved. /////////////////////////////////////////////////////...
#include <bits/stdc++.h> using namespace std; template <typename T, size_t N> int SIZE(const T (&t)[N]) { return N; } template <typename T> int SIZE(const T(&t)) { return t.size(); } string to_string(char b) { return + string({b}) + ; } string to_string(bool b) { return (b ? true : f...
#include <bits/stdc++.h> using namespace std; int main() { int N(0), aSum(0), bSum(0), cap(0), last(0), out(0); cin >> N; for (int i = 0; i < N; i++) { int a(0), b(0); cin >> a >> b; aSum += a; bSum += b; cap = bSum - aSum; if (cap >= out) out = cap; } cout <<...
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; int main() { long long f = 0, g = 1; int n; cin >> n; for (int i = 2; i <= n; i++) { long long k = f; f = 3 * g % mod; g = (k + 2 * g) % mod; } printf( %lld , f); return 0; }
#include <bits/stdc++.h> #pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; int main() { long long int t, n, i, j, m, d, k, q, y, z, l, r, a, b, c; cin >> t; while (t--) { ...
// File: UpDown_CounterTBV.v // Generated by MyHDL 0.10 // Date: Tue Aug 14 06:51:27 2018 `timescale 1ns/10ps module UpDown_CounterTBV ( ); // myHDL -> Verilog Testbench for `Down_Counter` module reg clk = 0; reg rst = 0; reg Trig = 0; wire [4:0] count; reg [0:0] Dir = 1'b0; reg [4:0] Down_Counter0_0_1_count_i = ...
/* * Command Buffer * * Serial input to parallel output * * Check correctness of the received command * * Enable/Disable CRC-5 and CRC-16 Encoder/Decoder * * Enable to processing the command if the received command is valid * * This design of baseband processor is improved by TSMC 0.18 um CMOS sta...
// // Generated by Bluespec Compiler (build 0fccbb13) // // // Ports: // Name I/O size props // RDY_server_reset_request_put O 1 reg // RDY_server_reset_response_get O 1 reg // valid O 1 // word_fst O 64 // word_snd ...
#include <bits/stdc++.h> using namespace std; long long a, x = 1e18; int main() { cin >> a; cout << a - x % a * 9 % a * 9 % a << << a - x % a * 9 % a * 9 % a + x - 1; return 0; }
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; int add(int a, int b) { long long x = a + b; if (x >= 998244353) x -= 998244353; if (x < 0) x += 998244353; return x; } long long mul(long long a, long long b) { return (a * b) % 998244353; } long long pw(long long a, l...
#include <bits/stdc++.h> using namespace std; int get() { int f = 0, v = 0; char ch; while (!isdigit(ch = getchar())) if (ch == - ) break; if (ch == - ) f = 1; else v = ch - 0 ; while (isdigit(ch = getchar())) v = v * 10 + ch - 0 ; if (f) return -v; else ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> v; for (int i = 1; i <= 20; ++i) { int first = ((1 << i) - 1) * (1 << (i - 1)); if (first > 1e5) break; v.push_back(first); } for (int i = v.size() - 1; i >= 0; --i) { if (n % v[i]...
#include <bits/stdc++.h> using namespace std; int n, ans; float x, dis, t; struct ponto { float ini, fim; bool operator<(const ponto &lhs) const { return lhs.ini > ini; } } p[1010]; int main() { scanf( %d%f , &n, &t); ans = 2; for (int i = 0; i < n; i++) { scanf( %f%f , &x, &dis); ...
#include <bits/stdc++.h> using namespace std; int a[1000000 * 2][2], g[1000000], v[1000000], d[20], f[1000000], e[20]; int n; void ins(int x, int y) { static int sum = 1; a[++sum][0] = y, a[sum][1] = g[x], g[x] = sum; } int gcd(int x, int y) { return !y ? x : gcd(y, x % y); } void dfs(int x, int G...
/* Copyright (C) 2016 Cedric Orban 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 distributed in the ho...
#include <bits/stdc++.h> using namespace std; struct cell { int x, y, cost; cell(int i, int j, int k) { x = i; y = j; cost = k; } }; int main() { int n, m, s; scanf( %d%d%d , &n, &m, &s); s--; int t1, t2, t3; vector<vector<pair<int, int> > > g(n); vector<int...