text
stringlengths
59
71.4k
/********************************************/ /* sync_fifo.v */ /* simple single-clock fifo */ /* */ /* 2011, */ /********************************************/ module sync_fifo #( parameter FD = 16, ...
#include <bits/stdc++.h> using namespace std; const int fx[8] = {0, -1, -1, -1, 0, 1, 1, 1}; const int fy[8] = {1, 1, 0, -1, -1, -1, 0, 1}; const int maxn = 310; int vis[maxn][maxn][8][30]; int v[maxn][maxn]; int step[40]; queue<pair<int, int> > q; pair<int, int> mkstate(int x, int y, int d, int t) { ...
#include <bits/stdc++.h> using namespace std; int x, cnt; vector<int> rj; bool good(int n) { bool t = false; for (int i = 20; i >= 0; i--) { if (n & (1 << i)) t = true; if (t && !(n & (1 << i))) return false; } return true; } int fix(int n) { bool t = false; for (int i = ...
#include <bits/stdc++.h> using namespace std; const int INF = 1029384756; const double PI = acos(-1); const double EPS = 0.0000000304; long long A, B, C; int main() { scanf( %I64d%I64d%I64d , &A, &B, &C); if ((A % 2) == (B % 2) && (B % 2) == (C % 2)) { printf( %I64d , A + B + C - max(A, max(B,...
#include <bits/stdc++.h> using namespace std; const int maxn = (1e9) + 7; bool mark[2501][101]; long long a[2501][101]; long long dp(int x, int y) { if (x > 0 && y == 0) return 0; if (x == 0 && y == 0) return 1; if (mark[x][y]) return a[x][y]; long long ans = 0; for (int i = 0; i <= min(25...
#include <bits/stdc++.h> using namespace std; long long a[3000005], has[3000005], visited[2000005], dist[1000005]; long long pr[3000010]; long long addmod(long long n, long long m) { return ((n % 1000000007) + (m % 1000000007)) % 1000000007; } long long multmod(long long n, long long m) { return ((n...
#include <bits/stdc++.h> using namespace std; const long long int inf = 9e18; const long double pi = 2 * acos(0.0); long long int arr[100005]; void solve() { long long int n, k; cin >> n >> k; ; for (int i = 0; i < n; i++) cin >> arr[i]; ; long long int mn = inf, pos = 0; for (long...
#include <bits/stdc++.h> using namespace std; vector<int> e[200010]; struct Node { int sz, l; } c[200010]; bool cmp(const Node &p, const Node &q) { return (p.sz - p.l) > (q.sz - q.l); } void dfs(int x, int fa) { c[x].l = c[fa].l + 1; for (int i = 0; i < (int)e[x].size(); i++) { int y = e[x...
#include <bits/stdc++.h> using namespace std; int q, n; int a[100010], b[100010]; int main() { scanf( %d , &q); while (q--) { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); for (int i = 1; i <= n; i++) scanf( %d , &b[i]); int pos = 0, dis = 0, flag1 = 0, flag2 ...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Mon Jan 23 19:11:23 MST 2017 // Date : Wed May 03 18:20:15 2017 // Host : LAPTOP-IQ9G3D1I running 64-bit major releas...
/** * ------------------------------------------------------------ * Copyright (c) All rights reserved * SiLab, Institute of Physics, University of Bonn * ------------------------------------------------------------ */ `timescale 1ps/1ps `default_nettype none module fx2_to_bus #( parameter ...
#include <bits/stdc++.h> using namespace std; int main() { int n, n1, n2; scanf( %d%d%d , &n, &n1, &n2); if (n1 > n2) swap(n1, n2); vector<double> X; double x; for (int i = 0; i < n; i++) { scanf( %lf , &x); X.push_back(x); } sort(X.begin(), X.end()); double sum1 = 0,...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int p = 0; p < t; ++p) { int n; cin >> n; int d[2][n]; for (int i = 0; i <= 1; ++i) { for (int j = 0; j < n; ++j) cin >> d[i][j]; } if (n == 1) cout << 0 << endl; el...
#include <bits/stdc++.h> using namespace std; int read() { int x = 0, f = 1; char c = getchar(); while (c < 0 or c > 9 ) { if (c == - ) f = -f; c = getchar(); } while (c >= 0 and c <= 9 ) { x = x * 10 + c - 0 ; c = getchar(); } return x * f; } struct E...
#include <bits/stdc++.h> using namespace std; double pi = 4 * atan(1.0); double eps = 1e-9; string stringmin = ! ; string stringmax = ~ ; int main() { cout.precision(14); int n; cin >> n; vector<int> v(n), vlen(n); for (auto &i1 : v) cin >> i1; for (int i = 0; i < n; i++) { i...
#include <bits/stdc++.h> using namespace std; long long max(long long a, long long b) { if (a > b) return a; else return b; } long long min(long long a, long long b) { if (a < b) return a; else return b; } long long gcd(long long a, long long b) { return b ? gcd(b, 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 long long mod = 998244353; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; long long k; cin >> n >> k; if (!k) { cout << 0 n ; return 0; } vector<int> h(n); for (int i = 0; i < n; i++...
module Mod_Teste( input CLOCK_27, input CLOCK_50, input [3:0] KEY, input [17:0] SW, output [6:0] HEX0, output [6:0] HEX1, output [6:0] HEX2, output [6:0] HEX3, output [6:0] HEX4, output [6:0] HEX5, output [6:0] HEX6, output [6:0] HEX7, output [8:0] LEDG, output [17:0] LEDR, output LCD_ON, // LCD Power...
#include <bits/stdc++.h> using namespace std; const int mo = 1000000007; char S[2005], A[2][2005]; int ans, n, m, P[2][2005][2005], Q[2][2005][2005]; long long H[2005], w[2][2005], W[2005], N[2005]; bool IS(int u, int p, int q, int l, int r) { return (w[u][q] - w[u][p - 1]) * H[2000 - p] == (...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 22:20:53 02/28/2016 // Design Name: // Module Name: sequencDetector // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies...
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; long double PI = 4 * atan(1); int n, r, val[2001], x, flag, ch[2001]; bool isChild[2001][2001]; pair<int, int> p[2001]; vector<int> v[2001]; queue<int> q1, q2, ans; void solve(int i) { int rem = ch[i] - p[i].second; whil...
#include <bits/stdc++.h> using namespace std; map<long long, long long> mp[12]; long long a[200005], dig[200005]; long long state[200005][12]; int main() { long long n, k; scanf( %lld %lld , &n, &k); for (int i = 0; i < n; i++) scanf( %lld , &a[i]); for (int i = 0; i < n; i++) { dig[i] =...
#include <bits/stdc++.h> using namespace std; string to_string(bool b) { return (b ? true : false ); } template <size_t N> string to_string(bitset<N> v) { string res = ; for (size_t i = 0; i < N; i++) { res += static_cast<char>( 0 + v[i]); } return res; } template <typename A> ...
#include <bits/stdc++.h> using namespace std; string imp = Impossible n ; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); clock_t startTime; double getCurrentTime() { return (double)(clock() - startTime) / CLOCKS_PER_SEC; } const int N = 1e5 + 1e3; long long MOD = 1e9 + 7; ...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:134217728 ) using namespace std; const long long MOD = 1000000000 + 7; const long long MAGIC = 123123123; const double PI = 4 * atan(1.); const double EPS = 1E-7; void time_elapsed() { cout << nTIME ELAPSED: << (double)clock() / CLOCKS_PER_S...
#include <bits/stdc++.h> using namespace std; int n, y, a[(int)1e5 + 4]; unsigned long long x, sum; void error() { puts( -1 ); exit(0); } int main() { scanf( %d%I64d%d , &n, &x, &y); sum = (unsigned long long)n; if (n > y || (n == y && sum < x)) error(); for (int i = 0; i < n; i++) a...
#include <bits/stdc++.h> using namespace std; long long ans; long long arr[300005][8]; long long a, b; bool ok(long long mid, long long n, long long m) { long long mx = (1LL << m) - 1; long long cnt[mx + 1]; for (int i = 0; i <= mx; i++) cnt[i] = 0; for (int i = 0; i < n; i++) { long lon...
//============================================================================== // File: $URL: svn+ssh:///public/Projects/GateLib/branches/dev/Publications/Tutorials/Publications/EECS150/Labs/ChipScopeSerial/Framework/Counter.v $ // Version: $Revision: 26904 $ // Author: Greg Gibeling (http://www.gdgib.com) // Copyr...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[1001]; int b[1001] = {0}; for (int i = 0; i < n; i++) { cin >> a[i]; b[a[i]] = 1; } sort(a, a + n); int ans = 0; int sum = a[n - 1] - a[0] + 1; cout << sum - n << endl; return 0;...
#include <bits/stdc++.h> using namespace std; long long dp[5005][5005]; long long solve(long long x, long long y) { if (x == 0 || y == 0) return 1; if (dp[x][y] == 0) dp[x][y] = (solve(x - 1, y - 1) * y + solve(x - 1, y)) % 998244353; return dp[x][y]; } int main() { long long n, m, k; ...
////////////////////////////////////////////////////////////////////// //// //// //// OR1200's WISHBONE BIU //// //// //// //// This file is part of the OpenR...
// -- (c) Copyright 2010 - 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 disclaimer is not a...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, m; cin >> n >> m; long long int a[n], k = 0, sum = 0; for (int x = 0; x < n; x++) { cin >> a[x]; } sort(a, a + n); for (int x = 0; x < m; x++) { if (a[x] < 0) { sum += a[x]; } } ...
// 8N1 UART Module, transmit only module uart_tx_8n1 ( clk, // input clock txbyte, // outgoing byte senddata, // trigger tx txdone, // outgoing byte sent tx, // tx wire ); /* Inputs */ input clk; input[7:0] txbyte; input senddata; /* Outputs */ ...
/** * 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 double PI = acos(-1.0); const int maxn = 1e5 + 5; const int Inf = 1e9 + 7; int main() { int a, b; while (cin >> a >> b) { if (a == 0 && b == 0) { printf( NO n ); } else if (abs(a - b) <= 1) { printf( YES n ); } else ...
/* 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,...
/* * 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 long long MAX = 5005; vector<long long> arr(MAX); long long solve(long long l, long long r, long long cur) { if (l > r) return 0; long long mn = arr[l], idx = l; for (int i = l; i <= r; i++) { if (arr[i] < mn) { mn = arr[i]; i...
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 7; const int maxn = 1e4 + 5; int n, b, q; int a[maxn], c[maxn]; inline int f(int x, int j) { return (x / 5) + (x % 5 >= j); } inline int calc(int j, int l, int r) { return f(r, j) - f(l - 1, j); } int main() { scanf( %d%d%d , &n, &b...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2014.4 // Copyright (C) 2014 Xilinx Inc. All rights reserved. // // ============================================================== `timescale 1 ns / 1 ps m...
#include <bits/stdc++.h> using namespace std; template <typename T> inline bool chkmin(T &x, T y) { return x > y ? x = y, 1 : 0; } template <typename T> inline bool chkmax(T &x, T y) { return x < y ? x = y, 1 : 0; } inline void read(int &x) { char ch = getchar(); int f = 1; x = 0; ...
#include <bits/stdc++.h> using namespace std; int main() { long long int k; cin >> k; if (k > 36) cout << -1; else { for (int i = 0; i < k / 2; i++) cout << 8; if (k % 2) cout << 4; } }
`timescale 1 ns / 1 ps // This component will be given the number of rows, and the size of each row // (assume each row is the same size). With this information it will request // all rows, and filter out the column of interest. module filter_rows ( input clk, input rst, outpu...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 1; long long a[N]; int main() { ios_base::sync_with_stdio(0); int n; cin >> n; priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> q; for (int i = 1; i <...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int ans = 0; for (int i = 0; i < s.size(); i++) { if (((s[i] - 0 ) % 2) == 0) { ans = ans + i + 1; } } cout << ans; }
//----------------------------------------------------------------------------- // // (c) Copyright 2010-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 ...
/* * 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 Header Begin ========================================== // // OpenSPARC T1 Processor File: bw_clk_gclk_inv_192x.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...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 1; int mark[N], t[N], n; long long res; int main() { ios::sync_with_stdio(0); cin.tie(0); ; cin >> n; for (int i = (1); i <= (n); i += (1)) cin >> mark[i]; int cur = 0; for (int i = (n); i >= (1); i -= (1)) { c...
#include <bits/stdc++.h> using namespace std; long long int power(long long int a, long long int b) { long long int ans = 1; while (b) { if (b & 1) { ans = ((ans % 1000000007) * (a % 1000000007)) % 1000000007; } a = ((a % 1000000007) * (a % 1000000007)) % 1000000007; b = b >>...
// FSM top module, for text only // FSM controlled by button purely // test about text displaying module game_text_top ( input wire clk, reset, input wire [1:0] btn, // we use the button now to control the FSM output wire hsync, vsync, output wire [2:0] rgb ); // symbolic state declarati...
//+FHDR------------------------------------------------------------------------ //Copyright (c) 2013 Latin Group American Integhrated Circuit, Inc. All rights reserved //GLADIC Open Source RTL //----------------------------------------------------------------------------- //FILE NAME : //DEPARTMENT : IC Design / Veri...
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k, a, b, c, n, t, f, d; string s, v; map<char, int> ma, sa; vector<int> vv; map<char, int>::iterator it, ki; cin >> s; f = 0; c = 0; for (j = 0; j < s.size(); j++) { if ((s[j] >= A && s[j] <= Z )) { ...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:268435456 ) using namespace std; const string IN_NAME = input.txt ; const string OUT_NAME = output.txt ; template <class T> T abs(T &x) { return ((x) >= 0) ? (x) : (-(x)); } template <class T> T sqr(T &x) { return (x) * (x); } temp...
#include <bits/stdc++.h> using namespace std; int main() { string str; cin >> str; if (str[0] > 96) { str[0] -= 32; } cout << str << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int inf = INT_MAX, df = 8e5 + 7; int i, j, k = 1, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, le[df], rig[df], c[df][26], ma[df << 1], head[df], pos[df << 1], tot, ans[df], fail[df], cnt, yet[df][26]; struct node { int sum, id; }...
//Legal Notice: (C)2017 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 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 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) 2016 C-L-G.FPGA1988.lichangbeiju. All rights reserved----------------- // // -- It to be define -- // -- ...
/** * 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; const long long mod = 1e9 + 7; int n; int fa[1000005], huan[1000005], zihuan[1000005], siz[1000005]; int find(int now) { return fa[now] == now ? now : fa[now] = find(fa[now]); } int main() { scanf( %d , &n); for (int i = 1; i <= 2 * n; i++) { fa[i]...
#include <bits/stdc++.h> using namespace std; int Rand(int x) { return rand() * rand() % x + 1; } const int INF = 0x3f3f3f3f, N = 5000005, M = 2000005, MOD = 1e9 + 7; long long qpow(long long a, long long b) { long long ret = 1; for (; b; b >>= 1, a = a * a % MOD) if (b & 1) ret = ret * a % MOD; ...
#include <bits/stdc++.h> using namespace std; const long long MAXN = 2e6; long long cnt[MAXN]; signed main() { long long n, m, k; ios_base::sync_with_stdio(false); cin >> n >> m >> k; vector<long long> f(n); vector<pair<long long, long long> > s(m); for (long long i = 0; i < n; i++) cin ...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int M = 1e9 + 7; void madd(int& a, int b) { a += b; if (a >= M) a -= M; } int mult(int a, int b) { return (1LL * a * b) % M; } int modexp(int a, int b) { int res = 1; while (b > 0) { if (b & 1) res = mult(res, ...
//***************************************************************************** // (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 property /...
module pulse_senor_read(clk,reset_n,chipselect,address,write,writedata,read,byteenable,readdata,pulse_in); // this module is used to read the lacation senor and angle senor in inverted pendulum application // pulse_in[0] connected to A port //Gang Chen @ Fortiss Fb2 input clk; input reset_n; input chipselect; input ...
#include <bits/stdc++.h> using namespace std; vector<int> v[27]; bool vis[27]; vector<pair<int, int> > pr; int cnt, flag; void dfs(int nod, int dest) { int i; vis[nod] = 1; if (nod == dest) { flag = 1; return; } for (i = 0; i < v[nod].size(); i++) { int curr = v[nod][i]...
#include <bits/stdc++.h> using namespace std; const long long INF = (1ll << 60); const int N = 205; int n, m, _len; int nxt[N]; long long k; long long ADD(long long x, long long y) { return min(INF, x + y); } struct node { char pref[N]; char suff[N]; long long len; long long sum; } t[N...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; vector<string> ans; string email = ; bool isPoss = true; for (int i = 0; i < s.length(); i++) { if (s[i] == @ ) { if ((i + 1 < s.length()) && (s[i + 1] != @ )) { if (email == ) { ...
#include <bits/stdc++.h> using namespace std; const int MAX = 109; int a[MAX], n, k, t = 1e9, s; int main() { cin >> n; for (int i = 0; i < 2 * n - 1; i++) { cin >> a[i], s += abs(a[i]), t = min(t, abs(a[i])); if (a[i] < 0) k++; } if (k % 2 && n % 2 == 0) s -= 2 * t; cout << s; ...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 21:13:58 05/20/2014 // Design Name: Single_Cycle_CPU // Module Name: C:/Users/Deus/Windows Sync/Xilinx Workspace/Single/test_t.v // Project Name: Single //...
#include <bits/stdc++.h> using namespace std; const int inf = 1e9 + 7; struct node { int x, d; }; vector<int> adj[100005]; vector<int> good[105]; int vis[100005]; int a[100005]; int d[100005][105]; void bfs(int s) { queue<node> q; for (int i = 0; i < good[s].size(); i++) { int v = ...
/* * 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; using lli = long long int; using pii = pair<int, int>; using vi = vector<int>; using vb = vector<bool>; using vvi = vector<vector<int>>; using vlli = vector<long long int>; using vpii = vector<pair<int, int>>; lli n, m, k, u, v, x, ans, curr, T; vlli c; ...
#include <bits/stdc++.h> using namespace std; int n, m, u, v, cnt, ans; int t[1100000], nxt[1100000], to[1100000]; int a[1100000], b[1100000], c[1100000], f[1100000]; int vis[1100000]; void add(int u, int v) { nxt[cnt] = t[u], t[u] = cnt, to[cnt++] = v; } void dfs(int x) { vis[x] = true; for (int ...
#include <bits/stdc++.h> using namespace std; const int maxn = 150000; int b[maxn]; long long a[maxn]; int main(void) { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &b[i]); b[0] = b[n]; int id = 0; for (int i = 1; i <= n; i++) if (b[i] > b[i - 1]) { id...
#include <bits/stdc++.h> using namespace std; struct pr { int a, b, n, x; pr(int a, int b, int n) : a(a), b(b), n(n) {} pr() : a(0), b(0), n(-1) {} }; int n, m; vector<pr> a, b; void connect(int x1, int& x2, int& y2) { if ((x2 != -1 && x2 != x1) || (y2 != -1 && y2 != x1)) { cout << -1;...
//Legal Notice: (C)2015 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; int n, m; int main() { scanf( %d%d , &n, &m); if (n == 1 && m == 2) { printf( 0 n1 1 n1 2 n1 1 n ); return 0; } if (n == 2 && m == 1) { printf( 0 n1 1 n2 1 n1 1 n ); return 0; } if (n * m % 2 == 1 || n == 1 || m == 1) { ...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: jbi_min_wrtrk.v // Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. // // The above named program is free software; you can redistribute it and...
/* * 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...
/** * 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 q; cin >> q; for (int i = 0; i < q; i++) { int n, r; cin >> n >> r; int arr[n]; for (int j = 0; j < n; j++) { cin >> arr[j]; } sort(arr, arr + n); int shots = 0, act[n], p = 0; act[0] =...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 12:52:27 05/20/2015 // Design Name: // Module Name: cpu_fpga // Project Name: // Target Devices: // Tool versions: // Description: // // Depend...
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; const int iinf = INT_MAX; const long long linf = 2e18; const double dinf = 1e30; const int MOD = 1000000007; inline int read() { int X = 0, w = 0; char ch = 0; while (!isdigit(ch)) { w |= ch == - ; ch = getchar...
#include <bits/stdc++.h> int n, m, l, x, oo = 1000000007, c[100005], a[100005], b[100005]; long long res = 1, ans; long long Exp(long long x, long long y) { long long res = 1; for (; y; y >>= 1, x = x * x % oo) if (y & 1) res = res * x % oo; return res; } int main() { scanf( %d , &n); ...
#include <bits/stdc++.h> using namespace std; int sum = 0; vector<vector<int>> mat; vector<string> mat2; void f1(vector<string>& ans, int f, string s) { if (f == 0) return; string s1 = to_string(f) + + s; ans.push_back(s1); sum += f * s.length(); vector<int> temp(2, 0); temp[0] = f...
#include <bits/stdc++.h> using namespace std; int l[1000000]; int one_line[5001][5001] = {0}; int summ[5001][5001] = {0}; int fac[5001]; int main() { int n, m, p; scanf( %d %d %d , &n, &m, &p); for (int i = 0; i < n; i++) scanf( %d , &l[i]); fac[0] = 1; for (int i = 1; i <= 5000; i++) fa...
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k, m, n, a = 0, b = 0; cin >> n >> m; k = n; k = k / 9; n = n % 9; if (n != 0) k++; for (i = 0; i < k; i++) cout << 54; cout << endl; for (i = 0; i < k - 1; i++) cout << 45; cout << 46; cout << endl; ...
#include <bits/stdc++.h> using namespace std; struct node { int r, c, p; node() {} node(int _r, int _c, int _p) { r = _r, c = _c, p = _p; } }; const int MAXN = 1005; char g[MAXN][MAXN]; int dist[MAXN][MAXN]; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int to_int(const char& c) { re...
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, sum = 0; vector<long long> A; int n; cin >> n; A.resize(n); for (int i = 0; i < n; i++) { cin >> a; sum += a; A[i] = sum; } b = sum / 2 + (sum % 2); a = 0; while (A[a] < b) a++; c...
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; while (t-- > 0) { long long int n, k, can = 0; cin >> n >> k; can += n / k; can = can * k; if (can < n) { if (n - can < k / 2) can += n - can; else can ...
#include <bits/stdc++.h> using namespace std; int main() { int q; cin >> q; while (q--) { long long x[3]; cin >> x[0] >> x[1] >> x[2]; sort(x, x + 3); x[2] -= x[1] - x[0]; cout << x[1] + x[2] / 2 << endl; } }
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: Adam LLC // Engineer: Adam Michael // // Create Date: 19:48:37 09/12/2015 // Design Name: SN74LS177Abehavior // Module Name: C:/Users/adam/Documents/GitHub/Lab1SN74LS177A/SN74LS177AAbsoluteTime.v // ...