text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int t; vector<vector<int> > nod; vector<int> sol; void bfs(int n) { sol = vector<int>(n + 10); sol[1] = 1; queue<int> Q; Q.push(1); while (!Q.empty()) { int a = Q.front(); Q.pop(); for (int j = 0; j < nod[a].size(); j++) ...
// (C) 2001-2017 Intel Corporation. All rights reserved. // Your use of Intel 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 docum...
#include <bits/stdc++.h> using namespace std; long long int n, t; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> t; while (t--) { cin >> n; long long int a[n], x = 0; vector<long long int> ans; for (int i = 0; i < n; i++) { cin >> a[i]; ...
#include <bits/stdc++.h> using namespace std; string s; bool atted, dotted, goned; int cntu, cnth = -1, cntr = -1, cntd = -1; int main() { cin >> s; for (int i = 0; i < ((int)(s).size()); i++) { if (!atted && s[i] == @ ) atted = 1; else if (atted && !goned && s[i] == . && s[i - ...
//----------------------------------------------------------------------------- // // (c) Copyright 2012-2012 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 ...
/** * 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() { int n, x(0); cin >> n; string s; while (n--) { cin >> s; if (s[1] == + ) ++x; else --x; } cout << x << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int MAX_N = 300000; const int MAX_E2 = 1 << 20; const long double PI = acosl(-1.0); struct Elm { long double x, y, th; Elm() : x(0.0), y(0.0), th(0.0) {} Elm(long double _x, long double _y, long double _th) : x(_x), y(_y), th(_th) {} ...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b; if (a >= b) { c = (a - b) / 2; cout << b << << c; } else { c = (b - a) / 2; cout << a << << c; } }
//Manages memory and //dispatches instructions to the rest of //the processor. //This unit doesn't have a proper pipeline, //rather it is mostly hard-wired combinational logic. module dispatchu( CLK, MEMDAT, ADAT, BDAT, CDAT, addr, memOut, memWrite, Cout, cWrite, Asel, Bsel, Csel, intPipeOp...
#include <bits/stdc++.h> using namespace std; const int maxn = 2007; const int mod = 1e9 + 7; int n, m; int dp[maxn][maxn][2], block[maxn][maxn][2], sum[maxn][maxn][2], vec[maxn][2]; char s[maxn][maxn]; int calc(int u, int v, int w) { if (w == 0) { for (; vec[v][1] < u; ++vec[v][1]) { if...
#include <bits/stdc++.h> struct el { int x, y, z; }; using namespace std; int cmp(el a, el b) { return a.x < b.x; } int cmp1(el a, el b) { return a.y < b.y; } int main(int argc, const char* argv[]) { int n, w; cin >> n >> w; vector<el> a; el b; int ans = 0; for (int i = 0; i < 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...
#include <bits/stdc++.h> using namespace std; using Long = long long; int main() { int t; cin >> t; while (t--) { int d; cin >> d; if (d * d < 4 * d) { puts( N ); } else { double dis = sqrt(d * d - 4 * d); double x = (dis + d) / 2, y = (d - dis) / 2; ...
#include<bits/stdc++.h> #define pb push_back using namespace std; typedef long long ll; const int maxn=1e6+100; const int M=1000000007; typedef array<int,41> A; bool vis[50]; int f[50],n,mx,F[50][50],G[50][50],p[50],nf[50],inv[50]; int ways[50][50][50]; map<A,int> dp[41][41][41]; void add(int &x,i...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: dram_ddr_rptr_south.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 ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 16:53:07 07/01/2014 // Design Name: // Module Name: cheat // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // Revision: //...
#include <bits/stdc++.h> using namespace std; int main() { int n, x; int a; scanf( %d%d , &n, &x); int sum = 0; while (n--) { scanf( %d , &a); sum += a; } int count = 0; if (sum == 0) { } else { if (abs(sum) <= x) { count = 1; } else { coun...
`timescale 1ns / 1ps /* Group Members: Thomas Hudson and Warren Seto Lab Name: Combinational Logic Project Name: eng312_proj2 Design Name: mux_four_to_one_test.v Design Description: Verilog Test Fixture for a Four to One Multiplexer */ module mux_four_to_one_test; // Inputs reg [3:0] DIN; ...
///////////////////////////////////////////////////////////////////// //// //// //// SPI Slave Model //// //// //// //// ...
/** * 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 : Fri Sep 22 23:00:44 2017 // Host : DarkCube running 64-bit major release ...
#include <bits/stdc++.h> using namespace std; int main() { int m = 0, k = 0, p = 0, i = 1; string s; cin >> s; int n, a[27]; cin >> n; for (i = 1; i < 27; i++) cin >> a[i], m = max(m, a[i]); for (i = 0; i < s.length(); i++) k += a[s[i] - 96] * (i + 1); while (n--) i++, p += i * m; ...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int n; double p[maxn], dp[maxn]; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %lf , &p[i]); double sol = 0.; dp[0] = 0; for (int i = 1; i < n; i++) { dp[i] = (dp[i - 1] + p[i - 1]) * p[i]; ...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) using namespace std; int a, b, c, d, i, j, n, m, k, ans, T; char str[200003]; int p[22], cs[22][22], dp[1 << 22]; pair<int, int> cur[26]; int main() { scanf( %d%d%d , &n, &k, &T); scanf( %s , str); for (int _n((k)-1), i(0); i ...
#include <iostream> #include <cstdio> #include <cassert> #include <cstring> #include <cmath> #include <functional> #include <algorithm> #include <utility> #include <vector> #include <string> #include <map> #include <set> using namespace std; using ll = long long; using PII = pair<int,int>; ...
/*************************************************************************************************** ** fpga_nes/hw/src/cpu/jp.v * * Copyright (c) 2012, Brian Bennett * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted * provided that the followi...
#include <bits/stdc++.h> const int maxn = 100001; int n, i, u, v, top, a[maxn], spt[maxn], vt[maxn], st[maxn], l[maxn]; long long sum, ans, tmp, val[maxn], uc, bc, ss, min; std::vector<int> adj[maxn]; void dfs() { top = 1; st[1] = 1; while (top > 0) { u = st[top]; if (vt[u] < spt[u] &&...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 11/03/2014 07:21:44 PM // Design Name: // Module Name: seven_seg // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // ...
#include <bits/stdc++.h> using namespace std; int n, CA, CB; struct point { int x, y; bool operator<(const point &p) const { return x != p.x ? x < p.x : y < p.y; } } st[201000]; int BX[201000], EX[201000], BY[201000], EY[201000]; long long res; void Pro(vector<point> &w, int *B, int *E) { int ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int x[n], y[n], h[n], a[n]; for (int i = 0; i < n; i++) { cin >> x[i] >> y[i]; } for (int i = 0; i < n; i++) { h[i] = n - 1; a[i] = 0; } int home[1000000] = {0}, away[1000000] = {0}; for...
// 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; int main() { int t; cin >> t; while (t--) { int n, k; cin >> n >> k; vector<int> s[k]; for (int i = 0; i < k; ++i) { int c; cin >> c; for (int j = 0; j < c; ++j) { int p; cin >> p; ...
#include <bits/stdc++.h> using namespace std; void qmax(long long &x, long long y) { if (x < y) x = y; } void qmin(long long &x, long long y) { if (x > y) x = y; } inline long long read() { char s; long long k = 0, base = 1; while ((s = getchar()) != - && s != EOF && !(isdigit(s))) ...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
/* lab3_part3.v - Master Slave D latch * * Copyright (c) 2014, Artem Tovbin <arty99 at gmail dot com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is dist...
/** * 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...
// (c) Copyright 1995-2014 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 ...
#include <bits/stdc++.h> using namespace std; long long int mod = 1e9 + 7; int dx[4] = {0, 1, 0, -1}; int dy[4] = {1, 0, -1, 0}; int main() { int n; cin >> n; string s; cin >> s; s += . ; n++; vector<pair<char, int>> a; int c = s[0]; int cnt = 1; for (int i = 1; i < 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 // This module is a third order delta/sigma modulator // It uses no multiply only shifts by 1, 2 or 13 // There are only 7 adders used, it takes around 110 LUTs module hq_dac ( input reset, input clk, input clk_ena, input [19:0] pcm_in, output reg dac_out ); ...
#include <bits/stdc++.h> using namespace std; long long n, h; bool ok(long long x) { long long ans = 0; if (x >= 2e9) return 1; if (x <= h) ans = x * (x + 1) / 2; else { ans = h * (h + 1) / 2 + (x - h) * h; long long high = x - h - 1; long long t1 = high / 2, t2 = high - t1...
#include <bits/stdc++.h> using namespace std; const int maxn = 4000010, maxm = 2010; long long s[maxn], f[maxn], P[maxm], Q[maxm]; int a, b, c, p[maxm], vis[maxm], mu[maxm]; void inc(long long &a, long long b) { a += b; if (a > (1ll << 30)) a -= (1ll << 30); } int main() { scanf( %d%d%d , &a, ...
//----------------------------------------------------------------------------- // (c) Copyright 2012 - 2013 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 proper...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////////////// // Company: Digilent Inc. // Engineer: Andrew Skreen // // Create Date: 08/16/2011 // Module Name: display_clk // Project Name: PmodGYRO_Demo // Target Devices: Nexys3 // Tool versions: ISE 14.1 // ...
// ------------------------------------------------------------- // // File Name: hdl_prj\hdlsrc\controllerPeripheralHdlAdi\velocityControlHdl\velocityControlHdl_Clamp.v // Created: 2014-08-25 21:11:09 // // Generated by MATLAB 8.2 and HDL Coder 3.3 // // -------------------------------------------------------------...
/* * Redistributions of any form whatsoever must retain and/or include the * following acknowledgment, notices and disclaimer: * * This product includes software developed by Carnegie Mellon University. * * Copyright (c) 2004 by Babak Falsafi and James Hoe, * Computer Architecture Lab at Carnegie Mellon (CALCM)...
`timescale 1ns / 100ps module QMFIR_uart_top(/*AUTOARG*/ // Outputs uart_tx, // Inputs uart_rx, clk, arst_n ); output uart_tx; input uart_rx; input clk; input arst_n; wire arst_n; wire [15:0] MEMDAT; /*AUTOWIRE*/ // Beginning of automatic wi...
`timescale 1ns / 1ps `define READ 2'b01 `define WRITE 2'b10 `define DO_NOTHING 2'b00 `define INVALID 2'b11 `define DATA_VALID 1'b1 `define DATA_INVALID 1'b0 `define FIFO_FULL 1'b1 `define FIFO_NOT_FULL 1'b0 `define FIFO_EMPTY 1'b1 `define FIFO_NOT_EMPTY 1'b0 `define LOG2(width) (width<=2)?1:\ (widt...
`timescale 1ns / 1ps module ConcatenadorNumeros #( parameter stateA = 5'b00001, //cargando datos en fifo parameter stateB = 5'b00010, //calculando datos parameter stateC = 5'b00100, //devuelvo parameter stateD = 5'b01000, //reseteo parameter stateE = 5'b10000) (input clk, input reset, input [7:0] da...
#include <bits/stdc++.h> using namespace std; void solve() { long long ans = 0; long long a, b, c, s; cin >> s >> a >> b >> c; ans = s / c + (s / c / a) * b; cout << ans << endl; } int main() { int T; cin >> T; while (T--) solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int k, n; cin >> n >> k; int x[n]; for (int i = 0; i < n; i++) { cin >> x[i]; } double m = -1, sum = 0; int c = 0; for (int i = 0; i < n; i++) { for (int j = i...
#include <bits/stdc++.h> using namespace std; long long a[100005], b[100005]; const long long INF = 1000000009; int main() { int n, x, y; cin >> n >> x >> y; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) b[i] = INF; for (int i = 0; i < n; i++) for (int j = i - y;...
#include <bits/stdc++.h> using namespace std; int b[1002][1002] = {0}; int main() { int a[8][3] = {{7, 3, 5}, {2, 6, 4}, {1, 5, 7}, {0, 4, 6}, {3, 7, 1}, {0, 2, 6}, {1, 3, 5}, {0, 2, 4}}; int x[8]; int y[8]; int d[8]; int n; int m; int tmpx, tmpy; int sum = 0; ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; using pii = pair<int, int>; using C = complex<double>; const double PI = 3.14159265; const double eps = 1e-8; const int N = 1 << 17; const int M = 1e9 + 7; const int inf = 1e...
#include <iostream> #include <cmath> using namespace std; int main() { int t; cin >> t; while(t--) { int xa, ya, xb, yb, xf, yf; cin >> xa >> ya >> xb >> yb >> xf >> yf; if(xa==xb && xb==xf && yf > ya && yf < yb) ...
#include <bits/stdc++.h> using namespace std; int main() { int m, n, count = 0, count1 = 0, x = 0; cin >> m >> n; int a[m][n], b[m][n]; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { cin >> b[i][j]; a[i][j] = 1; } } for (int i = 0; i < m; i++) { ...
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 5; char a[N], b[N]; int main() { int n, k; cin >> n >> k; scanf( %s %s , a + 1, b + 1); long long ans = 0, t = 1; for (int i = 1; i <= n; ++i) { t = t * 2; if (b[i] == a ) t--; if (a[i] == b ) t--; if...
//================================================================================================== // Filename : subRecursiveKOA.v // Created On : 2016-10-27 23:29:14 // Last Modified : 2016-10-31 11:41:29 // Revision : // Author : Jorge Esteban Sequeira Rojas // Company : Instituto T...
#include <bits/stdc++.h> using namespace std; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long n, m, k, t, mx; cin >> t; while (t--) { cin >> n >> m >> k; mx = min(n / k, m); cout << (m >= mx ? mx - ceil((long double)(m - mx) / (k - 1)) : m...
#include <bits/stdc++.h> using namespace std; const int maxN = 50000 + 10; int n; int B[maxN]; vector<pair<int, int>> VB; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , &B[i]); for (int i = 0; i < n; i++) { VB.push_back(make_pair(B[i] + B[(i + 1) % n], i)); } ...
#include <bits/stdc++.h> using namespace std; int n, m, k; int X1[127], X2[128], Y1[111], Y2[105]; bool u[134][134]; vector<int> res; int check(int xx1, int yy1, int x2, int y2) { if (x2 < 0 || y2 < 0 || x2 >= n || y2 >= m || u[x2][y2]) return 0; if (xx1 > x2) swap(xx1, x2); if (yy1 > y2) swap(y...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2017.4 // Copyright (C) 1986-2017 Xilinx, Inc. All Rights Reserved. // // ============================================================== `timescale 1 ns / 1 ...
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; long long gcd(long long x, long long y) { if (x > y) swap(x, y); if (x == 0) return y; if (y % x == 0) return x; return gcd(y % x, x); } int main() { long long n, k, t; long long m, d, w, g; long long x, y, z;...
#include <bits/stdc++.h> using namespace std; const long long B = 360; const long long N = 100005; long long block(long long x) { return x / B; } long long offset(long long x) { return x % B; } deque<long long> a[B]; signed c[B][N]; long long n, q; signed main() { ios::sync_with_stdio(false); ...
#include <bits/stdc++.h> using namespace std; char ss[100010]; string s; string s1; pair<int, int> b[2000000]; int m[100100]; unsigned long long h[100100]; unsigned long long p[100100]; int main() { scanf( %s , &ss); s = (string)ss; h[0] = 0; p[0] = 1; for (int i = (1); i < (100100...
#include <bits/stdc++.h> constexpr int Maxn = 1e5 + 7; constexpr int Mod = 1e9 + 7; int fac[Maxn], ifac[Maxn]; inline int fpm(int a, int b) { int res = 1; while (b) { if (b & 1) res = 1LL * res * a % Mod; a = 1LL * a * a % Mod; b >>= 1; } return res; } inline int C(int n, 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...
#include <bits/stdc++.h> using namespace std; int N, M; int A[200], B[200], D[200]; map<int, vector<int>> MM; set<int> S; struct mat { signed long long v[150][3] = {}; }; struct vec { signed long long v[3] = {}; }; void print(mat a, int n) { int x, y; for (x = 0; x < n; 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...
/** * 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 <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n; cin >> n; long long a[n]; for (long long i = 0; i < n; i++) cin >> a[i]; long long ans = 0; for (long long i = n - 1; i >= 0; i--) { if (i == n - 1) ...
// $Id: c_fp_arbiter.v 1625 2009-10-29 00:15:03Z dub $ /* Copyright (c) 2007-2009, Trustees of The Leland Stanford Junior University All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of s...
#include <bits/stdc++.h> using namespace std; template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; ...
#include <bits/stdc++.h> using namespace std; const int maxn = 5e6; int a[maxn], ans; int main() { ios_base::sync_with_stdio(0); int n; cin >> n; while (n--) { int tmp; cin >> tmp; a[tmp]++; } for (int i = 0; i < maxn; i++) { a[i + 1] += a[i] / 2; ans += a[i...
#include <bits/stdc++.h> using namespace std; const long long oo = 1e18; struct dta { int u, id; dta(int _u = 0, int _id = 0) { u = _u; id = _id; } }; struct TDij { long long val; int x; TDij(long long _val = 0, int _x = 0) { x = _x; val = _val; } }; inl...
// File name : UniversalCounter.v // Written by : Jianjian Song // 4-bit universal bidirectional counter `timescale 1ns / 1ps module ClockedPositiveOneShot(InputPulse, OneShot, Reset, CLOCK) ; input InputPulse, Reset, CLOCK; output reg OneShot; parameter State0=0, State1=1, State2=2, State3=3; reg [1:0] State; alwa...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; const int M = 1000005; const int nmax = 500010; const int MOD = (1e9) + 7; int nextX[] = {1, -1, 0, 0}; int nextY[] = {0, 0, 1, -1}; int n, m, t; int f[1010][1010]; char s[1010][1010]; bool good(int x, int y) { return (x >...
module test(); localparam size1 = 4; localparam size2 = 6; localparam size3 = 8; localparam [5:0] value1 = 6'h3f; localparam signed [5:0] value2 = 6'h3f; reg [31:0] result; reg failed = 0; initial begin result = size1'(value1) + 'd0; $display("%h", result); if (result !== 32'h0000000f) failed = 1; ...
#include <bits/stdc++.h> using namespace std; inline int read() { int s = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) s = (s << 3) + (s << 1) + ch - 0 , ch = getchar(); return s * f; ...
#include <bits/stdc++.h> int s, i, e; int main() { int t; scanf( %d , &t); while (t--) { int ans = 0; scanf( %d%d%d , &s, &i, &e); if (s > i + e) { printf( %d n , e + 1); } else if (s + e <= i) { printf( %d n , 0); } else { int k = e - (i + e - s) / ...
/* Distributed under the MIT license. Copyright (c) 2015 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 the rights to use, copy, mo...
/* * Copyright 2017 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to...
//############################################################################ //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // (C) Copyright Laboratory System Integration and Silicon Implementation // All Right Reserved //++++++++++++++++++++++++++++++++++++++++++++++++++++++++...
#include<bits/stdc++.h> #define ll long long int using namespace std; int main() { int t; cin>>t; while(t--) { ll a, b, c; cin>>a>>b>>c; if((a+b+c)%9 == 0 && min(a, min(b,c)) >= (a+b+c)/9) cout<< YES <<endl; else cout<< NO <<endl; } }
#include <bits/stdc++.h> using namespace std; int main() { size_t n, w, m; ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr), cin >> n >> w >> m; struct bottle_t { size_t amount, id; } bottle, poured; stack<bottle_t> bottles, non_empty; vector<bottle_t> cup[...
#include <bits/stdc++.h> using namespace std; struct node { int u, s; node() { u = s = 0; } bool operator<(const node &temp) const { if (this->s < temp.s) return 1; return 0; } }; node black[100005]; node white[100005]; vector<vector<node> > adj; int main() { int n; sca...
/** * 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 N = 1e10; void solve() { long long n, c; cin >> n >> c; long long a[n], b[n]; for (long long i = 0; i < n; i++) { cin >> a[i] >> b[i]; } long long low = -1, high = -1; for (long long i = 1; i <= 100000; i++) { lo...
#include <bits/stdc++.h> using namespace std; int main() { int n, a[1000]; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } long int answer = 0; for (int i = 0; i < (n - 1); i++) { if (a[i] == 1 && a[i + 1] == 2) { answer += 3; } else if (a[i] == 1 && a[i + 1]...
#include <bits/stdc++.h> using namespace std; vector<int> v; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long n; cin >> n; int flag = 0; int m; cin >> m; long long a[m]; for (int i = 0; i < m; i++) { cin >> a[i]; } sort(a, a + m);...
#include <bits/stdc++.h> using namespace std; const int Max = 2e5 + 10; vector<int> A; int ok[Max]; int len; int seg[Max * 4]; int lazy[Max * 4]; void build(int tl = 0, int tr = len + 1, int idx = 1) { if (tr - tl == 1) { seg[idx] = len - tl; return; } int mid = (tl + tr) / 2; ...
// megafunction wizard: %LPM_FF% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: lpm_ff // ============================================================ // File Name: lpm_ff_v1.v // Megafunction Name(s): // lpm_ff // // Simulation Library Files(s): // lpm // =====================================...
#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; ...
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; int a[1005]; int main() { int x, y, n; cin >> x >> y; int a[10] = {-x, -y, x - y, x, y, y - x}; cin >> n; int ans = (n + 2) % 6; a[ans] %= mod; if (a[ans] < 0) a[ans] += mod; cout << a[ans] << endl; ret...
// ------------------------------------------------------------- // // Generated Architecture Declaration for rtl of inst_t_e // // Generated // by: wig // on: Wed Jun 7 16:54:20 2006 // cmd: /cygdrive/h/work/eclipse/MIX/mix_0.pl -nodelta -bak ../../bitsplice.xls // // !!! Do not edit this file! Autogenerated by ...
#include <bits/stdc++.h> using namespace std; const long long MOD = 998244353; long long inv[5050 + 10], fac[5050 + 10], ifac[5050 + 10]; void setComb() { inv[0] = 1; inv[1] = 1; fac[1] = 1; ifac[1] = 1; fac[0] = 1; ifac[0] = 1; for (int i = 2; i < 5050; i++) { inv[i] = (-MOD /...
#include <bits/stdc++.h> using namespace std; string months[] = { January , February , March , April , May , June , July , August , September , October , November , December }; int main() { string x; int k; cin >> x >> k; int...
// (C) 2001-2016 Intel Corporation. All rights reserved. // Your use of Intel 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 docum...