text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; long long s; int main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; for (int x = 1; x <= n; x++) { int y = x + b - c; int z = x + a - d; int w = y + a - d; if (y <= n && z <= n && w <= n && y > 0 && z > 0 && w > 0) s++; }...
#include <bits/stdc++.h> using namespace std; const long long INFL = 1LL << 60; const int INF = 1 << 30; const long long MOD = 998244353; double EPS = 1e-10; vector<long long> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0}; vector<long long> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0}; void pres(double A) { printf( %.12lf...
//################ //# ------------ # //# NoName270805 # //# ------------ # //################ //#pragma GCC optimize( Ofast ) //#pragma GCC optimize( unroll-loops ) //#pragma GCC target( avx,avx2,fma ) //GNU G++17 7.3.0: No long long for faster code //GNU G++17 9.2.0 (64 bit, msys 2): Long long only...
#include <bits/stdc++.h> using namespace std; int main() { int n, x; scanf( %d%d , &n, &x); if (n == 1) { printf( YES n ); printf( %d n , x); } else if (n == 2) { if (x == 0) printf( NO n ); else { printf( YES n ); printf( 0 %d n , x); } } el...
#include <bits/stdc++.h> using namespace std; map<long long, long long> mp; int main() { long long k, i; cin >> k; string s; cin >> s; long long ans = 0, cnt = 0; long long n = s.length(); mp[0] = 1; for (i = 0; i < n; i++) { if (s[i] == 1 ) { cnt++; } if...
/*------------------------------------------------------------------------------ * This code was generated by Spiral Multiplier Block Generator, www.spiral.net * Copyright (c) 2006, Carnegie Mellon University * All rights reserved. * The code is distributed under a BSD style license * (see http://www.opensource.or...
#include <bits/stdc++.h> const int oo = 0x3f3f3f3f; const double PI = acos(-1.0); const double EPS = 1e-8; using namespace std; int read() { int d, f = 1; char c; while (!isdigit(c = getchar())) if (c == - ) f = -1; d = c ^ 0 ; while (isdigit(c = getchar())) d = (d * 10) + (c ^ 0 ...
#include <bits/stdc++.h> using namespace std; const int maxm = 1e6; int pre[maxm * 2 + 10]; bool a[maxm + 10]; int N; int main(int argc, const char* argv[]) { scanf( %d , &N); for (int i = 1; i <= N; i++) { int val; scanf( %d , &val); pre[val] = -1; a[val] = true; } i...
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 5; int sum[maxn], t, n, q, l, r; char s[maxn]; set<int> v[4 * maxn + 10]; int main() { scanf( %d , &t); while (t--) { sum[0] = 0; scanf( %d%d%s , &n, &q, (s + 1)); for (int i = 1; i <= n; i++) { sum[i] = s...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:60777216 ) using namespace std; int err; vector<char> best; vector<char> curr; int n, r; int it; void go(int pos, int f1, int f2, int errors) { if (err <= errors) return; if (pos == -1) { err = errors; best = curr; } else {...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); int q, n; cin >> q; while (q--) { cin >> n; vector<int> a(1 + n), answer(1 + n, 0); map<int, unordered_set<int> > m; vector<bool> vis(n + 1, false); for (int i = 1; i <= n; ++i) { ...
/* * This module accepts incoming data from PS2 interface * Copyright (C) 2010 Donna Polehn <> * * This file is part of the Zet processor. This processor is free * hardware; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software * Fou...
#include <bits/stdc++.h> using namespace std; int n, m, c; int a[1005]; bool check() { bool good = a[0] > 0; for (int i = 1; i < n; i++) good &= (a[i] > 0) && (a[i] >= a[i - 1]); return good; } int main() { cin >> n >> m >> c; for (int i = 0; i < n; i++) a[i] = 0; while (m--) { ...
#include <bits/stdc++.h> using namespace std; const long long mox = 1e6 + 9; long long ha[mox]; long long mod = 1e9 + 7; long long d[mox]; bool visit[mox]; long long ma[mox]; bool visit2[mox]; long long ta(long long a, long long b) { long long ans = 1; long long c = a; while (b) { if...
//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> bool chkmin(T &x, T y) { return x > y ? x = y, 1 : 0; } template <typename T> bool chkmax(T &x, T y) { return x < y ? x = y, 1 : 0; } int readint() { int x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ...
/** * 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 argc, char const *argv[]) { int n, a, b, ans = 0; cin >> n >> a >> b; if (b >= 0) { if (b >= n) { ans = b % n; ans += a; } else ans = a + b; if (ans > n) ans %= n; } else if (n == -b) { ans = 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 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...
// (C) 2001-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 doc...
#include <bits/stdc++.h> using namespace std; const int MN = 70; struct mat { long long T[MN][MN]; void O() { for (int i = 0; i < MN; i++) for (int j = 0; j < MN; j++) T[i][j] = 1e18; } }; mat mult(mat a, mat b) { mat ret; ret.O(); for (int i = 0; i < MN; i++) { for...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9 + 7; const int N = 3e5 + 10; class SegmentTree { public: long long addv[N * 4]; int ql, qr, qx; void set(int l, int r, int x = 0) { ql = l, qr = r, qx = x; } void add(int l, int r, int o = 1) { if (ql <= l && r <= q...
#include <bits/stdc++.h> using namespace std; int n, tot, d[105]; int read() { int _ = 0, ___ = 1; char __ = getchar(); while (__ > 9 || __ < 0 ) { if (__ == - ) ___ = -1; __ = getchar(); } while (__ >= 0 && __ <= 9 ) { _ = _ * 10 + __ - 0 ; __ = getchar(); ...
#include <bits/stdc++.h> using namespace std; int n, q, s, cntlog2[2050] = {0}; int main() { scanf( %d , &q); while (q--) { memset(cntlog2, 0, sizeof(cntlog2)); scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &s); if (s <= 2048) cntlog2[s]++; } for ...
`include "spi_master.v" `include "milisecond_timer.v" module oled_init ( input clk, input reset, input init_start, output reg init_fin, output spi_csn, output spi_sdo, output spi_sclk, output spi_dcn, // active=command mode, inactive=data mode output reg spi_resn...
`timescale 1ns / 1ps /* Copyright (C) 2016-2017, Stephen J. Leary All rights reserved. This file is part of TF530 (Terrible Fire 030 Accelerator). TF530 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; long long power(long long x, long long y, long long p) { long long res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } long long modulo(long long a, long long b) { ...
#include <bits/stdc++.h> using namespace std; const int N = 2222; const long long INF = 1e9 + 19; const int ALF = 26; int n; string s[N]; vector<vector<int>> nextS[N]; int m; int id[N]; string t; pair<int, int> dp[N][N]; vector<vector<int>> nextT; pair<int, int> nextG[N][ALF]; void read() { ...
#include <bits/stdc++.h> using namespace std; const int MAX_N = 20; int c[MAX_N], d[MAX_N], num[MAX_N]; int dp[MAX_N][MAX_N * 100]; int n, m, c0, d0, a, b; int main() { while (scanf( %d%d%d%d , &n, &m, &c0, &d0) != EOF) { for (int i = 1; i <= m; i++) { scanf( %d%d , &a, &b); num[i]...
/* -- ============================================================================ -- FILE NAME : if_stage.v -- DESCRIPTION : IFƒXƒe[ƒW -- ---------------------------------------------------------------------------- -- Revision Date Coding_by Comment -- 1.0.0 2011/06/27 suito V‹Kì¬ -- =============...
////////////////////////////////////////////////////////////////// // // // Generic Asynchronous FIFO // // // // This file is part of the Amber project ...
#include <bits/stdc++.h> inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } inline void sub(long long &a, long long b) { a -= b; if (a < 0) a += 1000000007; } inline void add(long long &a, long long b) { a += b; if (a >= 1000000007) a -= 1000000007; } template <...
#include <bits/stdc++.h> using namespace std; template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << ; cout << endl; } template <class T> void chmin(T &t, T f) { if (t > f) t = f; } template <class T> void chmax(T &t, T f) { if (t < f) t = f; } int in() ...
// megafunction wizard: %RAM: 1-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: icblbc_ram.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // =============================...
#include <bits/stdc++.h> using namespace std; struct Boot { int _pos; char _char; }; struct PairBoots { Boot _left; Boot _right; }; int main() { int n; string leftBoots; string rightBoots; vector<vector<Boot>> leftBootsBucket(27); vector<vector<Boot>> rightBootsBucket(27)...
/** * 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 N = 1e5 + 7; int a[N], n, q; long long sum[N << 2][11], mul[11] = {1}; long long SUM[11], LA[11]; int lazy[N << 2][11]; void pushup(int rt) { for (int i = 0; i < 10; ++i) { sum[rt][i] = sum[rt << 1][i] + sum[rt << 1 | 1][i]; } } voi...
/** * 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; double mas[10000][3]; void optim(int cnt, double Px, double Py, double Pz, double vs, double vp) { double l = 0, r = 0; double x1 = mas[cnt][0]; double y1 = mas[cnt][1]; double z1 = mas[cnt][2]; double x2 = mas[cnt + 1][0]; double y2 = mas[cnt ...
//`include"DataPath.v" //`include"Controller.v" module CPU(input clk,rst); wire[1:0] stackContrl,pcContrl; wire[5:0] cntrlInstruc; DataPath dp(clk,rst,RdOrR2,AluOrMem,RFWE,MWE,stackContrl,pcContrl,Zero,Cout,cntrlInstruc); Controller cntrl(clk,rst,RdOrR2,AluOrMem,RFWE,MWE,stackContrl,pcContrl,Zero,Cout,cntrlInstruc...
(* src = "../../verilog/extadc.v:1", top = 1 *) module ExtADC ( (* intersynth_port = "Reset_n_i", src = "../../verilog/extadc.v:3" *) input Reset_n_i, (* intersynth_port = "Clk_i", src = "../../verilog/extadc.v:5" *) input Clk_i, (* intersynth_conntype = "Bit", intersynth_port = "ReconfModuleIn_s", src = "../...
#include <bits/stdc++.h> using namespace std; const long long inf = 1e9 + 5; long long power(long long x, long long y) { long long res = 1; while (y > 0) { if (y & 1) res = res * x; y = y >> 1; x = x * x; } return res; } int32_t main() { ios_base::sync_with_stdio(false); ...
/** * 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...
module xxx_xxxxxx (input wire clk, input wire reset); typedef enum reg [4:0] {IDLE, IIII, HHHHH, AA_OP, AA_CMRD, AA_CMRD_WAIT, AA_RMW, AA_RMW_WAIT, AA_CMLLL, AA_CMLLL_WAIT, AA_NEXT, BB_OP, BB_CMLLL, BB_CMLLL_WAIT, BB_NEXT, CC_OP, CC_NEXT_OOOO, DD_OP, DD_CMRD, DD_CMRD_WAIT, DD_ACCUM, DD_...
#include <bits/stdc++.h> using namespace std; const int N = 100100; long long n, x; void printbin(long long a) { for (int i = 20; i >= 0; i--) { long long c = a & (1LL << i); cout << bool(c); } cout << n ; } int main() { cin >> n >> x; long long reversed = 0; reversed |...
#include <bits/stdc++.h> using namespace std; int n, k; pair<long long, long long> a[100007]; int r[100007]; int c[100007]; int used[100007]; long long ans = -1; bool cmp1(int x, int y) { return (a[x].first < a[y].first); } bool cmp2(int x, int y) { return (a[x].second < a[y].second); } void input()...
// Seven-segment display controller // Author: Ross MacArthur (https://github.com/rossmacarthur) // Description: // - Cycles through selecting each of the displays // - Outputs the corresponding display value for each display module SS_Control #(N = 4) ( input clk, // clock freq of about 750 Hz inp...
//----------------------------------------------------------------------------- // Copyright 2017 Damien Pretet ThotIP // Copyright 2018 Julius Baxter // // 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...
// Based on US Patent # 4,486,739 (expired) // Byte Oriented DC Balanced 8B/10B Partitioned Block Transmission Code // Author: Franaszek et al. // // https://patentimages.storage.googleapis.com/67/2d/ad/0258c2f0d807bf/US4486739.pdf // `include "bsg_defines.v" module bsg_8b10b_decode_comb ( input [9:0] data_i , ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 100, inf = 0x3f3f3f3f, mod = 1e9 + 7, M = 1e6 + 1000; const long long INF = 0x3f3f3f3f3f3f3f3f; long long sp(long long a, long long b, long long d) { if (!b) return 1; return b % 2 ? sp(a * a, b / 2, d) * a % d : sp(a * a, b / 2, d); } ...
module wait_time_module (reset, work, clk, wait_time); //counting the wait_time input clk,work,reset; output [11:0] wait_time; reg [11:0] wait_time; reg [5:0] i; always @ (posedge clk or negedge reset) begin if(!reset) begin wait_time <= 0; i <= 0; end else if (work == 0) begin //if(i >= 59) if(i >= ...
#include <bits/stdc++.h> using namespace std; int main() { int Tn; cin >> Tn; while (Tn--) { int n, x; cin >> n >> x; int mx = 0, flag = 0; while (n--) { int t; cin >> t; if (t == x) flag = 1; mx = max(mx, t); } if (!flag) print...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; const int MOD = 1e9 + 7; int m, d, L; int bit[2001]; long long dp[2001][2001]; void add(long long &x, long long y) { x = (x + y) % MOD; } long long DFS(int pos, int preyu, bool yes) { if (pos == L) return preyu == 0; if (!y...
#include <bits/stdc++.h> using namespace std; string i_str(int n) { char buff[10]; sprintf(buff, %d , n); return string(buff); } int main() { int a, b; cin >> a >> b; if (a < b) { cout << b; return 0; } string sa, sb, t, r = , si = ; sb = i_str(b); for (i...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, sum = 0; cin >> n >> m; vector<int> v; for (int i = 0; i < n; i++) { int ff; cin >> ff; v.push_back(ff); } for (int i = 0; i < m; i++) { int x; cin >> x; if (x == 1) { int l, k; ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; while (cin >> n >> m) { int str[550][550], cnt[550], ans[550]; memset(str, 0, sizeof(str)); memset(cnt, 0, sizeof(cnt)); memset(ans, 0, sizeof(ans)); for (int i = 0; i < m; i++) { int u, v; cin...
//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...
/* * 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 (C) 2014 Francis Bruno, All Rights Reserved // // 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...
module mmio_if ( clk_i_clk, hps_ddr3_mem_a, hps_ddr3_mem_ba, hps_ddr3_mem_ck, hps_ddr3_mem_ck_n, hps_ddr3_mem_cke, hps_ddr3_mem_cs_n, hps_ddr3_mem_ras_n, hps_ddr3_mem_cas_n, hps_ddr3_mem_we_n, hps_ddr3_mem_reset_n, hps_ddr3_mem_dq, hps_ddr3_mem_dqs, hps_ddr3_mem_dqs_n, hps_ddr3_mem_odt, hps_ddr3_mem_dm...
#include <bits/stdc++.h> using namespace std; long long c[105], x[105][105], dp[105][105][105]; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n, m, k, i, j, l, p, ans = 10000000000000000; cin >> n >> m >> k; for (i = 1; i <= n; i++) cin >> c[i]; for...
#include <bits/stdc++.h> using namespace std; const double eps = 1.0e-11; const double pi = acos(-1.0); int main() { string s; cin >> s; int n = s.size(); vector<int> points; for (long long i = 0; i < (int)(s).size(); i++) { if (s[i] == . ) { points.push_back(i); } }...
#include <bits/stdc++.h> using namespace std; vector<vector<long long> > g; vector<bool> used; void dfs(long long v, long long &h, long long &e) { used[v] = true; h++; e += g[v].size(); for (int i = 0; i < g[v].size(); ++i) { if (!used[g[v][i]]) dfs(g[v][i], h, e); } } int main() {...
#include <bits/stdc++.h> using namespace std; int t; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> t; while (t--) { int a, b, c; cin >> a >> b >> c; if (c == 0) { if (a <= b) cout << 0 << endl; else cout << 1 <<...
#include <bits/stdc++.h> using namespace std; int a[111111]; int b[111111]; int main() { int n, i, j; vector<pair<int, int> > v; scanf( %d , &n); a[0] = a[1] = 1; for (i = 2; i <= n; i++) { if (a[i] == 0) { for (j = i * 2; j <= n; j += i) a[j] = 1; } } for (i = n ...
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize( O3 ) #pragma GCC optimize( no-stack-protector ) #pragma GCC optimize( unroll-loops ) #pragma GCC optimize( fast-math ) #pragma GCC target( sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native ) mt19937 rng(time(NULL)); const int inf = 1e9 + 1...
#include <bits/stdc++.h> using namespace std; int main() { long long i, n, k, sum = 0; bool flag = false; set<long long> S; scanf( %I64d%I64d , &n, &k); for (i = 1; i <= sqrt(n); i++) { if (n % i == 0) { S.insert(i); S.insert(n / i); } } if (S.size() >= k) fla...
`timescale 1ns / 1ps /** Register file: * 2 asyncrhonous read ports * 1 synchronous write port */ module regfile( input wire clk, // clock to trigger write input wire rst, // reset input wire [4:0] raddr1, r...
#include <bits/stdc++.h> using namespace std; const long long N = 1e5; const long long M = 1e4; const long long mod = 1e9 + 7; const long long inf = 1e9; long long read() { long long s = 0; register bool neg = 0; register char c = getchar(); for (; c < 0 || c > 9 ; c = getchar()) neg |= (...
#include <bits/stdc++.h> using namespace std; long long a, b, c, i, l, j, x, s, y, ans; int main() { cin >> a >> b >> c >> l; s = 0; for (i = l + 1; i >= 1; i--) s += i * (i + 1) / 2; ans = 0; for (i = 0; i <= l; i++) { x = a + i; if (b > x || c > x) continue; y = min(l - i, ...
/*************************************************************************************************** ** fpga_nes/hw/src/cmn/uart/uart_baud_clk.v * * Copyright (c) 2012, Brian Bennett * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted * provided ...
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 100, mod = 998244353; int n, c[N], s[N]; int qpow(int x, int y) { int res = 1; while (y) { if (y & 1) res = 1ll * res * x % mod; x = 1ll * x * x % mod, y >>= 1; } return res; } int main() { scanf( %d , &n); ...
#include <bits/stdc++.h> using namespace std; template <class T> inline void amin(T& a, const T& b) { if (a > b) a = b; } template <class T> inline void amax(T& a, const T& b) { if (a < b) a = b; } template <class T> inline void rv(vector<T>& v, int n) { vector<T>(n).swap(v); for (int ...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
module data_ram_wb #( parameter addr_high = 32'h0000ffff, parameter addr_low = 32'h00001000) ( // wishbone signals input [31:0] dat_i, output [31:0] dat_o, input [31:0] adr_i, input we_i, input [3:0] sel_i, input cyc_i, input stb_i, ou...
#include <bits/stdc++.h> using namespace std; const int maxn = (int)1e6; const int inf = (1ll << 31) - 1; int p[maxn], l[maxn]; int n; pair<pair<int, int>, int> e[maxn]; pair<int, int> st[maxn]; int sum[maxn], answer[maxn]; int main() { scanf( %d , &n); for (int i = 0; i < n; ++i) { scan...
// Accellera Standard V2.3 Open Verification Library (OVL). // Accellera Copyright (c) 2005-2008. All rights reserved. `include "std_ovl_defines.h" `module ovl_one_cold (clock, reset, enable, test_expr, fire); parameter severity_level = `OVL_SEVERITY_DEFAULT; parameter width = 32; parameter inactive ...
/** * 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); template <typename T> void chmin(T &x, const T &y) { if (x > y) x = y; } template <typename T> void chmax(T &x, const T &y) { if (x < y) x = y; } template <typename T> T gcd(T x, T y) { return y ? gcd(y, x % y) : x...
/* Legal Notice: (C)2007 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...
#include <bits/stdc++.h> using namespace std; int n; long long x[100007], y[100007], xx, yy, m, p, q; long long ans; int get(int p, int q) { while ((x[q] - x[p]) * (yy - y[p]) - (y[q] - y[p]) * (xx - x[p]) <= 0) q = q % n + 1; q = (q + n - 2) % n + 1; return q; } int main() { cin >> ...
#include <bits/stdc++.h> int main(int argc, const char* argv[]) { int n; std::cin >> n; std::string s; std::cin >> s; std::vector<int> v0(n); for (int i = 0; i < n; i++) v0[i] = s[i] - 0 ; bool add = true; std::vector<int> v1(n); for (int i = 0; i < n; i++) { if (add) ...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2013 Xilinx, Inc. // All Right Reserved. /////////////////////////////////////////////////////////////////////////////// // ____ ____ // / /\/ / // /___/ \ / Vendor : Xilinx // \ \ \/ Version : 201...
#include <bits/stdc++.h> using namespace std; mt19937 rnnnd(chrono::steady_clock::now().time_since_epoch().count()); inline int read() { int x = 0, f = 1, c = getchar(); while (!isdigit(c)) { if (c == - ) f = -1; c = getchar(); } while (isdigit(c)) { x = (x << 1) + (x << 3) + (c...
#include <bits/stdc++.h> using namespace std; map<string, int> m; int main() { int n; cin >> n; string h; cin >> h; m[h]++; for (int i = 0; i < n; i++) { string s; cin >> s; string a = , b = ; for (int i = 0; i < 3; i++) a += s[i]; for (int i = 5; i < 8; i...
module VGAController( input iClk, input inRst, input [7:0] iR, input [7:0] iG, input [7:0] iB, output [7:0] oR, output [7:0] oG, output [7:0] oB, output oHSync, output ...
// Copyright (c) 2000-2009 Bluespec, Inc. // 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, pub...
/* Distributed under the MIT licesnse. Copyright (c) 2011 Dave McCoy () Permission is hereby granted, free of charge, to any person obtaining a copy of this start_of_frametware and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to u...
/** * 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() { vector<int> p; vector<int> n; vector<int> z; int t; cin >> t; int x; for (int i = 0; i < t; i++) { cin >> x; if (x > 0) p.push_back(x); else if (x < 0) n.push_back(x); else z.push_b...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; const int32_t M = 1e9 + 7; const int32_t MM = 998244353; void solve() { long long x; cin >> x; long long n = 2; long long tot = (n * (n - 1)) / 2; long long ans = 0; while (tot <= x) { ans++; n *= 2; ...
#include <bits/stdc++.h> static const int INF = std::numeric_limits<int>::max(); int dp[101][201]; int main() { int n; std::cin >> n; std::vector<int> t(n), w(n); for (int i = 0; i < n; ++i) { std::cin >> t[i] >> w[i]; } memset(dp, -1, sizeof(dp)); dp[0][0] = 0; for (int i = ...
#include <bits/stdc++.h> using namespace std; void arr(string &s); int main() { int n = 0, k = 0, m = 0; bool b = 0; cin >> n >> k; string s = ; cin >> s; arr(s); for (int i = 0; i < s.length(); i++) switch (s[i]) { case G : m = i; i = s.length(); ...
#include <bits/stdc++.h> using namespace std; const long long LLINF = 1e18 + 7; const long long INF = 1e9 + 7; const long long EPS = 1e-9 - 7; const long long MAX = 1e2 + 7; const long long MOD = 1e9 + 7; int n, d, dp[MAX]; string s; bool can[MAX], flag = false; int main() { memset(dp, MAX, size...
#include<bits/stdc++.h> #define ll long long int using namespace std; int t; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int sum=0; int odd=-1; vector<int> a(n); for (int q=0;q<n;q++){ int x; cin>>x; ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 2016/05/24 14:50:35 // Design Name: // Module Name: _8_to_3_priority_encoder_tb // Project Name: // Target Devices: // Tool Versions: // Description: // // Depende...
module diffeq_paj_convert (clk, reset,Xinport, Yinport, Uinport, Aport, DXport, Xoutport, Youtport, Uoutport ); input[31:0] Xinport; input[31:0] Yinport; input[31:0] Uinport; input[31:0] Aport; input[31:0] DXport; input clk; input reset; output[31:0] Xoutport; output[31:0] Youtport;...
#include <bits/stdc++.h> using namespace std; int n, m; char mp[103][103]; int main() { int i, j, cnt; scanf( %d , &n); for (i = 0; i < n; i++) scanf( %s , mp[i]); cnt = 0; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) if (mp[i][j] == . ) break; if (j != n) cnt++; ...