text
stringlengths
59
71.4k
`timescale 1 ns / 1 ps module test; /* verilator lint_off STMTDLY */ reg clk, rst; reg [15:0] fm_data[0:65535]; reg [10:0] psg_data[0:21000]; reg [15:0] fm_snd=16'd0; initial begin $readmemh("data.hex",fm_data); $readmemh("psg.hex",psg_data); end `ifdef FINISH_AT initial #((`FINISH_AT)*1000_000) $finish...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 00:59:48 04/01/2015 // Design Name: crc // Module Name: /home/christopher/Documents/RL02Controller/RL02Controller/crc_tb.v // Project Name: RL02Controller // Target ...
#include <bits/stdc++.h> using namespace std; long long max(long long a, long long b) { if (a > b) { return a; } else { return b; } } long long min(long long a, long long b) { if (a < b) { return a; } else { return b; } } struct P { double x, y; P() {}...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 3; const int M = 26; char s1[N], s2[N]; int z1[N][M], z2[N][M]; int n; bool check(int l1, int r1, int l2, int r2) { int l, i, t1, t2; for (i = 0; i < M; ++i) { t1 = z1[r1 - 1][i]; if (l1) t1 -= z1[l1 - 1][i]; t2 = ...
#include <bits/stdc++.h> using namespace std; const int MAXN = (int)1e5 + 10; int sx[MAXN], sy[MAXN], sz[MAXN]; char s[MAXN]; void solve(int x, int y, int z) { if (x + y + z < 3) { printf( YES n ); return; } int e = (x + y + z) / 3; vector<int> v; v.push_back(x); v.push_bac...
#include <bits/stdc++.h> using namespace std; char S[111111]; long long cnt1[26], cnt2[26 * 26]; int main() { scanf( %s , S); int len = strlen(S); for (int i = 0; i < len; i++) { for (int j = 0; j < 26; j++) cnt2[26 * j + S[i] - a ] += cnt1[j]; cnt1[S[i] - a ]++; } long long an...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2016 Xilinx, Inc. // // 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 // //...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 2014/03/12 13:10:34 // Design Name: // Module Name: filter_tb // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Rev...
`timescale 1ns / 1ps `define SIMULATION module mult_32_TB; reg clk; reg rst; reg reset; reg start; reg [15:0]in_A; reg [15:0]in_B; wire [31:0] pp; wire done; mult_32 uut (.clk(clk) , .rst(rst) , .init(start) , .A(in_A) , .B(in_B) , .pp(pp) , .done(done)); parameter PERIOD ...
// Copyright (c) 2015 CERN // 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) // any late...
#include <bits/stdc++.h> using namespace std; const long long maxn = 1e6 + 10, M = 20, mo = 1e9 + 7; vector<vector<long long> > f, sum; vector<long long> g; long long a[maxn], c[maxn]; long long n, l, k, K, B, ans, i, j, z, x, y, N, r; int main() { scanf( %lld%lld%lld , &n, &l, &k); g.push_back(0)...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, c; cin >> n >> m >> c; vector<int> A(n), B(m); for (auto &a : A) cin >> a; for (auto &b : B) cin >> b; int i = 0, x = 0; for (int i = 0; i < n; ++i) { if (i < m) x = (x + B[i]) % c; if (i > n - m) x = (x - B...
#include <bits/stdc++.h> using namespace std; int main() { int tosub = 0; int pls = 1; int mins = 0; string s; char a; cin >> a; while (a != = ) { if (a == + ) { s.push_back(a); pls++; } else if (a == - ) { mins++; s.push_back(a); } ...
#include <bits/stdc++.h> using namespace std; int main() { long long i, j, d = 0, e = 0, f = 0, sum = 0, c = 0, n; cin >> n; char a[4][4]; map<int, int> m; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { cin >> a[i][j]; } } for (i = 0; i < 4; i++) { for (j =...
#include <bits/stdc++.h> const int N = 1050000; const double pi = acos(-1.0); int a[N], ans[N], rev[N << 1]; std::complex<double> b[N << 1]; void FFT(std::complex<double> *a, int n, int f) { for (int i = 0; i < n; i++) if (i < rev[i]) std::swap(a[i], a[rev[i]]); for (int i = 1; i < n; i <<= 1) {...
#include <bits/stdc++.h> using ll = long long; using ld = long double; using ull = unsigned long long; using namespace std; const int N = 1e5 + 2, SQ = 400; int n, q, a[N], jump[N], cost[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> q; for (int i = (0); 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...
/* * 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...
///////////////////////////////////////////////////////////////////// //// //// //// OpenCores MC68HC11E based SPI interface //// //// //// //// Author: Richard Herveille ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int arr[n + 1]; int i, s = 0; for (i = 0; i < n; i++) { cin >> arr[i]; } int j; for (i = 1; i < n - 1; i++) { if (arr[i - 1] < arr[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 law...
#include <bits/stdc++.h> const int offs = 350; int n, d, f[30005][705], gem[30005]; int main() { scanf( %d%d , &n, &d); for (int i = 0, t; i < n; i++) scanf( %d , &t), gem[t]++; memset(f, -1, sizeof(f)); f[d][offs] = gem[d]; for (int i = d + 1, t; i < 30005; i++) for (int j = 0; j < 705 ...
// EE 454 // Spring 2015 // Lab 2 Part 2 // John Timms // accumulator_processor.v `timescale 1 ns / 100 ps module accumulator_processor (clk, reset, op, signal, read, write, req, grant, state); input clk, reset, signal, grant; input [1:0] op; input [31:0] read; output [31:0] write; output req; output [6:0] state;...
#include <bits/stdc++.h> using namespace std; const int maxl = 2 * 1000 * 100 + 5; const int maxlg = 22; vector<pair<int, int> > adj[maxl]; vector<int> tree[maxl]; int n, m, q; int mark[maxl], depth[maxl]; bool cut[maxl]; int dsu[maxl]; int arr[maxl]; int lca[maxl][maxlg]; int psum1[maxl], psum2...
/* * Copyright (C) 2009 Onno Kortmann <> * * 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 2 of the License, or * (at your option) any later version. * * This program ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int arr[n]; map<int, int> m; for (int i = 0; i < n; i++) { cin >> arr[i]; if (arr[i] != 0) { m[arr[i]]++; } } cout << m.size() << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long n, a[300005], tp, lt, ans; int main() { cin >> n; for (int i = 1; i <= n; i++) scanf( %lld , &a[i]); for (int i = 1; i <= n; i++) { tp = min(a[i] / 2, lt); lt -= tp; a[i] -= tp * 2; ans += tp + a[i] / 3; lt += a[i] %...
#include <bits/stdc++.h> using namespace std; int main() { long long sum = 0; string s; cin >> s; s += a ; int now_number = 0, buf_number = 0, size_buf = 0, point = 0; for (int i = 0; i < s.size(); ++i) { if (s[i] >= a && s[i] <= z ) { now_number = now_number * pow(10, size...
#include <bits/stdc++.h> using namespace std; long long int abs(long long int a, long long int b) { if (a < b) { return -1 * (a - b); } return (a - b); } bool comp(long long int a, long long int b) { if (a > b) { return true; } return false; } int main() { int n, a, b...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; int ans[maxn]; vector<int> xs[maxn], ys[maxn]; struct query { int l, r, d, u, id; query(int aa, int bb, int cc, int dd, int ee) { l = aa; r = bb; d = cc; u = dd; id = ee; } query() {} }; ...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); long long l, r; long long g(long long x) { long long t = 1; while (t <= x) t *= 10; return (t - 1 - x) * x; } int n, m; const char let[] = ACGT ; char buf[1600]; int len[16]; int a[16][16]; vector<int> st; s...
#include <bits/stdc++.h> using namespace std; int main() { vector<int> seq; int n; long e; cin >> n; int first = 0; long long s = 0; int f = 0; for (int i = 0; i < n; i++) { cin >> e; if (e != 1) { s += e; f++; } else { first++; } ...
#include <bits/stdc++.h> using namespace std; int n, m, a[100001]; long long s[100001], ans[100001]; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + n + 1); reverse(a + 1, a + n + 1); for (int i = 1; i <= n; i++) s[i] = s[i - 1] + a[i]; cin >> m; for ...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, m; cin >> n >> m; double num; num = (double)m / n; if (n == m) { cout << 0 ; } else { long long int x = num, counter1 = 0, counter2 = 0; if (ceil(num) == num) { if (x % 2 == 0 || x % 3 == 0...
////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2013, Andrew "bunnie" Huang // // See the NOTICE file distributed with this work for additional // information regarding copyright ownership. The copyright holder // licenses this file to you under the Apache License...
`timescale 1 ns / 1 ns ////////////////////////////////////////////////////////////////////////////////// // Company: Rehkopf // Engineer: Rehkopf // // Create Date: 01:13:46 05/09/2009 // Design Name: // Module Name: address // Project Name: // Target Devices: // Tool versions: // Description: Address logic w/ S...
#include <bits/stdc++.h> using namespace std; unsigned long long x1, out; unsigned long long Fac(unsigned long long x1) { unsigned long long out = 1; for (int i = 1; i <= x1; i++) out = out * i; return out; } unsigned long long Cnk(unsigned long long a, unsigned long long b, ...
#include <bits/stdc++.h> using namespace std; int main() { string str; cin >> str; stack<char> s; map<char, char> type = {{ ( , ) }, { { , } }, { < , > }, { [ , ] }}; int ans = 0; for (auto it : str) { if (it == { || it == ( || it == < || it == [ ) { s.push(it); ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const int mod = 1e9 + 7; void show2d(const vector<vector<int>>& adj) { for (auto x : adj) { for (auto y : x) { cout << y << ; } cout << n ; } } long long int modexp(long long int a, long long int b, l...
// 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 : Thu May 25 15:17:13 2017 // Host : GILAMONSTER running 64-bit major release (...
/* This file is part of JT12. JT12 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 (at your option) any later version. JT12 is distributed in the hope tha...
/////////////////////////////////////////////////////////////////////////////// // // Copyright 2010-2012 by Michael A. Morris, dba M. A. Morris & Associates // // All rights reserved. The source code contained herein is publicly released // under the terms and conditions of the GNU Lesser Public License. No part of...
#include <bits/stdc++.h> using namespace std; int rec[40][40][40][40], con[40][40][40][40], r[40][40]; int main() { int n, m, q, a, c, b, d, i, j, k, l; string s[50]; scanf( %d %d %d , &n, &m, &q); for (i = 0; i < n; i++) { cin >> s[i]; } for (i = 0; i < n; i++) { for (j = 0; j...
#include <bits/stdc++.h> using namespace std; const int maxN = 2000 * 100 + 100; vector<pair<int, int> > c[maxN]; bool mark[maxN]; bool used[maxN]; int arr[maxN], ind; int st[maxN]; struct Ans { int x, y, z; }; void dfs(int s) { mark[s] = true; st[s] = ind; arr[ind++] = s; for (a...
#include <bits/stdc++.h> using namespace std; long long a[31]; int main() { long long t, n; long long q = 0; cin >> t; for (int i = 0; i <= 29; i++) { a[i] = pow(2, i); } for (int i = 1; i <= t; i++) { cin >> n; if (n % 2 == 0) { q = (n + 1) * (n / 2); } els...
#include <bits/stdc++.h> using namespace std; struct Point { double x, y; Point() {} Point(double a, double b) { x = a; y = b; } Point operator+(Point who) { return {x + who.x, y + who.y}; } Point operator-(Point who) { return {x - who.x, y - who.y}; } Point operator/(double ...
#include <bits/stdc++.h> using namespace std; int dp[2][100100]; int visit[100100]; int v[100100]; int main() { int i, j; int n, m; while (scanf( %d %d , &n, &m) != EOF) { memset(dp, 0, sizeof(dp)); for (i = 1; i <= n; i++) { scanf( %d , &v[i]); if (v[i] < 0) { ...
// Copyright 2009, Brian Swetland. Use at your own risk. // Hacked by Travis Geiselbrecht, 2009-2012 /* * Copyright (c) 2011-2012 Travis Geiselbrecht * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files * (the "Software"), to deal 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 law...
#include <bits/stdc++.h> using namespace std; int min(int a, int b) { if (a < b) return a; return b; } int Abs(int a) { if (a < 0) return -a; else return a; } double Abs(double a) { if (a < 0) return -a; else return a; } unsigned long long sqr(unsigned lon...
#include <bits/stdc++.h> using namespace std; inline int solve(int w, int h, int S) { if (S == (2 * w + 1) * (2 * h + 1)) return 2 * (w + 1) * (h + 1) - 1; if (S > (2 * w + 1) * (2 * h + 1)) return 0; S = (2 * w + 1) * (2 * h + 1) - S; if (S & 3) return 0; S /= 4; int res = 0; for (int w...
#include <bits/stdc++.h> using namespace std; const int H_MAX = 100100; const int N_MAX = 200100; int H, N; int layers[H_MAX]; int tree1[N_MAX]; int tree2[N_MAX]; int main() { N = 0; cin >> H; for (int i = 0; i <= H; i++) { cin >> layers[i]; N += layers[i]; } assert(layer...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 12/13/2015 11:06:55 AM // Design Name: // Module Name: SD_Control // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // //...
//-------------------------------------------------------------------------------- // Project : SWITCH // File : gmii_if.v // Version : 0.2 // Author : Shreejith S // // Description: GMII Interface Description - XILINX // //----------------------------------------------------------------------------- //...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); long count[] = {0, 0, 0, 0}; long n; cin >> n; while (n--) { long x; cin >> x; count[x] += 1; } cout << min(min(count[1] + count[2], count[1] + count[3]), ...
#include <bits/stdc++.h> using namespace std; const int max_n = 300005; int n, m; int p[max_n]; int rk[max_n]; bool vis[max_n]; vector<int> G[max_n]; set<int> s; void dfs(int u) { for (auto v : G[u]) s.erase(rk[v]); vector<int> can; for (auto v : s) { if (v < rk[u]) { v = p[v...
module top ( fpga_clk_50, fpga_reset_n, fpga_led_output, memory_mem_a, memory_mem_ba, memory_mem_ck, memory_mem_ck_n, memory_mem_cke, memory_mem_cs_n, memory_mem_ras_n, memory_mem_cas_n, memory_mem_we_n, memory_mem_reset_n, memory_mem_dq, memory_mem_dqs, memory_mem_dqs_n,...
module main( // clocks input fclk, output clkz_out, input clkz_in, // z80 input iorq_n, input mreq_n, input rd_n, input wr_n, input m1_n, input rfsh_n, output int_n, output nmi_n, output wait_n, output res, inout [7:0] d, input [15:0] a, // zxbus and related output csrom, ...
/** * 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 n, m, nn = 0, range; int a, b, c, d, pos, neg, ok = 1, finddd = 0; int ara[200], ara2[200]; scanf( %d %d , &n, &m); for (int i = 0; i < n; i++) { scanf( %d %d , &ara[i], &ara2[i]); if (ara2[i] == m || ara[i] == m) { ...
/** * 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; constexpr int N = 3e3; uint16_t a[N], lst[N], nxt[N], cnxt[20], dp[N][N]; int main() { cin.tie(0), ios::sync_with_stdio(0); int t, n; cin >> t; while (t--) { cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i], --a[i]; } ...
#include <bits/stdc++.h> using namespace std; int T[1000010][30], cnt = 0, fa[1000010]; char s[400010]; struct Q { int id, x; }; int A[400010], val[400010]; vector<Q> g[1000010]; vector<int> gg[1000010]; queue<int> q; void insert(int id) { int f = 0, i, v; for (i = 0; s[i]; i++) { ...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; const int Mod = 1000000007; const int INF = 0x3f3f3f3f; const long long LL_INF = 0x3f3f3f3f3f3f3f3f; const double e = exp(1); const double PI = acos(-1); const double ERR = 1e-10; int main() { long long n; scanf( %lld , &n...
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:200000000 ) const double EPS = 1E-9; const int INF = 1000000000; const long long INF64 = (long long)1E18; const double PI = 3.1415926535897932384626433832795; string s[110000]; int n, k, z[110][110], dp[1100000]; char buf[11...
/*------------------------------------------------------------------------------ * 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> using namespace std; struct node { long long st, en; node() {} node(long long _st, long long _en) : st(_st), en(_en) {} }; int main() { int n, b, t, d; long long etime[200000]; long long ftime; int qlen = 0; cin >> n >> b; cin >> t >> d; etime[0] ...
#include <bits/stdc++.h> using namespace std; template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } const double EPS = 1e-9; const double PI = acos(-1.); const int INF = 1e9; const int MAXN = 2e5 + 5; const long long MOD = 1e9 + 7; void output_path(int n, int a, int b, int c, 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...
// Copyright 1986-2015 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2015.4 (lin64) Build Wed Nov 18 09:44:32 MST 2015 // Date : Thu Aug 25 17:35:25 2016 // Host : fpgaserv running 64-bit Ubuntu 14.04.4 LTS ...
/* * 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 2013(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // ar...
#include <bits/stdc++.h> long long k, L, R, a[2222222], b[2222222], ans, sum[2222222]; int n, r; long long min(long long a, long long b) { return a < b ? a : b; } long long max(long long a, long long b) { return a > b ? a : b; } bool check(long long x) { long long ans = 0, now = 0; memset(b, 0, sizeof...
/** * 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 2014 - 2017 (c) Analog Devices, Inc. All rights reserved. // // In this HDL repository, there are many different and unique modules, consisting // of...
#include<bits/stdc++.h> using namespace std; typedef long long int ll; ll mod=1e9+7; int main() { int t; cin>>t; while(t--) { ll n,k; cin>>n>>k; ll ans=1; for(ll i=0;i<k;i++) { ans=(ans*n)%mod; } cout<<ans<<endl; } }
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2018.2 // Copyright (C) 1986-2018 Xilinx, Inc. All Rights Reserved. // // ============================================================== `timescale 1 ns / 1...
#include <bits/stdc++.h> using namespace std; template <class T> T abs(T x) { if (x < 0) return -x; return x; } template <class T> T sqr(T a) { return a * a; } const double pi = acos(-1.0); const double eps = 1e-8; int ar[150010]; int flag[150010]; int i, n; int main() { while ...
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 10; long long arr[MAX], arr2[MAX]; int n, m; bool check(long long mid) { int prv = 0; for (int i = 0; i < n; ++i) { while (prv < m && arr2[prv] + mid < arr[i]) ++prv; if (prv == m || arr2[prv] - mid > arr[i]) return 0; ...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MAXN = 1e5 + 5; ll x; string s; int ans[MAXN]; void init() { ; ; } void solve(int casei) { ll n = s.length(); s = # + s; for (int i = 1; i <= n; ++i) { ans[i] = -1; } for (int i = 1; i <= ...
#include <bits/stdc++.h> using namespace std; int kk[(100010)]; map<int, int> possible; int main() { int t, m, k, tj, rj, pre(0); bool first(false), already(false); scanf( %d , &t); for (int i = 0; i < t; ++i) { first = false; already = false; pre = 0; possible.clear(); ...
#include <bits/stdc++.h> using namespace std; long long int power(long long int a, long long int b) { long long int result = 1; while (b > 0) { int lastbit = (b & 1); if (lastbit) { result = (result * a); } a = (a * a); b = b >> 1; } return result; } long lo...
/** * 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; bool cmp(int a, int b) { return a > b; } int h[2005]; int main() { int i, n, a, b, ans = 0; scanf( %d %d %d , &n, &a, &b); for (i = 0; i < n; ++i) scanf( %d , &h[i]); sort(h, h + n, cmp); if (h[a - 1] > h[a]) ans = h[a - 1] - h[a]; printf( %d...
#include <bits/stdc++.h> using namespace std; int main(int argc, const char* argv[]) { int x1, x2, y1, y2, dx, dy, px, py; cin >> x1 >> y1 >> x2 >> y2 >> px >> py; dx = abs(x2 - x1); dy = abs(y2 - y1); if (dx % px != 0 || dy % py != 0) { cout << NO ; exit(0); } int a = dx / ...
/** * 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; long long mod = 1e9 + 7; vector<long long> fact(10005); long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long power(long long x, long long y) { long long temp; if (y == 0) return 1; temp = power(x, ...
// // Copyright (c) 2014 Jan Adelsbach <>. // 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 Foundation, either version 3 of the License, or // (at your optio...
// 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 : Sun Jan 22 23:56:44 2017 // Host : TheMosass-PC running 64-bit major release ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int tt; cin >> tt; while (tt--) { int n; cin >> n; vector<int> a(n + 1); for (int i = 1; i <= n; i++) { cin >> a[i]; } int lo = 1, hi = n; while (...
// megafunction wizard: %RAM: 1-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: ram.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // ====================================...
#include <bits/stdc++.h> using namespace std; long long n, k, a, b; long long mini = (long long)1e15; long long maxi = 0; long long gcd(long long a, long long b) { if (b == 0) return a; else return gcd(b, a % b); } void calc(long long l) { if (l <= 0 || l > n * k) return; long ...
#include <bits/stdc++.h> using namespace std; const int N = 4e4; int main() { ios::sync_with_stdio(false); int n; while (cin >> n) { int a[12]; for (int i = 0; i < n; ++i) cin >> a[i]; sort(a, a + n); long long p = clock(); while (clock() - p < 1400) ; cout ...
// megafunction wizard: %ROM: 1-PORT%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: LOG_Table.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // ==============...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; vector<int> a; for (int i = 1; i <= n; i++) if (n % i == 0) a.push_back(i); for (int i = 1; i < a.size(); i++) { for (int j = 0; j < a[i] / 2; j++) swap(s[j], s[a[i] - j - 1]); ...
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; int N; vector<int> adj[200001]; vector<int> L[200001]; vector<int> R[200001]; int dp[200001]; int ans[200001]; inline void addmod(int& x, int v) { x += v; if (x >= MOD) x -= MOD; } void dfs(int u, int p) { for (a...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
/* * 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) 2010, Martijn Vermaat <> *) (* *) (* Licensed under the MIT license, see the LICENSE file or *) (* http://en.wikipedia.org/wiki/Mit_lice...
// -- (c) Copyright 2010 - 2011 Xilinx, Inc. All rights reserved. // -- // -- This file contains confidential and proprietary information // -- of Xilinx, Inc. and is protected under U.S. and // -- international copyright and other intellectual property // -- laws. // -- // -- DISCLAIMER // -- This disclaimer is not a...