text
stringlengths
59
71.4k
////////////////////////////////////////////////////////////////////////////////// // // This file is part of the N64 RGB/YPbPr DAC project. // // Copyright (C) 2015-2021 by Peter Bartmann <> // // N64 RGB/YPbPr DAC is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public ...
/** * 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...
// Emulate CSOC Scan Chain and IOs module csoc #( parameter NREGS = 1918 )( input clk_i, input rstn_i, input uart_read_i, output uart_write_o, input [7:0] data_i, output [7:0] data_o, input xtal_a_i, output xtal_b_o, output clk_o, input test_tm_i, inpu...
/* * 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 N, M, cnt[101]; int main() { int N, M, cnt[101] = {0}; scanf( %d%d , &N, &M); for (int i = 0; i < N; i++) { int t; scanf( %d , &t); int now = M - t; int ans = i; for (int j = 1; j <= 100; j++) { int get = min(now /...
/** * 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, k, a[10010]; long long ans; int main() { scanf( %d%d , &n, &k); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); sort(a + 1, a + n + 1); for (int i = 1; i <= k; i++) ans += a[i]; printf( %lld n , ans); return 0; }
#include <bits/stdc++.h> bool compare(int a, int b) { return a < b; } void swapped(char s1, char s2) { char temp = s1; s1 = s2; s2 = temp; } long long int modd(long long int n, long long int k) { return (k + (n % k)) % k; } bool i(long long first) { return first && (!(first & (first - 1))); ...
#include <bits/stdc++.h> using namespace std; template <typename T> inline bool upmin(T &x, T y) { return y < x ? x = y, 1 : 0; } template <typename T> inline bool upmax(T &x, T y) { return x < y ? x = y, 1 : 0; } const long double eps = 1e-9; const long double pi = acos(-1); const int oo = ...
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b = 0; cin >> a; if (a == 0) { cout << 0 ; return 0; } b = a + 1; if (b % 2 == 0) { cout << b / 2; } else cout << b; }
// ============================================================== // 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> using namespace std; long long md = 1000000007; long long bexp(long long a, long long b) { if (b == 0) return 1; if (b == 1) return a; long long r = bexp(a, b / 2); r = r * r; if (b % 2 == 0) return r; else return r * a; } int main() { ios_base:...
#include <bits/stdc++.h> using namespace std; int n, A, B, C, T; int temp[1005]; int main() { cin >> n >> A >> B >> C >> T; long long ans = 0; for (int i = 1; i <= n; i++) cin >> temp[i]; ans = n * A; if (C > B) { for (int i = 1; i <= n; i++) ans += (C - B) * (T - temp[i]); } c...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; int main() { ios::sync_with_stdio(false); cin.tie(0); int k; cin >> k; int sum = (1 << 18) - 1; cout << 3 3 n ; cout << sum << << (1 << 17) << << 0 << n ; cout << k << << sum << << 0 << n...
#include <bits/stdc++.h> using namespace std; long long n, v[100010], c[100010], l[100010], r, mx = 0; map<long long, long long> dp, path, acp; vector<long long> ans, vt[3 * 100010]; void getdp(long long x) { long long i, ss; dp.clear(); path.clear(); acp.clear(); for (i = 0; i < vt[x].siz...
#include <bits/stdc++.h> using namespace std; using INT = long long; int a[200100], b[200100]; map<int, int> mp[2]; int arr[200100]; map<int, int> vst; int main() { int n, st; cin >> n >> st; for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); } int m, ed; cin >> m >> ed; ...
module wavegrp_info ( wf_wr_en, wr_wf_tag, wr_wg_wf_count, wr_wfid, halt, halt_wfid, rd_wfid, rd_wgid, rd_wf_count, clk, rst ); input clk; input rst; input wf_wr_en; input [14:0] wr_wf_tag; input [3:0] wr_wg_wf_count; input [5:0] wr_wfid; input [5:0] rd_wfid; input halt; input [5:0] ...
#include <bits/stdc++.h> #pragma warning(disable : 4996) #pragma comment(linker, /STACK:336777216 ) using namespace std; int IT_MAX = 1 << 18; const long long MOD = 1000000007; const int INF = 0x3f3f3f3f; const long long LL_INF = 0x3f3f3f3f3f3f3f3f; const double PI = acos(-1); const double ERR = 1e-1...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 22:30:52 01/30/2011 // Design Name: MiniAlu // Module Name: D:/Proyecto/RTL/Dev/MiniALU/TestBench.v // Project Name: MiniALU // Target Device: // Tool v...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; set<string> g; g.insert(s); int n = s.size(); for (int k = 0; k < s.size(); k++) { string s1 = ; s1 += s[n - 1]; for (int i = 0; i < s.size() - 1; i++) { s1 += s[i]; } s = s...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long n, k; cin >> n >> k; if (k == n) { cout << Alice n ; continue; } if (k > n || k % 3 != 0) { if (n % 3 == 0) { cout << Bob n ; } el...
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; vector<int> a[1000001]; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; ++i) { int g; scanf( %d , &g); while (g--) { int p; scanf( %d , &p); a[p].push_back(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...
`timescale 1ns/1ps module tb_cocotb #( parameter DATA_WIDTH = 32, //This is the output bus parameter ADDR_WIDTH = 32, parameter INTERRUPT_WIDTH = 32 )( //Virtual Host Interface Signals input clk, input rst, input [31:0]...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, min, max; std::cin >> n >> m >> min >> max; int a[m]; int maxHit = 0; int minHit = 0; for (int i = 0; i < m; ++i) { std::cin >> a[i]; if (a[i] == min) { minHit = 1; } else if (a[i] == max) { ...
/** * 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 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 // laws....
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int cnt = 0, count = 0; for (int i = 0; i < n; i++) { if (s[i] == 8 ) cnt++; } while (cnt) { n = n - 1; cnt = cnt - 1; if (n / 10 > 0) { count++; 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 law...
#include <bits/stdc++.h> using namespace std; const int N = 100010; int n; struct Data { int s, id; bool operator<(const Data &a) const { return s < a.s; } } da[N]; int a[N], b[N]; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) { int s; scanf( %d , &s); da[i] =...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 14.03.2017 23:31:58 // Design Name: // Module Name: frequency_analyzer_synch // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependenci...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const double eps = 1e-8; char ans[1024]; int K, X, N, M; char st[64], ed[64]; long long num[64]; void printAns(char from, char to, int all, int len) { int pos = 1; if (from == A ) pos = 0; for (int i = 0; i < len; i...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int n, m; int a[maxn]; int b[maxn]; int ans[maxn]; int main() { cin >> n >> m; int num = 0; for (int i = 0; i < m; i++) { scanf( %d , a + i); if (b[a[i]] == 0) num++; b[a[i]]++; if (num == n) { ...
#include <bits/stdc++.h> using namespace std; int w, m; long long x = 1; bool f = 1; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> w >> m; while (m && f) { if ((m - 1) % w == 0 || m % w == 0 || (m + 1) % w == 0) { if ((m - 1) % w == 0 || m % w == 0) ...
/* * 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; long long int A[n]; for (int i = 0; i < n; i++) { cin >> A[i]; } sort(A, A + n); long long ans = 0; for (int i = 0; i < n / 2; i++) { ans += (A[i] + A[n - i - 1]) * (A[i] + A[n - 1 - 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; const int mod = int(1e6 + 3); vector<vector<int> > v; char second[600000]; int n, m; int main() { scanf( %d%d n , &n, &m); v.resize(n); for (int i = 0; i < n; ++i) { gets(second); v[i].resize(m); for (int j = 0; j < m; ++j) { ...
///////////////////////////////////////////////////////////////////// //// //// //// WISHBONE rev.B2 compliant synthesizable I2C Slave model //// //// //// //// ...
#include <bits/stdc++.h> using namespace std; const int MX = 11; int n, l; int main() { scanf( %d , &n); while (n) { int a = n % 10; int b = n % 100; int c = n % 1000; if (a == 1) n /= 10; else if (b == 14) n /= 10; else if (c == 144) n /= 100;...
//***************************************************************************** // (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 /...
#include <bits/stdc++.h> using namespace std; int main() { unsigned long long n, sum = 0; cin >> n; if (n % 2 == 0) { if ((n / 2) % 2 == 0) cout << 0 << endl; else cout << 1 << endl; } else { if ((n / 2) % 2 == 0) cout << 1 << endl; else cout <...
//====================================================================== // // tb_csprng_fifo.v // ---------------- // Testbench for the csprng fifo module in the trng. // // // Author: Joachim Strombergson // Copyright (c) 2014, Secworks Sweden AB // All rights reserved. // // Redistribution and use in source and bina...
/* * 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> const int inf = 1039074182; using namespace std; int n; long long a[100005]; void fi() { cout << sjfnb n ; exit(0); } void se() { cout << cslnb n ; exit(0); } int main() { cin >> n; for (int i = 0; i < n; i++) { scanf( %I64d , a + i); } ...
#include <bits/stdc++.h> using namespace std; int f(int a, int b) { int ans = 1; for (int i = 0; i < b; i++) ans *= a; return ans; } int main() { int a, b, sgn, n, ans = 1999; scanf( %d %d %d , &a, &b, &n); sgn = (a < 0) ^ (b < 0); a = abs(a); b = abs(b); if (sgn == 1 && n % ...
`begin_keywords "1364-2005" module top; reg svar; reg sarr [1:0]; reg sout, stmp; wire wsarr [1:0]; wire wsbslv, wspslv, wsuplv, wsdolv; wire wsbstr, wspstr, wsuptr, wsdotr; wire wsbs = svar[0]; wire wsps = svar[0:0]; wire wsup = svar[0+:1]; wire wsdo = svar[0-:1]; wire wsabs = sarr[0][0]; wir...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int maxn = 2e5 + 10; int n, k; long long fac[maxn + 10], afac[maxn + 10]; long long qpow(long long a, long long b) { long long ret = 1LL; while (b) { if (b & 1) ret = ret * a % mod; a = a * a % mod; b >>= ...
/******************************************************************************* * * NetFPGA-10G http://www.netfpga.org * * File: * tx_queue.v * * Library: * hw/osnt/pcores/osnt_10g_interface_v1_11_a * * Module: * tx_queue * * Author: * James Hongyi Zeng * * Description...
#include <bits/stdc++.h> long long quickpow(long long a, long long b) { long long ans = 1; while (b) { if (b & 1) ans = ans * a % 1000000007; b >>= 1, a = a * a % 1000000007; } return ans; } using namespace std; const long long N = 1e3 + 7; const long long maxn = 2e3 + 9; long lo...
#include <bits/stdc++.h> using namespace std; string s[3]; int a[200][200]; int n; int main() { char card, team; int tm, player; cin >> s[0] >> s[1]; cin >> n; for (int i = 0; i < n; i++) { cin >> tm >> team >> player >> card; if (card == y ) a[team][player]++; e...
#include <bits/stdc++.h> long long n, m, Q; long long T; std::vector<long long> req, l, r; std::vector<long long> fill(std::vector<long long>& req) { std::vector<long long> ans(m + 1); long long tem = T; for (long long i = m; i; i--) { ans[i] = 0; if (i < m) ans[i] = ans[i + 1]; if...
/** * 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...
// megafunction wizard: %ROM: 1-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: HW_SW.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // ======================...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
module I2CFSM ( input Reset_n_i, input Clk_i, input In0_i, input In1_i, input In2_i, input In3_i, input In4_i, input In5_i, input In6_i, input In7_i, output Out0_o, output Out1_o, output Out2_o, output Out3_o, output Out4_o, output Out5_o, output Out6_o, output Out7_o, output Out8_...
#include <bits/stdc++.h> using namespace std; pair<int, int> get_pair(int a, int b) { if (a > b) swap(a, b); return {a, b}; } template <class Cap, class Cost> struct mcf_graph { private: int _n; struct _edge { int to, rev; Cap cap; Cost cost; }; vector<pair<int, in...
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC optimize( Ofast ) using namespace std; long long int n, res[200005], cnt = 0, ans[200005]; vector<long long int> g[200005]; vector<long long int> v[200005]; map<long long int, long long int> c; queue<long long int> q; void dfs1(long long ...
/** * 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; int main() { long n, e = 0, aw = 0, k = 0; cin >> n; long a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; k = max(a[i], k); e += a[i]; } aw = k * n - e; while (aw <= e) { k++; aw = k * n - e; } cout << k...
/** * 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 ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 15:38:39 10/29/2012 // Design Name: // Module Name: IP_RAM // Project Name: // Target Devices: // Tool versions: // Description: // Êý¾Ý´æ´¢Æ÷Ä£¿é // ÊäÈëÐÅ...
#include <bits/stdc++.h> using namespace std; long long a[1000000], prime[1000000]; vector<long long> v[3000000]; int main() { ios::sync_with_stdio(false); cin.tie(), cout.tie(); long long e; for (long long i = 3; i * i <= 1000000; i += 2) if (a[i] == 0) for (long long j = i * i; j...
#include <bits/stdc++.h> using namespace std; const int N = 1510; int n, arr[N], m; int main() { scanf( %d , &n); int ans = 0; for (int i = 0; i < n; i++) { scanf( %d , &arr[i]); for (int j = 0; j < i; j++) { if (arr[i] < arr[j]) ans ^= 1; } } scanf( %d , &m); w...
#include <bits/stdc++.h> using namespace std; const int MaxN = 500 + 5; int n, m, mod, h[MaxN], tmp, tot[3]; long long f[MaxN << 1][MaxN]; char ch; void read(int &num) { ch = 0; while (ch < 0 || ch > 9 ) ch = getchar(); num = ch - 0 ; } int main() { scanf( %d%d%d , &n, &m, &mod); ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; char* c = new char[k]; for (int i = 0; i < k; i++) { c[i] = a + i; } for (int i = 0; i < n; i++) { cout << c[i % k]; } }
/** * 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() { long long int n; cin >> n; n = n / 2520; cout << n; return 0; }
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 17:45:25 12/01/2014 // Design Name: // Module Name: RegistroWithMuxInputBorrar // Project Name: // Target Devices: // Tool versions: // Description: // // D...
/* * yosys -- Yosys Open SYnthesis Suite * * Copyright (C) 2012 Clifford Wolf <> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * T...
#include <bits/stdc++.h> using namespace std; int pos, ans, a[20], b[20], cnt[12]; bool check(int pos, bool Ls, bool Rs) { if (pos == 0) return true; if (!Ls && !Rs) return true; int l = Ls ? a[pos] : 0, r = Rs ? b[pos] : 9; for (int i = l; i <= r; i++) if (cnt[i]) { cnt[i]--; ...
#include <bits/stdc++.h> using namespace std; int t, n, m; long long a, k, ak; char c; unordered_map<long long, bool> ma; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> t; for (int ti = 1; ti <= t; ++ti) { ma.clear(); cin >> n >> m; k = (1ll << m) - n; for (...
`include "logfunc.h" module pfmonitor_wp ( input clk ,input reset ,input logic coretopfm_dec_valid ,output logic coretopfm_dec_retry ,input SC_pcsign_type coretopfm_dec_pcsign ,input SC_robid_type coretopfm_dec_rid ,input SC_decwidth_type coretopfm_dec_decmask ...
/** * 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.Roger Wang. All rights reserved------------------ // // -- It to be define -- // -- ...
#include <bits/stdc++.h> #define ll long long using namespace std; int main() { ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ; int t; cin>>t; while(t--) { ll n,x,s=0,a=1; cin>>n>>x; ll arr[n]; for(int i=0; i<n; i++) ...
// $Id: c_rr_arbiter_base.v 5188 2012-08-30 00:31:31Z dub $ /* Copyright (c) 2007-2012, 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: Redistribu...
//---------------------------------------------------------------------------- // Copyright (C) 2009 , Olivier Girard // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must re...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 2016/06/08 19:17:16 // Design Name: // Module Name: timing_signal_generator // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencie...
#include <bits/stdc++.h> using namespace std; const int64_t N = 1e5 + 1; int64_t crt_node = 0, maxi = 0; vector<int64_t> previous; vector<vector<int64_t>> adj; void dfs(int64_t node, int64_t pere, int64_t len) { previous[node] = pere; if (len > maxi) { crt_node = node; maxi = len; } ...
#include <bits/stdc++.h> using namespace std; int n, m, w; int v[100010]; long long mark[100010]; bool test(long long x) { memset(mark, 0, sizeof mark); long long qnt = 0; long long sum = 0; for (int i = 0; i < n; ++i) { if (qnt > m) return false; sum -= mark[i]; long long va...
/* * 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, m; scanf( %d , &n); scanf( %d , &m); int f[n], b[m], a[m]; map<int, int> x; for (int i = 0; i < n; i++) { scanf( %d , &f[i]); if (x.find(f[i]) != x.end()) x[f[i]] = -1; else x[f[i]] = i; }...
#include <bits/stdc++.h> int n, m, k; int main() { long long ans = 1; scanf( %d%d%d , &n, &m, &k); if (k == n) { int mid = k / 2 + (k & 1); for (int i = 0; i < mid; ++i) ans = (ans * m) % 1000000007; printf( %I64d , ans); } else if (!(k % 2) && k < n) printf( %d , m); els...
#include <bits/stdc++.h> using namespace std; long long n, arr[55] = {}, sm = 0, dp[55][2] = {}; long long rec(int ind, bool dt) { if (ind == n - 1) { if (dt) return 0; else return arr[ind]; } if (dp[ind][dt] != -1) return dp[ind][dt]; if (dt) return dp[ind][dt] =...
/** * 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...
`define ADDER_WIDTH 017 `define DUMMY_WIDTH 128 `define 3_LEVEL_ADDER module adder_tree_top ( clk, isum0_0_0_0, isum0_0_0_1, isum0_0_1_0, isum0_0_1_1, isum0_1_0_0, isum0_1_0_1, isum0_1_1_0, isum0_1_1_1, sum, ); input clk; input [`ADDER_WIDTH+0-1:0] isum0_0_0_0, isum0_0_0_1, isum0_0_1_0, isum0_0_1_1, isum0_1_0_0,...
/* * PicoSoC - A simple example SoC using PicoRV32 * * Copyright (C) 2017 Claire Xenia Wolf <> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all co...
#include <bits/stdc++.h> using namespace std; vector<long long> t1, t2; long long a, b, n, k, q, day, val, p, t; void update1(long long i, long long l, long long r, long long qi, long long qx) { if (l + 1 == r) { t1[i] += qx; t1[i] = min(t1[i], a); return; } long lon...
/** * 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; typedef long long ll; //#define rep(i,a,b) for(int i=a;i<b;i++); void solve(){ ll n; cin>>n; string s; cin>>s; vector<ll>v; for(int i=0;i<n;i++){ if (s[i]== * ){ v.push_back(i); } } if (v.size()<=1 or v.size()==n){ cout<<0<<en...
#include <bits/stdc++.h> using namespace std; int n, a, b, k, tt; int tree1[800000], tree2[800000]; void updata1(int L, int R, int ro, int x, int v) { if (x < L || x > R) return; if (L == R && L == x) { tree1[ro] = min(v + tree1[ro], b); return; } int Mid = (L + R) / 2; updata1(L...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int main() { ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m; cin >> n >> m; long long a[n + 1]; for (int i = 1; i <= n; i++) cin >> a[i]; long long v, x, add = 0, y, q; int t; w...
#include <bits/stdc++.h> using namespace std; const int inf = 1e9 + 7; inline void rvi(vector<int>& v, int n) { int temp; for (int i = 0; i < n; i++) { cin >> temp; v.push_back(temp); } } inline void rvll(vector<long long int>& v, int n) { long long int temp; for (int i = 0; i ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { int n, m; cin >> n >> m; auto chk = [&](int x, int y) { return 0 <= x && x < n && 0 <= y && y < m; }; vector<int> nxt(n * m, -1)...
// megafunction wizard: %LPM_COUNTER%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: LPM_COUNTER // ============================================================ // File Name: dummy_cnt.v // Megafunction Name(s): // LPM_COUNTER // // Simulation Library Files(s): // lpm // ==============================...
#include <bits/stdc++.h> inline int abs(int n) { return n < 0 ? -n : n; } bool board[20][20]; int dx[] = {-3, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 3}; int dy[] = {0, 1, -1, 2, -2, 3, -3, 2, -2, 1, -1, 0}; int dfs(int p, int n, int m) { int mx = p, t, cnt = 0; for (int i = 0; i < n; i++) { 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 la...