text
stringlengths
59
71.4k
/* * 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...
`timescale 1ns/10ps module soc_system_sdram_pll( // interface 'refclk' input wire refclk, // interface 'reset' input wire rst, // interface 'outclk0' output wire outclk_0, // interface 'outclk1' output wire outclk_1, // interface 'locked' output wire locked ); altera_pll #( .fractional_vco_multiplie...
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; struct Edge { int to, cap, flow; }; struct Graph { int n; vector<vector<int> > e; vector<Edge> edges; vector<int> d, c; Graph() {} Graph(int _n) { n = _n; e.resize(n); } void addEdge(int from, in...
#include <bits/stdc++.h> using namespace std; int val_of_op[200]; int n; struct T { string Name, Expr; bool danger; int num[5]; int sum(int a0 = 0, int a1 = 0, int a2 = 0, int a3 = 0) { return num[a0] + num[a1] + num[a2] + num[a3]; } } macro[1000]; void Eliminate_Space(string &s) {...
// ------------------------------------------------------------- // // Generated Architecture Declaration for rtl of inst_a_e // // Generated // by: wig // on: Wed Jun 7 16:54:20 2006 // cmd: /cygdrive/h/work/eclipse/MIX/mix_0.pl -nodelta -bak ../../bitsplice.xls // // !!! Do not edit this file! Autogenerated by ...
#include <bits/stdc++.h> using namespace std; long long dp[300300]; int a[300300], h[300300], d[300300]; vector<int> ans; inline void calc(int i) { int mn = min(a[i], a[i + 1]); if (!mn) return; ans.push_back(i); a[i] -= mn, a[i + 1] -= mn; } int main() { int n; scanf( %d , &n); ...
`timescale 100 ps/100 ps module circuit_under_test ( clk, rst, testVector, resultVector, injectionVector ); input clk; input rst; input[7:0] testVector; output[7:0] resultVector; input[104:0] injectionVector; fir_inj toplevel_instance ( .x_in(testVector [7:0]), .clk(clk), .y(resultVector [7:0]), .p_desc0_p_O_FD(injecti...
Require Import NArith. Require FMapList. Require Import OrderedType. Require Import Word. Require Import ContractSem. Module AbstractExamples (W : Word). Module C := (ContractSem.Make W). Import C. (**** Now we are able to specify contractsin terms of how they behave over many invocations, returns from call...
#include <bits/stdc++.h> using namespace std; const int MAX = 300 + 5; int n, m, p; int grid[MAX][MAX]; int dp[MAX][MAX]; vector<pair<int, int> > pos[MAX * MAX]; vector<int> col[MAX]; int main() { scanf( %d %d %d , &n, &m, &p); for (int i = int(0); i < int(n); i++) { for (int j = int(0); j...
#include <bits/stdc++.h> using namespace std; bool pal(string s) { string b = s; reverse(b.begin(), b.end()); return b == s; } int main() { string s; cin >> s; for (int i = 0; i <= s.size(); ++i) { for (char a = a ; a <= z ; ++a) { string b = s.substr(0, i) + a + s.substr...
`timescale 1ns / 1ps module regfile( input [31:0] Aselect,//select the register index to read from to store into abus input [31:0] Bselect,//select the register index to read from to store into bbus input [31:0] Dselect,//select the register to write to from dbus input [31:0] dbus,//data in output [31:0] abu...
/** * 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 maxn = 1e2 + 10; char a[maxn], b[maxn], t[maxn]; int main() { int n; char c[1]; scanf( %d , &n); gets(c); scanf( %s , a + 1); int d = 0; while (d <= n) { d++; if (n % d == 0) { for (int i = 1; i <= d; i++) { ...
module lru_stats import bsg_cache_pkg::*; #(parameter `BSG_INV_PARAM(ways_p) ,localparam lg_ways_lp=`BSG_SAFE_CLOG2(ways_p) ) ( input clk_i ,input reset_i ,input stat_mem_v_i ,input stat_mem_w_i ,input [lg_ways_lp-1:0] chosen_way_i ); localparam ctr_width_lp = 17; localparam ma...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 17:50:33 01/10/2017 // Design Name: barrel_shifter // Module Name: /home/aaron/Git Repos/CSE311/lab1/barrel_shifter_tb.v // Project Name: lab1 // Target Device: //...
/** * 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 : processing_system7_bfm_v2_0_gen_reset.v * * Date : 2012-11 * * Description : Module that generates FPGA_RESETs and synchronizes RESETs to the * respective clocks. ************************************************...
#include <bits/stdc++.h> int64_t f(int64_t a, int64_t b, int64_t c, int64_t l) { int64_t total = 0; for (int64_t la = 0ll; la <= l; ++la) { int64_t x = std::min(a - b - c + la, l - la); if (x >= 0) total += (x + 1) * (x + 2) / 2ll; } return total; } int main() { int64_t a, b, c, l;...
#include <bits/stdc++.h> using namespace std; vector<int> g[100001]; long long v[100001]; pair<long long, long long> r[100001]; int mark[100001]; void dfs(int s) { mark[s] = 1; r[s] = pair<long long, long long>(0, 0); for (int i = 0; i < g[s].size(); i++) { if (!mark[g[s][i]]) { df...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int matrix[n][n], sum = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> matrix[i][j]; } } int j = 0; for (int i = 0; i < n; i++) { sum += matrix[i][i]; } fo...
#include <bits/stdc++.h> using namespace std; const int MAXN = 35000 + 10; const int MAXK = 55; int tree[MAXN << 2], info[MAXN << 2]; int dp[MAXK][MAXN]; int nums[MAXN]; int pre[MAXN], cur[MAXN]; void build(int node, int start, int end, int i) { if (start == end) { tree[node] = dp[i][start - 1...
#include <bits/stdc++.h> using namespace std; const long double eps = 1e-13; const long double PI = acos(-1); const int INF = (int)1e9; const long long INFF = (long long)1e18; const int mod = (int)1e9 + 7; const int MXN = (int)2e5 + 7; char s[MXN]; int cnt[MXN]; int num[MXN], num2[MXN], a[MXN]; bo...
#include <bits/stdc++.h> using namespace std; const long long inf = 3 * 1e18; long long mi[5], ma[5], low[5], high[5]; long long resx, resy, resz; long long div2(long long x, long long y) { if (x > 0 && y > 0 || x < 0 && y < 0) { long long f = 0; if (x % 2 && y % 2) f = 1; if (x > 0 && y...
#include <bits/stdc++.h> using namespace std; int main() { long int n, i; cin >> n; long int a[n]; for (i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); long long int sum = 0, j = 0; for (i = 0, j = n - 1; i < j; i++, j--) { sum = sum + ((a[i] + a[j]) * (a[i] + a[j]));...
#include <bits/stdc++.h> using namespace std; int64_t dfs(int64_t idx, int64_t p, vector<vector<int64_t>>& g, vector<int64_t>& parents, int64_t& c1, int64_t& c2) { int64_t n = g.size() - 1; parents[idx] = p; int64_t res = 1; int64_t mx = 0; for (auto& x : g[idx]) { if (x != p...
// (c) Copyright 1995-2014 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property // laws. // // DISCLAIMER // This disclaimer is not a license and does not grant ...
module system_pll(REFERENCECLK, PLLOUTCORE, PLLOUTGLOBAL, RESET); input REFERENCECLK; input RESET; /* To initialize the simulation properly, the RESET signal (Active Low) must be asserted at the beginning of the simulation */ output PLLOUTCORE; output PLLOUTGLO...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; int n, m, k, w; char ax[500005]; char bx[500005]; int Next[500005], next2[500005]; int sig[500005][2]; int hh[500005][2]; bool tepan() { int i, j, a, b; for (i = 1; i <= n; i++) { if (sig[i][0] == m) { w = max(1, i - k + 1); w =...
/***************************************************************************** * File : processing_system7_bfm_v2_0_arb_wr_4.v * * Date : 2012-11 * * Description : Module that arbitrates between 4 write requests from 4 ports. * *****************************************************************************/ modul...
#include <bits/stdc++.h> using namespace std; int main() { int n, ans = -1; cin >> n; int a[n], l[n], r[n]; for (int i = 0; i < n; ++i) cin >> a[i]; for (int i = 0, des = 0; i < n; ++i) { ++des; l[i] = des = min(des, a[i]); } for (int i = n - 1, des = 0; i >= 0; --i) { ...
//////////////////////////////////////////////////////////////////////////////// // Original Author: Schuyler Eldridge // Contact Point: Schuyler Eldridge () // sqrt_pipelined.v // Created: 4.2.2012 // Modified: 4.5.2012 // // Implements a fixed-point parameterized pipelined square root // operation on an unsig...
#include <bits/stdc++.h> using namespace std; struct rangeincrease { int l, r; }; rangeincrease actions[100001]; rangeincrease inprogress[100001]; int actionL = 0; int nums[100001]; int opened = 0; int main() { int n; int i; cin >> n; for (i = 1; i <= n; i++) { cin >> nums[i]...
#include <bits/stdc++.h> using namespace std; void solve() { long long st = 1, mod = 998244353; int n; cin >> n; vector<long long> ans(n + 1); ans[n] = 10; ans[n - 1] = 20; for (int i = n - 2; i >= 1; i--) { ans[i] = ans[i + 1] + 9; } for (int i = n - 1; i >= 1; i--) { ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: Muhammad Ijaz // // Create Date: 08/13/2017 11:49:08 AM // Design Name: // Module Name: VICTIM_CACHE // Project Name: RISC-V // Target Devices: // Tool Versions: // Des...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2011 by Wilson Snyder. module t; typedef logic [3:0] mc_t; typedef mc_t tocast_t; typedef struct packed { logic [15:0] data; } packed_t; packed_t pdata; ass...
// Copyright (c) 2015 CERN // @author Maciej Suminski <> // // This source code is free software; you can redistribute it // and/or modify it in source code form under the terms of the GNU // General Public License as published by the Free Software // Foundation; either version 2 of the License, or (at your option) // ...
#include <bits/stdc++.h> using namespace std; template <typename T> inline string toString(T a) { ostringstream os( ); os << a; return os.str(); } template <typename T> inline long long toLong(T a) { long long res; istringstream os(a); os >> res; return res; } template <type...
/* * yosys -- Yosys Open SYnthesis Suite * * Copyright (C) 2012 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 copies. * ...
/* * Copyright (c) 2013, Quan Nguyen * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this * list of conditi...
#include<iostream> using namespace std; int main() { int t; cin>>t; while(t--){ int a,b; cin>>a>>b; if(a==0&&b==0) cout<< 0 n ; else if(a==0&&b!=0) cout<<2*b-1<<endl; else if(a!=0&&b==0) cout<<2*a-1<<endl...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 17:18:58 01/29/2016 // Design Name: // Module Name: latch_EX_MEM // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } string str; cin >> str; bool flag = 0; int start = 0; set<int> s; for (int i = 0; i < str.length(); i++) { if (!flag && str[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 mxn = 2000; int x[mxn]; int main() { int n, a, b; cin >> n >> a >> b; for (int(i) = (0); (i) < (n); (i)++) cin >> x[i]; sort(x, x + n); cout << x[n - a] - x[n - a - 1]; }
#include <bits/stdc++.h> using namespace std; using namespace std; const int N = 1e6 + 100; const int inf = 1e9 + 100; int n, w, m, a[N], seg[N << 2]; long long fen[N]; void change(int dex, int val, int v = 1, int s = 0, int e = N) { if (dex < s || e <= dex) { return; } if (e - s == 1) {...
/** * 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...
// part of NeoGS project (c) 2007-2008 NedoPC // // interrupt controller for Z80 module timer( input wire clk_24mhz, input wire clk_z80, input wire [2:0] rate, // z80 clocked // 3'b000 -- 37500/1 // 3'b001 -- 37500/2 // 3'b010 -- 37500/4 // 3'b011 -- 37500/8 // 3'b100 -- 37500/16 // 3'...
`timescale 1 ns / 1 ps module audio_direct_v1_1 # ( // Users to add parameters here // User parameters ends // Do not modify the parameters beyond this line // Parameters of Axi Slave Bus Interface S_AXI parameter integer C_S_AXI_DATA_WIDTH = 32, parameter integer C_S_AXI_ADDR_WIDTH = 5 ) ( // Us...
#include <bits/stdc++.h> using namespace std; bool isprime(long long n) { if (n == 1) return false; if (n == 2) return true; for (long long i = 2; i <= sqrt(n); i++) { if (n % i == 0) { return false; } } return true; } long long poww(long long b, long long e) { if (e ...
/** * 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 t; cin >> t; int n[t], sum = 0; for (int i = 0; i < t; i++) { cin >> n[i]; } for (int i = 0; i < t; i++) { if (n[i] % 2 == 0) { sum = (n[i] / 2) - 1; } else { sum = n[i] / 2; } cout <...
`default_netype none module memory_resource_controller #( parameter P_MEM_ADDR_N = 22 )( input wire iCLOCK, input wire inRESET, input wire iRESET_SYNC, //IF0 input wire iIF0_ARBIT_REQ, output wire oIF0_ARBIT_ACK, input wire iIF0_ARBIT_FINISH, input wire iIF0_ENA, output wire oIF0_BUSY, input w...
#include <bits/stdc++.h> using namespace std; int prime[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31}; vector<int> next(vector<int>& a, int p, int k) { vector<int> result; for (long long mul = 1; mul <= (long long)k; mul *= p) { for (int i = 0; i < a.size(); ++i) { long long newN = (long long...
#include <bits/stdc++.h> using namespace std; double __begin; template <typename T1, typename T2, typename T3> struct triple { T1 a; T2 b; T3 c; triple(){}; triple(T1 _a, T2 _b, T3 _c) : a(_a), b(_b), c(_c) {} }; template <typename T1, typename T2, typename T3> bool operator<(const tri...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2014 Xilinx, Inc. // All Right Reserved. /////////////////////////////////////////////////////////////////////////////// // ____ ____ // / /\/ / // /___/ \ / Vendor : Xilinx // \ \ \/ Vers...
#include <bits/stdc++.h> using namespace std; const long long INF = (1ll << 45); long long bit[1000006]; void update(long long from, long long val) { for (long long i = from; i < 1000006; i += i & -i) bit[i] += val; } long long query(long long from) { if (from == 0) return 0; long long cnt = 0; ...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int maxn = 1e5 + 7; int n, x; int main() { cin >> n >> x; int ans = 0, num = 0; if (n == 2 && x == 0) { puts( NO ); return 0; } puts( YES ); if (n == 1) printf( %d , x); else if (n == ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
`timescale 1ns / 1ps //////////////////////////////////// //Zachary Karpinski //Karpentium Processor // //instruction_register.v // //A load/store register for the instuctions with the control table // ls clr function // d 1 clear register // 0 0 store // 1 0 load // /////////////////////////////////// ...
#include <bits/stdc++.h> #define ll long long #define real long double #define fr(i,l,n) for(ll i=l;i<n;i++) #define br cout<< n #define al(fu) (fu).begin(), (fu).end() #define prl(c) cout<<(c)<< n #define prv(v) {fr(qz,0,v.size()) cout<<(v)[qz]<< ; br;} #define alr(fu) (fu).rbegin(), (fu).rend() ...
#include <bits/stdc++.h> using namespace std; string s, s2, t1, t2; int main() { long long n, l, r, i, j; cin >> s; n = s.length(); char mx = a ; for (i = n - 1; i >= 0; i--) { if (s[i] - mx >= 0) { mx = s[i]; l = i; } } s2 += mx; r = l; for (i = mx...
// $Id: c_dff.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: Redistributions of sou...
// 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 : Wed Mar 01 09:54:28 2017 // Host : GILAMONSTER running 64-bit major release (...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e12; const int INF1 = 1e7; const int maxn = 100000 + 10; int n, m, k; int fd, u, v, w; struct node { int to, cost, fd; } a[maxn], b[maxn]; bool cmp(node f, node g) { return f.fd < g.fd; } bool cmp1(node f, node g) { return f.fd...
#include <bits/stdc++.h> using namespace std; const int maxn = (1e6) + 7; const int inf = (1e9) + 7; const long long LLinf = (1e18) + 7; const long double eps = 1e-9; const long long mod = 1e9 + 7; const int maxlog = 31; stack<pair<int, int> > stos; int tab[maxn]; int lewo[maxn]; int prawo[maxn]; ...
/* * 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 = 100005; struct edge { int to, index; edge(int t = 0, int i = 0) { to = t; index = i; } }; vector<edge> g[N]; int num[N], ans[N], dep[N], fa[18][N], n, m; void add(int from, int to, int index) { g[from].push_back(edge(to, i...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } int time = INT_MAX, check = 0; for (int i = 0; i < n; i++) { check = 0; int no = a[i]; for (int j = 0; j < no; j++) { int ite...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n == 1) cout << 1 << << 1 << n << 1; else cout << 2 * (n - 1) << << 2 << n << 1 << << 2; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int x, y; cin >> x >> y; int tx = x - y; int ty = x + y; x = tx; y = ty; if (x < 0) cout << -1 n ; else { int l = 1, r = 1e9 + 5; while (r - l > 1) { int mid = (l + ...
//Legal Notice: (C)2013 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> #pragma comment(linker, /STACK:200000000 ) using namespace std; template <typename T> inline T Abs(T x) { return (x >= 0) ? x : -x; } template <typename T> inline T sqr(T x) { return x * x; } template <typename T> string toStr(T x) { stringstream st; st << x...
// *************************************************************************** // *************************************************************************** // Copyright 2014 - 2017 (c) Analog Devices, Inc. All rights reserved. // // In this HDL repository, there are many different and unique modules, consisting // of...
////////////////////////////////////////////////////////////////////// //// //// //// speedCtrlMux.v //// //// //// //// This file is part of the usbhos...
#include <bits/stdc++.h> using namespace std; int main() { int n, ar[110]; while (cin >> n) { for (int i = 0; i < n; i++) { cin >> ar[i]; } if ((n % 2 == 1) && (ar[0] % 2 == 1) && (ar[n - 1] % 2 == 1)) cout << Yes << endl; else cout << No << endl; } ...
/*============================================================================= Testbench for Serial SPI Bus EEPROM Simulation Model =============================================================================*/ `include "M95XXX_Parameters.v" //This defines the parameter file for M95080-W6, "W" or "G" F6SP36% proc...
// ---------------------------------------------------------------------- // Copyright (c) 2016, The Regents of the University of California All // rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met:...
#include <bits/stdc++.h> using namespace std; int n, m; const int sz = 1 << 13; vector<int> gos[5001]; int rev[5001]; template <class T> class Dinic { struct _edge { int x, y; T c, rc; _edge(int x, int y, T c, T rc) : x(x), y(y), c(c), rc(rc) {} }; int s, e; int n; ve...
#include <bits/stdc++.h> #include<cmath> using namespace std; int main(){ long long t; cin>>t; while(t--){ int a,b,n; long long ans=0; cin>>a>>b>>n; int ar[a+1],br[b+1],arr[2][n]; memset(ar,0,sizeof(ar)); memset(br,0,sizeof(br)); ...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.3 (win64) Build Mon Oct 10 19:07:27 MDT 2016 // Date : Wed Nov 01 12:03:22 2017 // Host : vldmr-PC running 64-bit Service Pack 1 ...
#include <bits/stdc++.h> using namespace std; int main(void) { int t; cin >> t; while (t--) { long long n, x, sum = 0, ans = 0, cur; cin >> n >> x; priority_queue<long long> nums; for (int i = 0; i < n; ++i) { cin >> cur; nums.push(cur - x); } for (int...
#include <bits/stdc++.h> using namespace std; int n, m, k; vector<int> ini[100005]; vector<int> mat[100005]; int maior[100005]; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { int a; cin >...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int k; cin >> k; k += 2000; cout << 2000 << n ; cout << -1 << ; for (int i = 0; i < 1999; i++) { if (k > 1000000) { cout << 1000000 << ; ...
#include <bits/stdc++.h> using namespace std; bool chk[5000050]; int ara[5000050], sum[5000050]; void sieve() { int i, j, k, x, y, z; for (i = 2; i <= 5000000; i++) if (!chk[i]) { for (j = i; j <= 5000000; j += i) { x = 0; k = j; while (k % i == 0) { ...
#include <bits/stdc++.h> using namespace std; const int M = 100004; unordered_map<string, int> mp; unordered_set<int> st[M]; vector<int> g[M]; string s[M]; int m = 0; int getid(string &t) { if (mp.count(t)) return mp[t]; else { s[++m] = t; return mp[t] = m; } } int val[...
/** * 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 MX = 100 + 3; int n, m, k; bool mat[MX][MX], tmp[MX][MX]; void solve1() { int q = (1 << m); int cnt = 0; int ans = 20; for (int z = 0; z < q; z++) { cnt = 0; memset(tmp, false, sizeof(tmp)); for (int j = 0; j < m; j++) {...
#include <bits/stdc++.h> typedef struct smirror { int left, right, score; } mirror; int max(int a, int b) { return a > b ? a : b; } int shoot_in(double x, mirror a[]) { for (int i = 1; i <= a[0].score; ++i) if (a[i].left <= x && x <= a[i].right) return i; return -1; } int deal(int n, mirro...
module ememory # (parameter AW = 32, // address width parameter PW = 104, // packet width parameter IDW = 12, // ID width parameter DEPTH = 65536, // memory depth parameter NAME = "emem", // instance name parameter WAIT = 0, // enable random wait parameter MON = 0 ...
#include <bits/stdc++.h> using namespace std; const int N = 300000; const long long INF = (1 << 30) - 1; int n; long long a[N + 9], sum[N + 9]; void into() { scanf( %d , &n); for (int i = 1; i <= n; ++i) { scanf( %lld , &a[i]); sum[i] = a[i] + sum[i - 1]; } } int ans; void Get_...
#include <bits/stdc++.h> using namespace std; const int N = 4010; int n, a, b; vector<pair<int, int>> ans; deque<int> s[3]; inline void print() { if (n == 1248) for (pair<int, int> p : ans) printf( %d %d n , p.first, p.second); } inline void move(int tp, int c) { if (!c) return; if (tp...
// (C) 2001-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 doc...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<long long, long long>; const long long INF = 2e18; template <class A, class B> ostream &operator<<(ostream &os, const pair<A, B> &p) { os << ( << p.first << , << p.second << ) ; return os; } template <clas...
#include <bits/stdc++.h> using namespace std; long long int k, v, n, m, ans, sum, sum1, l, r, i, j, mx, mn, c, z, x, y, a[111111], d[111111], t[111111]; string s, sos, ss; char ch; bool used[111111]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; cout << (n - 1) / 2; ...
/* * 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> int main(int argc, char const *argv[]) { int n, i; scanf( %d , &n); getchar(); char row[n]; for (i = 0; i < n; ++i) { row[i] = getchar(); } if (n == 1 && row[0] == 0 ) { printf( No n ); return 0; } for (i = 1; i < n; ++i) { if (row[...
#include <bits/stdc++.h> using namespace std; const int MAXN = 105; bool dmy[MAXN][MAXN][MAXN]; void dfs(int d, int m, int y, int bd, int bm, int by) { if (dmy[bd][bm][by]) return; dmy[bd][bm][by] = true; if (bm > 12) return; if (bd > 31) return; if (!(by % 4) && bm == 2 && bd > 29) return; ...
// ============================================================================ // Copyright (c) 2013 by Terasic Technologies Inc. // ============================================================================ // // Permission: // // Terasic grants permission to use and modify this code for use // in synthesis 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 la...