text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; long long n, m; long long arr[200002], time_freq[101]; void solve() { long long total_time = 0; for (long long i = 0; i < n; i++) { long long exam_start_time = total_time + arr[i] - m; int student_removed = 0; if (exam_start_time > 0) { ...
#include <bits/stdc++.h> using namespace std; vector<pair<long long, long long> > bl; long long fact[200005]; long long ifact[200005]; long long invert_mod(long long a, long long p) { long long n = 1, old = 0, q = p, r, h; bool pos = false; while (a > 0) { r = q % a; q = q / a; h...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; const int mod = 1e9 + 7; long long qpow(long long a, long long b) { long long res = 1; for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } struct graph { int head[maxn], ...
/* 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,...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2010 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 interface counter_if; logic [3:0] value; logic reset; modport counter_mp (input reset, outp...
#include <bits/stdc++.h> using namespace std; const int maxn = 1000 + 100; int n, k; long long C[maxn][maxn]; void Init() { C[0][0] = 1; for (int i = 1; i < maxn; ++i) { for (int j = 0; j <= i; ++j) { if (j == 0 || j == i) { C[i][j] = 1; } else { C[i][j] = C[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...
/* -- ============================================================================ -- FILE NAME : bus_if.v -- DESCRIPTION : ƒoƒXƒCƒ“ƒ^ƒtƒF[ƒX -- ---------------------------------------------------------------------------- -- Revision Date Coding_by Comment -- 1.0.0 2011/06/27 suito V‹Kì¬ -- =======...
// ZX-Evo SD Load (c) NedoPC 2008,2009,2010,2011,2012,2013,2014,2015,2016,2019 // // top-level /* This file is part of ZX-Evo SD Load firmware. ZX-Evo SD Load firmware is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by ...
`timescale 1ns / 1ps module hvsync_generator( input wire clk, input wire reset, output reg vga_h_sync, output reg vga_v_sync, output reg [10:0] CounterX, output reg [10:0] CounterY, output reg inDisplayArea ); parameter TotalHorizontalPixels = 11'd800; parameter HorizontalSyncWidth = 11'd96; parameter Vertical...
#include <bits/stdc++.h> using namespace std; int main() { int n, k, i, teo = 0, s = 0, a[100001], t[100001]; cin >> n >> k; for (i = 1; i <= n; i++) cin >> a[i]; for (i = 1; i <= n; i++) { cin >> t[i]; if (t[i] == 1) { teo = teo + a[i]; a[i] = 0; } a[i] = a[i...
#include <bits/stdc++.h> #pragma GCC optimize( O2 ) #pragma GCC optimize( unroll-loops ) using namespace std; const long double eps = 1e-7; const int inf = 1000000010; const long long INF = 10000000000000010LL; const int mod = 1000000007; const int MAXN = 200010, LOG = 20; struct DSU { int par[MAX...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t-- > 0) { char c[100005]; int n; cin >> n; string s0 = ; string sm = ; string s1 = ; bool flag0 = true; int pos1 = -1; int pos0 = -1; for (int i = 1; i <=...
/* * 16 to 8 bit instruction prefetch fifo * Milkymist SoC * Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq * adjusted to 16 to 8 bit by Charley Picker <> * * 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 ...
#include <bits/stdc++.h> using namespace std; int n; pair<double, double> p[301]; double a, b, c, den, len; double area(int i) { double num = abs(a * p[i].first + b * p[i].second + c); return (num) / (2.0); } double f(int i, int j) { a = (p[j].second - p[i].second); b = (p[i].first - p[j]....
`timescale 1ns/10ps module DE0_NANO_SOC_QSYS_pll_sys( // interface 'refclk' input wire refclk, // interface 'reset' input wire rst, // interface 'outclk0' output wire outclk_0, // interface 'outclk1' output wire outclk_1, // interface 'outclk2' output wire outclk_2, // interface 'loc...
#include <bits/stdc++.h> using namespace std; int main() { int n, size = 1e6 + 1; cin >> n; vector<int> prime(1e6 + 1, 1); prime[0] = 0; prime[1] = 0; for (int ri = 2; ri <= sqrt(size); ri++) { if (prime[ri]) { for (int pi = ri * ri; pi <= size; pi += ri) if (prime[pi...
/** * 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 = 10, dir[4][2] = {{1, 0}, {0, 1}, {1, -1}, {1, 1}}; int main() { char b[n][n]; for (int i = 0; i < 10; i++) for (int j = 0; j < n; j++) scanf( %c , &b[i][j]); bool found = false; for (int i = 0; !found && i < n; i++) for (int ...
/******************************************************************************* * This file is owned and controlled by Xilinx and must be used solely * * for design, simulation, implementation and creation of design files * * limited to Xilinx devices or technologies. Use with non-Xilinx ...
#include <bits/stdc++.h> using namespace std; int main() { int i, j, n, x = (int)(1e7 + 1); cin >> n; vector<bool> p(x, true); p[0] = p[1] = false; int c = 0; for (i = 2; i <= x; i++) { if (p[i]) { c++; cout << i << ; if (c == n) break; for (j = i; (l...
#include <bits/stdc++.h> inline long long int min(long long int a, long long int b) { return (a < b) ? a : b; } long long int dp[303][303], cost[303][303]; int main() { int n, m, k, o, j, i; scanf( %d %d %d , &n, &m, &o); for (i = 0; i <= n; i++) for (j = 0; j <= n; j++) dp[i][j] = cost[i]...
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t) { t--; long long a, b; cin >> a >> b; long long n = a / b + (bool)(a % b); cout << b * n - a << endl; } return 0; }
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 02:05:46 08/01/2008 // Design Name: // Module Name: test_vdu // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // Revision:...
#include <bits/stdc++.h> using namespace std; const long ka[6] = {0, 0, 0, 0, 2, 4}; int main() { long long n, m; while (cin >> n >> m) { if (n > m) { int tmp = n; n = m; m = tmp; } long long ret; if (n == 1) ret = m / 6 * 6 + ka[m % 6]; else i...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int i = 0; i < t; i++) { int n; cin >> n; int maxi = 0, mini = 1000000000; vector<long long int> a(n, 0); long long int xor1 = 0; long long int sum1 = 0; for (int i = 0; i < n; i++)...
#include <bits/stdc++.h> using namespace std; const int maxn = 3010; bool visit[maxn]; int n, m, ans, f[maxn]; vector<int> ve; vector<pair<int, int> > maps[maxn]; void first_dfs(const int u) { visit[u] = 1; for (int i = 0; i < ((int)(maps[u]).size()); ++i) { int v = maps[u][i].first; i...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2014 Xilinx, Inc. // All Right Reserved. /////////////////////////////////////////////////////////////////////////////// // ____ ____ // / /\/ / // /___/ \ / Vendor : Xilinx // \ \ \/ 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 la...
#include <bits/stdc++.h> using namespace std; const int N = 1e7; long long int a[N], ans; int main() { long long int n; cin >> n; long long int l = 0, r = n - 1; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); for (int i = 0; i < n / 2; i++) { ans += (a[l] + ...
`timescale 1ns / 1ps //----------------------------------------------- // Company: agh // Engineer: komorkiewicz // Create Date: 04/18/2012 // Description: divider core using successive approximation method //----------------------------------------------- module divider_28_20 # ( parameter LATENCY=8, param...
//-*- mode: Verilog; verilog-indent-level: 3; indent-tabs-mode: nil; tab-width: 1 -*- module apl2c_connect(autoinoutmodport_type_intf ctl_i, /*AUTOINOUTMODPORT("autoinoutmodport_type_intf", "ctl_cb")*/ // Beginning of automatic in/out/inouts (from modport) ...
`timescale 1ps/1ps module test_spi_device_test; reg running; reg [7:0] data; reg [3:0] cnt; reg [4:0] clk_cnt; reg clk; reg reset; reg end_flag; reg [7:0] buffer; wire mosi; reg sck; wire miso; assign mosi = buffer[7]; parameter osc = / 4; test_spi_device device (reset, sck, mosi, miso); initial be...
#include <bits/stdc++.h> using namespace std; long long g; void ex_gcd(long long a, long long b, long long& x, long long& y) { if (!b) { g = a; x = 1, y = 0; } else { ex_gcd(b, a % b, y, x); y = y - a / b * x; } } int main() { long long a, b, c; scanf( %lld%lld%lld ...
#include <bits/stdc++.h> using namespace std; int n; string a, b; void perform(int len) { for (int i = 0; i < len / 2; ++i) { if (a[i] == a[len - 1 - i]) { a[i] = 0 + 1 - a[i]; a[len - 1 - i] = 0 + 1 - a[len - 1 - i]; } } if (len & 1) a[len / 2] = 0 + 1 - a[le...
#include <bits/stdc++.h> const int MAXN = 2e5 + 10; const int mod = 1e9 + 7; void reduce(int& x) { x += x >> 31 & mod; } int mul(int a, int b) { return (long long)a * b % mod; } int pow(int a, int b, int res = 1) { for (; b; b >>= 1, a = mul(a, a)) if (b & 1) res = mul(res, a); return res; } ...
/* * 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() { int N; cin >> N; string inst; cin >> inst; int total = 0; for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { int ct_u = 0; int ct_l = 0; for (int k = i; k <= j; k++) { if (inst[k] ...
#include <bits/stdc++.h> using namespace std; char s[1010000]; int main() { int i, j, k, m, n; scanf( %s , s); n = strlen(s); if (n % 2 == 1) { n = (n + 1) / 2; for (i = 1; i <= n; i++) putchar( 4 ); for (i = 1; i <= n; i++) putchar( 7 ); puts( ); } else { char u...
/*************************************************************************************************** ** fpga_nes/hw/src/cmn/uart/uart.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 ...
/** * 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; char ss[100002]; int main() { int N, K, k = 0; scanf( %d %d , &N, &K); scanf( %s , ss); string S = ss; for (int i = 0; i < N - 1 && k < K; i++) { if (S[i] == 4 && S[i + 1] == 7 ) { int x = i + 1; if (x % 2) { if (...
//-------------------------------------------------------------------------------- // stage.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 Foundat...
#include <bits/stdc++.h> using namespace std; int a, b, c; double dp[102][102][102]; int main() { scanf( %d%d%d , &a, &b, &c); int n = max(max(a, b), c); dp[1][0][0] = 1; dp[1][1][0] = 1; for (int i = 1; i <= n; i++) dp[i][0][0] = 1; for (int i = 1; i <= n; i++) for (int j = 0; j <...
#include <bits/stdc++.h> using namespace std; const int N = 200010; int hp[N], dmg[N], p[N]; bool cmp(int a, int b) { return hp[a] - dmg[a] > hp[b] - dmg[b]; } bool vis[N]; int main() { int n, a, b; scanf( %d%d%d , &n, &a, &b); for (int i = 1; i <= n; i++) { scanf( %d%d , &hp[i], &dmg[i]);...
#include <bits/stdc++.h> using namespace std; int a[200000 + 1]; struct info { int sum, prop; } t[3 * 200000 + 3]; void build(int node, int b, int e) { if (b >= e) { if (b == e) t[node].sum = a[b]; return; } int left = node << 1; int right = left | 1; int mid = (b + e) >> 1...
#include <bits/stdc++.h> using namespace std; int s, x1, x2, t1, t2, p, d; int main() { cin >> s >> x1 >> x2 >> t1 >> t2 >> p >> d; int t = 0, flag1 = 0, flag2 = 0; while (flag1 == 0 || flag2 == 0) { if (flag1) { if (p == x2) break; } else if (p == x1) flag1 = 1; if (...
#include <bits/stdc++.h> using namespace std; bool debug = 1; long long MOD = 1e9 + 7; const int N = 2e5 + 10; map<int, vector<int>> mpe, mps; int nonred[N]; int n; set<int> st; int main() { cin >> n; for (int i = 0; i < n; i++) { int l, r; scanf( %d%d , &l, &r); mpe[l].push_...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 19:03:44 08/31/2014 // Design Name: // Module Name: lab5dpath // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // ...
#include <bits/stdc++.h> using namespace std; long long n, m, a[1005], b[1005], c[1005], d[1005], ans, tot; ; char s[1005]; long long calc() { long long cc = 0; for (long long i = 1; i <= n; i++) if (c[i]) { ans += (c[i] - 1) * (m - c[i]) * 4; for (long long j = i + 1; j <= n; j+...
#include <bits/stdc++.h> using namespace std; int n, k, s, a[5][205]; struct node { int id, x, y; }; vector<node> ans; inline void park() { for (int i = 0; i <= 2 * n - 1; ++i) if (a[1][i] && a[1][i] == a[0][i]) { ans.push_back(node{a[1][i], i / n ? 4 : 1, i % n + 1}); a[1][i] ...
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; vector<long long> a(k); for (int h = 0; h < a.size(); h++) { cin >> a[h]; }; int gg = max_element(a.begin(), a.end()) - a.begin(); for (int i = k - 1; i > gg; i--) { if (a[i] > a[i - 1]) { cou...
#include <bits/stdc++.h> using namespace std; const int inf = 1e9; const long long Inf = 1e18; const int N = 2e5 + 10; const int mod = 0; long long gi() { long long x = 0, o = 1; char ch = getchar(); while ((ch < 0 || ch > 9 ) && ch != - ) ch = getchar(); if (ch == - ) o = -1, ch = getc...
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 5; constexpr int LOGMAX = 31 - __builtin_clz(MAX) + 5; int N; char T[MAX]; int sa[MAX], tsa[MAX], ra[MAX], tra[MAX]; int lcp[MAX], plcp[MAX], phi[MAX], c[MAX], st[LOGMAX][MAX]; long long pref[MAX]; void sort(int k) { memset(c, 0, ...
#include <bits/stdc++.h> using namespace std; int64_t pre[200001]; int64_t dp[200001]; int n; int main() { cin >> n; for (int i = 1; i <= n; ++i) { cin >> pre[i]; pre[i] += pre[i - 1]; } int64_t mx = -1e15; for (int i = n - 1; i >= 1; --i) { dp[i] = max(pre[n], mx); ...
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; void MAIN(); int main() { MAIN(); return 0; } const int N = (int)1e5 + 32; char s[N]; int n; void MAIN() { scanf( %d , &n); scanf( %s , s); vector<int> cnt(26, 0); for (int i = 0; i < int(n); i++) cnt[s...
#include <bits/stdc++.h> using namespace std; int main() { long long n = 0, m = 0; cin >> n >> m; for (long long i = 0; i < n; i++) { for (long long j = 0; j < m; j++) { if (i % 2 == 0) cout << # ; else if ((j == m - 1 && (i - 1) % 4 == 0) || (j == 0 && (i + 1) % 4 == 0)...
// megafunction wizard: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: scfifo // ============================================================ // File Name: txfifo.v // Megafunction Name(s): // scfifo // // Simulation Library Files(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...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:256000000 ) using namespace std; vector<char> cc; void solve() { int n, m, k, d = 0; cin >> n >> m >> k; vector<string> arr(n), ans(n); for (int i = 0; i < n; i++) { cin >> arr[i]; ans[i].resize(m); for (int j = 0; j < m;...
/****************************************************************************** * License Agreement * * * * Copyright (c) 1991-2012 Altera Corporation, San Jose, California, USA. * ...
/** * 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 + 5, INF = 1e9; bool check(int n, string s) { for (int i = 1; i <= n; i++) if (s[i] == 0 ) return false; cout << 1 << << n - 1 << << 2 << << n << endl; return true; } void sol(int n, string s) { for (int i = 1; ...
module memorytestbench; parameter sim_time = 750*2; // Num of Cycles * 2 wire MFC; wire [31:0] MEMDAT; reg [31:0] MEMDAT_BUFF; reg MFA,READ_WRITE,WORD_BYTE, Reset ,Clk; reg [7:0] MEMADD; assign MEMDAT = MEMDAT_BUFF; //module memory (inout reg[31:0] Data, output reg MFC, input MFA, ReadWrite, input [7:0] Address, ...
#include <bits/stdc++.h> using namespace std; const int maxn = 3452; vector<int> G[maxn]; pair<int, int> snd[maxn][maxn]; int size[maxn][maxn]; long long f[maxn][maxn]; int n, cur, nxt; void dfs(int p, int fl = -1) { if (fl == cur) { nxt = p; } size[cur][p] = 1; snd[cur][p] = make_...
#include <bits/stdc++.h> using namespace std; int main() { int a[2][2]; cin >> a[0][0] >> a[0][1] >> a[1][0] >> a[1][1]; int n[2]; if (!a[0][0] && !a[1][0] && !a[0][1] && !a[1][1]) { cout << 0 ; return 0; } for (int i = 0; 1; i++) { int temp = i * (i - 1) / 2; if (te...
#include <bits/stdc++.h> using namespace std; const long long MOD = 998244353; long long modexp(long long a, long long n) { if (a == 0) return 0; if (n == 0) return 1; long long p = modexp(a, n / 2); p = p * p % MOD; if (n & 1) p = p * a % MOD; return p; } int main() { ios_base::sy...
#include <bits/stdc++.h> using namespace std; int a[1505]; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); int ans = 0; for (int i = 1; i <= n; i++) for (int j = 1; j <= i - 1; j++) if (a[j] > a[i]) ans ^= 1; int q; scanf( %d , &q); ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 10:50:10 11/03/2014 // Design Name: // Module Name: Output_2_Disp // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: ...
// (C) 1992-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 simulati...
//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 (c) 2015-2016 The Ultiparc Project. 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 source code must retain the above copyright * notice, this list...
`timescale 1us/100ns module top; reg pass = 1'b1; reg [3:0] ia = 4'd1; wire signed [3:0] iconstp, iconstm, isfunc, iufunc; wire [7:0] istring; /* Integer constant value. */ assign #1 iconstp = 2; // 2 assign #1 iconstm = -2; // -2 assign #1 istring = "0"; // "0" /* Integer System Function. */ as...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0); long long n, i, j, k, l, m, arr[100010], arr1[100010], x, y; double a, b, c, d, p, t; cin >> n; for (i = 0; i < n; i++) cin >> arr[i]; sort(arr, arr + n); reve...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 10:13:49 05/12/2015 // Design Name: // Module Name: sbox8 // Project Name: // Target Devices: // Tool versions: // Description: // // Dependenc...
/** * datapath.v - Microcoded Accumulator CPU * Copyright (C) 2015 Orlando Arias, David Mascenik * * 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...
/////////////////////////////////////////////////////////////////////////////// // // 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...
#include <bits/stdc++.h> using namespace std; const int N = 200005; long long dp[N][5]; long long DP[N]; int head[N], nex[N * 2], to[N * 2], tot = 0; int n, k; long long ans = 0; void add(int u, int v) { to[++tot] = v; nex[tot] = head[u]; head[u] = tot; } void dfs(int u, int fa, int d) {...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); ; long long n, k; cin >> n >> k; vector<long long> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; } long long ans = 0; unordered_map<int, int> m; for (int...
#include <bits/stdc++.h> using namespace std; int main() { int arr[100] = {0}, con = 0, d = 0; ; string x; cin >> x; for (int i = 0; i < x.size(); i++) { if (x[i] == + ) { for (int j = 0; j < con; j++) { arr[d] += (x[i - j - 1] - 48) * pow(10, j); } d++; ...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Wed Dec 14 22:35:39 MST 2016 // Date : Mon Feb 20 13:53:00 2017 // Host : GILAMONSTER running 64-bit major release (...
#include <bits/stdc++.h> using namespace std; const int N = 5010; int n, arr[N], ans[(N << 1)]; vector<int> a[N], b[N]; const int inv2 = 500000004; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &arr[i]); } for (int i = n - 2; i >= 0; i--) { a[i].resize((...
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int, int> PII; typedef pair<LL,LL> PLL; const int INF = 0x3f3f3f3f, N = 1e5 + 10; inline int lc(int u) {return u << 1;} inline int rc(int u) {return u << 1 | 1;} inline int lowbit(int x) {return x & (-x);} int y[27] = {10...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 20:37:07 03/24/2015 // Design Name: // Module Name: abc // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencie...
#include <bits/stdc++.h> using namespace std; using ll = long long; void dout() { cerr << endl; } template <typename Head, typename... Tail> void dout(Head H, Tail... T) { cerr << H << ; dout(T...); } mt19937 rnd(time(0)); struct Node { Node* left = nullptr; Node* right = nullptr; ...
#include <bits/stdc++.h> using namespace std; int cnt[(100000 + 10)]; int f[(100000 + 10)]; int main() { int n; cin >> n; int ans = 0; int mx = 0; for (int i = 1; i <= n; i++) { int v; cin >> v; cnt[f[v]]--; f[v]++; cnt[f[v]]++; int ok = 0; mx = max(...
#include <bits/stdc++.h> const int mod = 1000000007; using namespace std; long long gcd(long long a, long long b) { if (a == 0) return b; return gcd(b % a, a); } long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); } int prime[100007]; void SieveOfEratosthenes(int n) { memset(...
#include <bits/stdc++.h> using namespace std; const int N = 112; const long long mod = 1e9 + 7; int R; long long p1, p2, p3, p4, s; int lim[N]; long long F[N][N]; long long ksm(long long a, long long b = mod - 2) { long long ret = 1; for (; b; b >>= 1, a = a * a % mod) if (b & 1) ret = ret...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int tt; cin >> tt; while (tt--) { int a, b, c; cin >> a >> b >> c; int ans = (int)1e9; int A = -1, B = -1, C = -1; for (int cA = 1; cA <= 2 * a; cA++) { for (...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
// -- (c) Copyright 2010 - 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 property // -- laws. // -- // -- DISCLAIMER // -- This disclaimer is not a...
#include <bits/stdc++.h> using namespace std; int main(void) { int t, n; cin >> t; string s; for (int k = 0; k < t; k++) { cin >> n; cin >> s; if (s.size() == 2) { if (s[0] < s[1]) { cout << YES << n ; cout << 2 << n ; cout...
#include <bits/stdc++.h> using namespace std; bool SR(int &_x) { return scanf( %d , &_x) == 1; } bool SR(long long &_x) { return scanf( %lld , &_x) == 1; } bool SR(double &_x) { return scanf( %lf , &_x) == 1; } bool SR(char *_s) { return scanf( %s , _s) == 1; } bool RI() { return true; } template <typenam...
#include <bits/stdc++.h> using namespace std; template <class T> bool umin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template <class T> bool umax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } const int N = 1e2 + 9; char s[N], t[...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; for (int i = 0; i < t; i++) { int x, y, a, b; cin >> x >> y >> a >> b; if ((y - x) % (a + b) == 0) { cout << (y - x) / (a + b) << n ; } els...
#include <bits/stdc++.h> using namespace std; int main() { int n, h, m, l, r, x; cin >> n >> h >> m; vector<int> v(n, h); for (int i = 0; i < m; i++) { cin >> l >> r >> x; for (int j = l - 1; j < r; j++) { v[j] = min(v[j], x); } } long long sum = 0; for (int i =...
`include "constants.vh" `default_nettype none module true_dualport_ram #( parameter ADDRLEN = 10, parameter DATALEN = 2, parameter DEPTH = 1024 ) ( input wire clka, input wire [ADDRLEN-1:0] addra, output reg [DATALEN-1:0] rdataa, input wire [DATALEN-1:0] wdataa, inp...
//sata_link_layer.v /* Distributed under the MIT license. Copyright (c) 2011 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 rig...
`timescale 1ns/1ns module usb_tx_sie (input c, input c_48, input rst, input [7:0] d, input dv, output done, output oe_n, inout vp, inout vm); wire txf_q, txf_read, txf_empty; usb_tx_fifo usb_tx_fifo_inst (.c(c), .c_48(c_48), .d(d), .dv(dv), // at 125 mhz .q(txf_q), .read(txf_read), .empty(txf_empty)); // ...
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int N = 1100; int n; vector<int> g[N]; int ed[N][3]; int ans[10 * N][3]; int ansSz; void addAns(int v, int u, int x) { ans[ansSz][0] = v + 1; ans[ansSz][1] = u + 1; ans[...