text stringlengths 59 71.4k |
|---|
//--------------------------------------------------------------------------------
//
// timer.v
// Copyright (C) 2011 Ian Davis
//
// 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; eit... |
/* verilator lint_off WIDTH */
/* verilator lint_off UNUSED */
module output_data(
input clock,
// meta data
input isDrawAreaVGA,
input isOsdTextArea,
input isCharPixel,
input isOsdBgArea,
input isScanline,
input [8:0] scanline_intensity,
// ...
input [23:0] data,
output reg... |
/*
Copyright (c) 2020 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,... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
#include <bits/stdc++.h> using namespace std; const double PI = 3.1415926535; double squared(double n) { return n * n; } typedef struct { int cx; int cy; int r; int R; } circle_t; bool isBlack(double x, double y, circle_t c) { double val = squared(x - (double)c.cx) + squared(y - (double)... |
//Legal Notice: (C)2020 Altera Corporation. All rights reserved. Your
//use of Altera Corporation's design tools, logic functions and other
//software and tools, and its AMPP partner logic functions, and any
//output files any of the foregoing (including device programming or
//simulation files), and any associated do... |
/*
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law... |
#include <bits/stdc++.h> using namespace std; vector<int> g[201010]; int tin[201010], tout[201010]; int n, a[201010], m, timer; int is[201010], lvl[201010]; void dfs(int v) { tin[v] = ++timer; for (auto to : g[v]) if (!tin[to]) { lvl[to] = lvl[v] ^ 1; dfs(to); } tout[... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; int n, m; int f[2][25][25][25][25][2][2]; int x[6], y[6]; int tpx[1 << 6], tqx[1 << 6], tpy[1 << 6], tqy[1 << 6]; inline void update(int &x, int y) { x = x + y >= mod ? x + y - mod : x + y; } inline bool check(int now, int px, int ... |
#include <bits/stdc++.h> using namespace std; const int MaxN = 1e5; const int Inf = 1 << 30; double a[105]; int main() { int n, cnt; double pos, pp, ans, sum; while (~scanf( %d , &n)) { sum = 0; pos = 4.5; pos *= n; for (int i = 1; i <= n; i++) { scanf( %lf , &a[i])... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer: Hasan Hassan
//
// Create Date: 08/24/2015 06:51:37 PM
// Design Name:
// Module Name: pcie_data_sender
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dep... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 14:55:04 12/14/2010
// Design Name:
// Module Name: msu
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// R... |
#include <bits/stdc++.h> using namespace std; const int N = 100000; const long long INF = 1000000000000000; int a[N]; int main() { int t; cin >> t; for (int q = 0; q < t; q++) { int n, k; cin >> n >> k; for (int j = 0; j < n; j++) { cin >> a[j]; } long long an... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; int t, n; int cnt, num, maxx; int a[maxn]; int vis[maxn]; int m1[maxn]; int m2[maxn]; void init() { num = 0; maxx = 0; memset(vis, 0, sizeof(vis)); } int main() { scanf( %d , &t); while (t--) { cnt =... |
#include <bits/stdc++.h> int query(int aa[][150 + 1], int l0, int l1, int r0, int r1) { return l0 > l1 || r0 > r1 ? 0 : ((long long)aa[l1][r1] - aa[l0 - 1][r1] - aa[l1][r0 - 1] + aa[l0 - 1][r0 - 1]) % 1000000007; ... |
#include <bits/stdc++.h> using namespace std; int main() { double m, R; cin >> m >> R; double answer = (m * (m + 1) * (m + 2) / 3 - m) * 2; answer += (sqrt(2.0) - 2) * ((m * m - m) + (m * m - m - (m - 1) * 2)); answer /= (m * m); answer *= R; cout << setprecision(7) << answer << endl; ... |
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 1995/2014 Xilinx, Inc.
// All Right Reserved.
///////////////////////////////////////////////////////////////////////////////
// ____ ____
// / /\/ /
// /___/ \ / Vendor : Xilinx
// \ \ \/ Vers... |
`timescale 1ns / 1ps
// The Arithmetic/Logic Unit (ALU) is responsible for performing the arithmetic
// and bitwise logical operations the computer depends upon to calculate
// everything from effective addresses for looking stuff up in memory, all the
// way to medical imaging. (OK, the latter might have some help f... |
////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 1995-2012 Xilinx, Inc. All rights reserved.
////////////////////////////////////////////////////////////////////////////////
// ____ ____
// / /\/ /
// /___/ \ / Vendor: Xilinx
// \ \ \/ Version: P.49... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:512000000 ) using namespace std; void solve(bool); void precalc(); clock_t start; int main() { start = clock(); int t = 1; cout.sync_with_stdio(0); cin.tie(0); precalc(); cout.precision(10); cout << fixed; int testNum =... |
#include <bits/stdc++.h> namespace my_std { using namespace std; inline int read() { char c = getchar(); int ans = 0, f = 1; while (c > 9 || c < 0 ) { f ^= (c == - ); c = getchar(); } for (; c <= 9 && c >= 0 ; c = getchar()) ans = (ans << 1) + (ans << 3) + (c ^ 48); ... |
// sprite priority logic module
// this module checks the playfields and sprites video status and
// determines if playfield or sprite data must be sent to the video output
// sprite/playfield priority is configurable through the bplcon2 bits
module denise_spritepriority
(
input [5:0] bplcon2, // playfields... |
#include <bits/stdc++.h> using namespace std; const int INF = 2147483647; const long long LLINF = 9223372036854775807LL; const int ST = 100010; const int ST1 = 1000010; const long long MOD = 1000000007; long long ABS(long long a) { if (a < 0) return a * (-1); else return a; } int m... |
#include <bits/stdc++.h> using namespace std; int n, m, k, s, arr[4005][4005] = {}, x = 2000, ex[9][4], song[100005], res = 0; int main() { cin >> n >> m >> k >> s; for (int i = 0; i < 9; i++) { ex[i][0] = -999999999; ex[i][1] = 999999999; ex[i][2] = -999999999; ex[i][3] = 99999999... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); map<pair<string, string>, int> map_count; vector<int> cost_list; int n, a, b, k, f; string s, t, prv = ; cin >> n >> a >> b >> k >> f; for (int cost, i = 0; i < n; i++) { cin >> s >> t; ... |
`timescale 1ns/10ps
module audio_clock_0002(
// 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_multiplier("f... |
module dcache_top
(
// System clock, reset and stall
clk_i,
rst_i,
// to Data Memory interface
mem_data_i,
mem_ack_i,
mem_data_o,
mem_addr_o,
mem_enable_o,
mem_write_o,
// to CPU interface
p1_data_i,
p1_addr_i,
p1_MemRead_i,
p1_MemWrite_i,
p1_data_o,
p1_stall_o
);
//
// System ... |
#include <bits/stdc++.h> using namespace std; template <class T> ostream& operator<<(ostream& out, vector<T>& v) { out << [ ; for (auto k : v) out << k << ; out << ] ; return out; } vector<int> g[500]; string color; bool posible = true; void DFS(int n, int p, char c) { if (color... |
module butterfly_16(
enable,
i_0,
i_1,
i_2,
i_3,
i_4,
i_5,
i_6,
i_7,
i_8,
i_9,
i_10,
i_11,
i_12,
... |
`define IDLE 3'b000
`define STATE_RD 3'b001
`define STATE_EX1 3'b010
`define STATE_EX2 3'b011
`define STATE_EX3 3'b100
`define STATE_EX4 3'b101
module alu_fsm (
in_alu_select,
out_alu_start,
in_valu_done,
out_alu_ready,
RD,
EX,
WB,
clk,
rst
);
input in_alu_select;
input in_valu_done;
output out_... |
//
// Copyright (c) 1999 Steven Wilson ()
//
// 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)
// ... |
//////////////////////////////////////////////////////////////////////////////////
//
// Author : Praveen Kumar Pendyala
// Create Date : 05/27/13
// Modify Date : 16/07/14
// Module Name : mapping
// Project Name : PDL
// Target Devices : Xilinx Vertix 5, XUPV5 110T
// Tool versions : 13.2 ISE
//
// ... |
// Periferico del modulo ultrasónico. El módulo transforma el tiempo que Signal permanece encendido en milímetros.
// Signal entra desde el modulo físico del ultrasonico, las demás señales pertenecen a la interaccion que tiene con el J1
// Solo hay lectura de datos. una vez se desactiva el estado de reset, el módulo s... |
module RegisterFileTestBench_nogenerate;
parameter sim_time = 750*2; // Num of Cycles * 2
reg [31:0] Rd,Mem,Pcin;
reg [19:0] RSLCT;
reg Clk, RESET, LOADPC, LOAD,IR_CU;
wire [31:0] Rn,Rm,Rs,PCout;
RegisterFile_nogenerate RF(Rd,Mem,Pcin,RSLCT,Clk, RESET, LOADPC, LOAD,IR_CU, Rn,Rm,Rs,PCout);
initial fork
//Clk 0
Cl... |
#include <bits/stdc++.h> using namespace std; void solve() { int n, m; cin >> n >> m; int a[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) cin >> a[i][j]; } int b[m][n]; bool flag = false; int index = -1; for (int i = 0; i < m; i++) { for (int j = 0;... |
#include <bits/stdc++.h> using namespace std; long long N, f[3001][3001]; struct Node { long long x, val; } P[3001]; inline bool cmp(const Node &a, const Node &b) { return a.x < b.x; } int main() { scanf( %I64d , &N); for (long long i = 1; i <= N; i++) scanf( %I64d%I64d , &P[i].x, &P[i].val); ... |
#include <bits/stdc++.h> using namespace std; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); mt19937 rnf(2106); const int N = 200005; int n, m; int x[N], y[N]; int d[N]; queue<int> q[N]; int dist(int x1, int y1, int x2, int y2) { return abs(x1 - x2) + abs(y1 - y2); } int ans[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... |
#include <bits/stdc++.h> using namespace std; int main() { int a[4], i, j, min = 1000, x, y; for (i = 0; i < 4; i++) { cin >> a[i]; if (min > a[i]) min = a[i]; } cin >> x >> y; if (x >= min) { cout << 0; return 0; } else if (y < min) { cout << y - x + 1; } e... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e3 * 3 + 10; int n, k, m; vector<int> graph[2][MAXN]; int p[2][MAXN]; int sum; void read_input() { scanf( %d , &n); scanf( %d , &k); int v; for (int i = 0; i < k - 1; i++) { sum++; scanf( %d , &v); graph[0][n... |
#include <bits/stdc++.h> using namespace std; int ara[1000]; int rf[1000]; int main() { int n, i, f, w, cnt = 0, m, r; char str[1000001]; scanf( %d %d , &n, &m); scanf( %s , str); for (i = 0; i < n; i++) { r = str[i]; ara[r] = ara[r] + 1; } for (i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n; cin >> n; long long now = 0; long long mx = -1; while (true) { long long rem = (n - (now * 7)); if (rem < 0) { break; ... |
/**
* 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 1995-2017 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 ... |
/**
* 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... |
#pragma GCC optimize( O3 , Ofast , unroll-loops , omit-frame-pointer , inline ) //Optimization flags #pragma GCC option( arch=native , tune=native , no-zero-upper ) //Enable AVX // #pragma GCC target( avx2 ) //Enable AVX #include <bits/stdc++.h> #define int long long using namespace std; #ifdef ... |
#include <bits/stdc++.h> using namespace std; int dx8[8] = {1, -1, 0, 0, 1, 1, -1, -1}; int dy8[8] = {0, 0, 1, -1, 1, -1, 1, -1}; void file() {} void fast() { std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); } int main() { file(); int n, s; cin >> n >> s; if (n... |
/*
* Copyright (c) 2009 Zeus Gomez Marmolejo <>
*
* This file is part of the Zet processor. This processor is free
* hardware; you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software
* Foundation; either version 3, or (at your option) an... |
/**
* The Hack CPU (Central Processing unit), consisting of an ALU,
* two registers named A and D, and a program counter named PC.
* The CPU is designed to fetch and execute instructions written in
* the Hack machine language.
* In particular, functions as follows:
* Executes the inputted instruction accordin... |
/**
* 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 INF = 1e9 + 5; const long long LINF = LLONG_MAX; int main() { int t; cin >> t; while (t--) { int n; cin >> n; if (360 % (180 - n) == 0) cout << YES n ; else cout << NO n ; ... |
#include <bits/stdc++.h> using namespace std; bool field[100][100][100]; int n, m, k; bool check(int x, int y, int z) { return (x >= 0 && x < n && y >= 0 && y < m && z >= 0 && z < k && field[x][y][z]); } int main() { cin.sync_with_stdio(false); cout.sync_with_stdio(false); cin >>... |
/**
* 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 a, t, b, c, m, n, ck = 0, ans = 0, sum = 0; cin >> t; cin.ignore(); while (t--) { ck = 0; cin >> a; cin.ignore(); string s; cin >> s; b = a - 10; for (int i = 0; i < b; i++) { i... |
#include <bits/stdc++.h> using namespace std; #pragma warning(disable : 4996) #pragma comment(linker, /STACK:20000007 ) #pragma GCC optimize( unroll-loops ) const int N = (int)1e6 + 100; const int maxn = (int)1e3 + 100; const int base = (int)1e9; const int mod = (int)1e9 + 7; const int inf = INT_MAX;... |
#include <bits/stdc++.h> using namespace std; enum { AABB, ABAB, ABBA, AAAA }; int n, k; string s1, s2, s3, s4; bool isvow(char c) { return (c == a || c == e || c == i || c == o || c == u ); } string suf(string s) { static int sp = 0; auto i = s.end(), beg = s.begin(); int tk = 0;... |
//////////////////////////////////////////////////////////////////////
//// ////
//// XTEA IP Core ////
//// ////
//// This file is part of the xtea ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 101; int N, Q, freq[11]; char commands[MAXN], commands2[MAXN]; void solve(int l, int r) { l--; r--; for (int i = 0; i < N; i++) commands2[i] = commands[i]; for (int i = 0; i < 10; i++) freq[i] = 0; int cur = l; int dir = 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... |
// ***************************************************************************
// ***************************************************************************
// Copyright 2011(c) Analog Devices, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// a... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int a[n]; vector<int> ans; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); ans.push_back(a[0]); for (int i = 1; i < n; i++) { ... |
`timescale 1 ps / 1 ps
(* message_disable = "14320" *) module alt_mem_ddrx_buffer
# (
// module parameter port list
parameter
ADDR_WIDTH = 3,
DATA_WIDTH = 8,
REGISTER_OUTPUT = 0
)
(
// port list
ctl_clk,
ctl_reset_n,
// write interface
write_valid,
... |
#include <bits/stdc++.h> using namespace std; int main() { int a[1002], l, n; scanf( %d %d , &n, &l); for (int i = 0; i < n; i++) scanf( %d , a + i); sort(a, a + n); double d = max(a[0] - 0, l - a[n - 1]); for (int i = n - 1; i > 0; i--) d = max(d, double(a[i] - a[i - 1]) / 2); printf( %... |
#include <bits/stdc++.h> using namespace std; template <typename T> void display(T a[], int size) { for (int i = 0; i < size; i++) { cout << a[i] << ; } cout << endl; } void display(vector<pair<int, int> > a) { for (int i = 0; i < a.size(); i++) { cout << ( << a[i].first << ,... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename S> inline T smax(T &a, const S &b) { return a < b ? a = b : a; } int n, s, m, k, a[int(1500 + 20)], l[int(1500 + 20)], r[int(1500 + 20)], id[int(1500 + 20)]; int psum[int(1500 + 20)], dp[int(1500 + 20)][int(1500 + 20)], ... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 23:33:33 08/26/2015
// Design Name:
// Module Name: VerificadorSentidoMovimiento
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
//... |
#include <bits/stdc++.h> using namespace std; template <class T> inline T gcd(T a, T b) { while (b) b ^= a ^= b ^= a %= b; return a; } template <class T> inline T lcm(T a, T b) { a = abs(a); b = abs(b); return (a / gcd(a, b)) * b; } template <class T> inline T my_strrev(T array) { ... |
//Legal Notice: (C)2015 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... |
module avconf ( // Host Side
CLOCK_50,
reset,
// I2C Side
I2C_SCLK,
I2C_SDAT );
// Host Side
input CLOCK_50;
input reset;
// I2C Side
output I2C_SCLK;
inout I2C_SDAT;
// Internal Registers/Wires
reg [15:0] mI2C_CLK_DIV;
reg [23:0] mI2C_DATA;
reg mI2C_CTRL_CLK;
reg m... |
#include <bits/stdc++.h> using namespace std; const long long int INF = (long long int)1e9 + 10; const long long int INFLL = (long long int)1e18 + 10; const long double EPS = 1e-8; const long double EPSLD = 1e-18; const long long int MOD = 1e9 + 7; template <class T> T &chmin(T &a, const T &b) { ret... |
/**
* 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; __int128 read() { __int128 x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = x * 10 + ch - 0 ; ch = getchar(); } return x *... |
#include <bits/stdc++.h> using namespace std; bool matrix[5205][5205]; char inp[1305]; vector<int> divivi; int func(char c) { if (c >= 0 && c <= 9 ) return c - 0 ; else return c - A + 10; } bool check(int x, int n) { int i, j, r, c, ini; for (r = 0; r < n / x; r++) { ... |
#include <bits/stdc++.h> using namespace std; struct EDGE { int to, next, w, co; } e[100000]; int head[100], top, vis[100000]; void add(int u, int v, int w, int co) { e[top].to = v; e[top].w = w; e[top].co = co; e[top].next = head[u]; head[u] = top++; } struct _ { int max_flow,... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); const double eps = 1e-12; const int inf = 2000000000; const long long int infLL = (long long int)1e18; long long int MOD = 1000000007; int MOD1 = 1000000007; int MOD2 = 1000000009; inline bool checkBit(long long int n, long long... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e2 + 1; int n, m, q, ans[MAX][MAX], t[MAX][MAX][2]; int main() { ios_base::sync_with_stdio(0); cin >> n >> m >> q; for (int i = 1; i < n + 1; i++) for (int j = 1; j < m + 1; j++) { t[i][j][0] = i; t[i][j][1] = j; ... |
/**
* 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; scanf( %d , &N); int P; scanf( %d , &P); vector<int> As, Bs; long long SA = 0, SB = 0; for (decltype(N) _i = 0, _n = (N); _i < _n; _i++) { int A; scanf( %d , &A); int B; scanf( %d , &B); As.pu... |
//
// Copyright 2011 Ettus Research LLC
//
// 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 option) any later version.
//
// This program is dis... |
/*
* Copyright (c) 2001 Stephan Boettcher <>
*
* 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; int a[1111], x, n, s, y, o, oo; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> x; if (x == 0 || x == 100) a[s++] = x; else if (x < 10 && o == 0) a[s++] = x, o = 1; else if (x % 10 == 0 && oo == 0) a[... |
// LUT and DFF are combined to a GENERIC_SLICE
module LUT #(
parameter K = 4,
parameter [2**K-1:0] INIT = 0
) (
input [K-1:0] I,
output Q
);
wire [K-1:0] I_pd;
genvar ii;
generate
for (ii = 0; ii < K; ii = ii + 1'b1)
assign I_pd[ii] = (I[ii] === 1'bz) ? 1'b0 : I[ii];
endgenerate
assign Q = INIT[I_pd];
... |
#include <bits/stdc++.h> using namespace std; const int LIM = 200 * 1000, MAXN = 300 * 1000; int fen[MAXN]; void add(int pos, int val) { pos++; while (pos < MAXN) { fen[pos] += val; pos += pos & -pos; } } int sum(int pos) { pos++; int tot = 0; while (pos) { tot += f... |
/***********************************************
Module Name: CORDIC
Feature: CORDIC algorithm
An example for the GEM Projects
Coder: Garfield
Organization: xxxx Group, Department of Architecture
------------------------------------------------------
Input ports: clk: System clock
... |
// megafunction wizard: %RAM: 2-PORT%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: altsyncram
// ============================================================
// File Name: PA.v
// Megafunction Name(s):
// altsyncram
//
// Simulation Library Files(s):
// altera_mf
// =====================================... |
#include <bits/stdc++.h> using namespace std; long long i, j, k, m, n, t, x; string s, u; int main() { for (scanf( %lld , &t); t--;) { i = 1; cin >> x >> s; for (; s.size() < x; i++) { if (s[i - 1] > 49) { u = s.substr(i); for (k = s[i - 1] - 48; --k;) s += u; ... |
#include <bits/stdc++.h> int read() { int x = 0, y = 1; char ch = getchar(); while (ch > 9 || ch < 0 ) { if (ch == - ) y = -1; ch = getchar(); } while (ch <= 9 && ch >= 0 ) x = (x << 3) + (x << 1) + ch - 0 , ch = getchar(); return x * y; } void print(int x) { ... |
(* src = "../../verilog/extadc.v:1", top = 1 *)
module ExtADC (
(* intersynth_port = "Reset_n_i", src = "../../verilog/extadc.v:3" *)
input Reset_n_i,
(* intersynth_port = "Clk_i", src = "../../verilog/extadc.v:5" *)
input Clk_i,
(* intersynth_conntype = "Bit", intersynth_port = "ReconfModuleIn_s", src = "../... |
#include <bits/stdc++.h> using namespace std; class Data { public: long long lazy, val; Data() { lazy = -1; val = 0; } }; long long pr = 107; long long c_pr[100010]; Data tree[4 * 100010]; long long ara[100010]; void updval(int node, int le_ran, int ri_ran, long long lazy) { ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 110000, MAXM = MAXN * 2; const int inf = 10000000; struct eglist { int other[MAXM], succ[MAXM], last[MAXM], sum; void addEdge(int a, int b) { other[++sum] = b, succ[sum] = last[a], last[a] = sum; other[++sum] = a, succ[sum] = las... |
#include <bits/stdc++.h> using namespace std; int n, x, y, sum, mbit; int Ask(vector<int> vec) { int ret = 0; printf( ? %d , vec.size()); for (int i = 0; i < vec.size(); i++) printf( %d , vec[i]); puts( ); fflush(stdout); scanf( %d , &ret); return ret; } int Solve(vector<int> 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... |
module mult_wrap (
input ck,
input [63:0] i_a, i_b,
input [8:0] i_htId,
input i_vld,
output [63:0] o_res,
output [8:0] o_htId,
output o_vld
);
// Wires & Registers
wire [63:0] c_t19_res;
wire [8:0] c_t1_htId;
wire c_t1_vld;
reg [8:0] r_t2_htId, r_t3_htId, r_t4_htId, r_t5_htId, r... |
/**
* 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... |
/**
# SmallLpf2nd - 2-pole IIR Low-Pass Filter #
Small 2-Pole IIR low-pass filter, made using just adders and bit shifts. Set
the frequency using the K0_SHIFT and K1_SHIFT parameters. It can be slowed down by
strobing the `en` bit to run at a lower rate.
By using power of two feedback terms, this filter is alsways ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; const double PI = acos(-1.0); const int EPS = (1e-10); const int N = 1e5 * 2 + 10; const int inf = 1e9 * 2 + 10; const ll INF = 1e18 * 2 + 10; const int MOD = 1e9 + 7; int nx... |
#include <bits/stdc++.h> using namespace std; map<int, int> lc, rc, pr; set<int> nodes; set<int>::iterator it; vector<int> v; int main() { int n; cin >> n; int root; cin >> root; nodes.insert(root); for (int i = 1; i < n; ++i) { int x; cin >> x; v.push_back(x); ... |
#include <bits/stdc++.h> using namespace std; const int M = 1e5 + 5; int n, k; vector<pair<int, int> > g[M]; int ans; int dp[M][2]; void dfs(int u, int Pa) { vector<pair<int, int> > ch; for (auto p : g[u]) { int v = p.first, w = p.second; if (v == Pa) continue; dfs(v, u); c... |
#include <bits/stdc++.h> struct state { int n : 24; int c : 8; state const *prev; }; state b[128][128][128] = {}; void print(state const &s) { if (s.n) { state const &p = *s.prev; print(p); if (p.n < s.n) printf( %c , s.c); } } int main() { char s1[128]; char s2... |
#include <bits/stdc++.h> using namespace std; int n, k, x, y, l, r, fact[200001], inv[200001], mod = 1e9 + 7; map<int, int> m; int powlog(int a, int b) { if (b == 0) return 1; int ret = powlog(a, b / 2); if (b % 2) return 1LL * ret * ret % mod * a % mod; return 1LL * ret * ret % mod; } int C... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.