text stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; class Solution { public: void solve(std::istream& in, std::ostream& out) { long long n, k, b, c, a, d; in >> n >> k >> b >> c; b = min(b, 5 * c); vector<pair<long long, long long>> x(n); for (int i = 0; i < n; i++) { in >> 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 la... |
#include <bits/stdc++.h> using namespace std; int prime[100010]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int cnt = 0; for (int i = 2; i <= n; i++) { if (!prime[i]) { cnt++; for (int j = i; j <= n; j += i) prime[j] = cnt; } } ... |
#include <bits/stdc++.h> using namespace std; using vi = vector<long long>; template <typename T> std::istream& operator>>(std::istream& input, std::pair<T, T>& data) { input >> data.first >> data.second; return input; } template <typename T> std::istream& operator>>(std::istream& input, std::vect... |
`timescale 1ns / 1ps
module testbench;
parameter SIZEIN = 16, SIZEOUT = 40;
reg clk, ce, rst;
reg signed [SIZEIN-1:0] a, b;
output signed [SIZEOUT-1:0] REF_accum_out, accum_out;
output REF_overflow, overflow;
integer errcount = 0;
reg ERROR_FLAG = 0;
task clkcycle;
begin
#5;
clk = ~clk;
#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 law... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const int INF = 1000 * 1000 * 1000 + 7; const long long LINF = INF * (long long)INF; const int L = 22; int G[L]; int dp[1 << L]; int P[1 << L]; int M[1 << L]; int n; void print(int mask) { for (int i = (0); i < (n); i+... |
// --------------------------------------------------------------------
// Copyright (c) 2007 by Terasic Technologies Inc.
// --------------------------------------------------------------------
//
// Permission:
//
// Terasic grants permission to use and modify this code for use
// in synthesis for all Terasic De... |
#include <bits/stdc++.h> namespace fft { using namespace std; const double PI = std::atan2(0, -1); using dbl = double; struct num { dbl x, y; num(dbl x_ = 0, dbl y_ = 0) : x(x_), y(y_) {} }; inline num operator+(num a, num b) { return num(a.x + b.x, a.y + b.y); } inline num operator-(num a, num ... |
`timescale 1ns/10ps
module hps_design_pll_0(
// interface 'refclk'
input wire refclk,
// interface 'reset'
input wire rst,
// interface 'outclk0'
output wire outclk_0,
// interface 'locked'
output wire locked
);
altera_pll #(
.fractional_vco_multiplier("false"),
.reference_clock_frequency("50.0 MHz")... |
#include <bits/stdc++.h> using namespace std; int main() { long long i, j, m, a, s, c, b, n, x, y, ar[1001]; cin >> n; while (n--) { cin >> s >> a >> b >> c; x = s / c; y = x / a * b; cout << x + y << endl; } return 0; } |
/**
* $Id: red_pitaya_daisy_rx.v -01-21 11:40:39Z matej.oblak $
*
* @brief Red Pitaya daisy chain communication module. RX de-serializator.
*
* @Author Matej Oblak
*
* (c) Red Pitaya http://www.redpitaya.com
*
* This part of code is written in Verilog hardware description language (HDL).
* Please visit http:... |
#include <bits/stdc++.h> using namespace std; int p[200007]; int c1[200007]; int c2[200007]; bool used[200007]; int main() { int n; cin >> n; for (int i = 0; i < n; ++i) { scanf( %d , &p[i]); } for (int i = 0; i < n; ++i) { scanf( %d , &c1[i]); c1[i]--; } for (i... |
#include <bits/stdc++.h> using namespace std; const int P = 1e9 + 7, INF = 0x3f3f3f3f; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long qpow(long long a, long long n) { long long r = 1 % P; for (a %= P; n; a = a * a % P, n >>= 1) if (n & 1) r = r * a % P; ret... |
#include <bits/stdc++.h> using namespace std; const int inf = 1e9 + 10; int main() { int n; cin >> n; int an[n]; vector<int> p; vector<pair<int, int> > st; int i = 0; for (int a = 0; a < n * 2; a++) { char sy; cin >> sy; if (sy == + ) { p.push_back(i++); ... |
// -- (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... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 15:34:01 05/26/2014
// Design Name:
// Module Name: mccu
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Re... |
#include <bits/stdc++.h> using namespace std; int arr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6}; void solve() { int d, x; int a, b; cin >> a >> b; int ans = 0; for (int i = a; i <= b; i++) { x = i; while (x) { d = x % 10; x = x / 10; ans += arr[d]; } } ... |
// ========== Copyright Header Begin ==========================================
//
// OpenSPARC T1 Processor File: cpx_databuf_ca2.v
// Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
//
// The above named program is free software; you can redistribute it a... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, n; cin >> a >> b >> c >> n; int tot = n - a - b + c; if (tot <= 0 || a < c || b < c) return 0 * puts( -1 ); cout << tot << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; struct Node { vector<Node*> next; Node() : next(26, nullptr) {} }; Node* root = new Node; void insert(string& s, int i, Node* c) { if (i >= s.length()) return; if (c->next[s[i] - a ] == nullptr) { c->next[s[i] - a ] = new Node; } in... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if ((a == 0) || (b == 0)) return a + b; return gcd(b, a % b); } long long pow_mod(long long a, long long b) { long long res = 1; while (b) { if (b & 1) res = (res * a) % 1000000007; a = (a * a) % ... |
#include <bits/stdc++.h> using namespace std; int a[210][210], n, m, s[110]; bool dop(int x, int y) { return (x >= 0 && y >= 0 && x < 2 * n && y < 2 * m); } void dfs(int x, int y, int cur) { s[cur]++; a[x][y] = cur; if (dop(x + 2, y) && a[x + 1][y] != -1 && a[x + 2][y] != cur) { dfs(x + 2, y, ... |
`timescale 1ns / 1ps
module ps2_TB;
reg Rx;
reg CLKOUT;
ps2 uut(.CLKOUT(CLKOUT),.Rx(Rx));
always
begin
CLKOUT =1'b1;
#1;
CLKOUT =1'b0;
#1;
end
initial
begin
Rx=1;
#10;
Rx=0;
#2;
Rx=0;//1
#2;
Rx=0;
#2;
Rx=0;
#2;
Rx=1;
#2;
Rx=1;
#2;
Rx=1;
#2;
Rx=0;
#2;
Rx=0;//8
... |
#include <bits/stdc++.h> using namespace std; int n, q; string a[50]; string b[50]; int dfs(char c, int dep) { if (dep == n - 1) { return 1; } int ans = 0; for (long long int i = 1; i <= q; i++) { if (b[i][0] == c) { ans += dfs(a[i][0], dep + 1); } } return an... |
#include <bits/stdc++.h> using namespace std; int main() { int n, d; while (cin >> n >> d) { int A[n], ans = 0; for (int i = 0; i < n; i++) cin >> A[i]; for (int i = 1; i < n; i++) { if (A[i] <= A[i - 1]) { int rest = A[i - 1] - A[i], cnt = (rest / d) + 1; A[i] ... |
#include <bits/stdc++.h> using namespace std; int n, m, k; int dist[200002]; vector<pair<int, int>> v[200002]; vector<int> nes[200002]; char s[200002]; vector<string> ans; void dfs(int d) { if (ans.size() >= k) return; if (d > n) { ans.push_back(s); return; } for (auto i : ne... |
#include <bits/stdc++.h> using namespace std; int sum(int a) { int sum = a; while (a) { sum += a % 10; a /= 10; } return sum; } int main() { vector<int> v; int a; cin >> a; int b = a; while (a) { int check = sum(a); if (check == b) v.push_back(... |
#include <bits/stdc++.h> using namespace std; template <class T> inline T BM(T p, T e, T M) { long long int ret = 1; for (; e > 0; e >>= 1) { if (e & 1) ret = (ret * p) % M; p = (p * p) % M; } return (T)ret; } template <class T> inline T gcd(T a, T b) { if (b == 0) return a; ... |
#include <bits/stdc++.h> using namespace std; const int N = 4e5 + 10, INF = 1e9; int l[N], r[N], ps[N]; map<int, int> mp; int cnt, seg[4 * N], lazy[4 * N]; inline void shift(int id) { seg[2 * id] += lazy[id]; lazy[2 * id] += lazy[id]; seg[2 * id + 1] += lazy[id]; lazy[2 * id + 1] += lazy[id]... |
/**
* 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 tg, ans[22]; int state[22][22], fa_inc[22][22], fa_n4[22][22], fa_n7[22][22]; int t, cs = 0, dg[22]; int main() { scanf( %d , &t); for (cs = 1; cs <= t; ++cs) { scanf( %I64d , &tg); for (int i = 0; i < 19; ++i) dg[i] = tg % 10, tg /= ... |
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2012 by Wilson Snyder.
module t (/*AUTOARG*/
// Inputs
clk
);
/*verilator no_inline_module*/ // So we'll get hiearachy we can test
input clk;
sub sub (/*AUTOINST*... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 200005; struct M { int val, pos; }; M a[Maxn], b[Maxn]; int idx[Maxn], idy[Maxn], Nx[Maxn], Ny[Maxn]; int read() { int sum = 0, t = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) t = -1; c = getch... |
#include <bits/stdc++.h> using namespace std; template <class T> inline bool Up(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool Down(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long x, long long y) { return x ? gcd(y % x, x) : y; } int N; int a[2010], b[2010], c[2010]; vector<pair<long long, long long> > v; long long func(void) { int i, j; int ans = 0; i = 0; while (i < v.size()) { for (j = i; j... |
#include <bits/stdc++.h> using namespace std; int lsone(int n) { return (n & -n); } void mult(long long int a[25][25], long long int b[25][25], long long int c[25][25], int m, int n, int p) { for (int i = 1; i <= m; i++) { for (int j = 1; j <= p; j++) { c[i][j] = 0; for (int ... |
///////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2014 Francis Bruno, All Rights Reserved
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foun... |
/*
* Copyright (c) 2015-2018 The Ultiparc Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list... |
#include <bits/stdc++.h> using namespace std; namespace jumpmelon { const int MAXN = 52; int A[MAXN + 1], B[MAXN + 1]; bool F[MAXN + 1]; void work() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &A[i]); vector<vector<int>> Ans; while (1) { memset(F + 1, 0, size... |
// (C) 1992-2014 Altera Corporation. All rights reserved.
// Your use of Altera Corporation's design tools, logic functions and other
// software and tools, and its AMPP partner logic functions, and any output
// files any of the foregoing (including device programming or simulati... |
#include <bits/stdc++.h> using namespace std; int main() { int n, t; cin >> n >> t; if (t == 10) { if (n == 1) { cout << -1 ; } else { for (int i = 0; i < n - 1; i++) { cout << 1 ; } cout << 0 ; } } else { for (int i = 0; i < n; i+... |
#include <bits/stdc++.h> using namespace std; template <typename item> item abs(item i) { if (i < 0) i = -i; return i; } char *s; int n; int pos; int main() { cin >> n; cin >> pos; s = new char[n + 2]; cin >> s + 1; int cnt = 0; if (n == 1) { cout << 0; return... |
#include <bits/stdc++.h> using namespace std; const int N = 300000 + 7; int n, q; long long val[N]; struct edge { int to, nex; long long wei; } e[N << 1]; int fir[N], eid; int siz[N], dep[N], fa[N], son[N], ltp[N]; long long faw[N]; int dfn[N], inx; long long f[N], g[N]; long long bit[N]... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline T read() { T x = 0, f = 1; char c = getchar(); while (!isdigit(c)) { if (c == - ) f = -f; c = getchar(); } while (isdigit(c)) { x = (x << 3) + (x << 1) + (c - 48); c = getchar(); } retur... |
`define CONN_INTERNAL_BITS
`define PINTYPE 6'b010000
// `define IOSTANDARD "SB_LVCMOS"
`define IOSTANDARD "SB_LVDS_INPUT"
// The following IO standards are just aliases for SB_LVCMOS
// `define IOSTANDARD "SB_LVCMOS25_16"
// `define IOSTANDARD "SB_LVCMOS25_12"
// `define IOSTANDARD "SB_LVCMOS25_8"
// `define IOSTANDA... |
#include <bits/stdc++.h> using namespace std; struct Edge { int v; int w; Edge* next; void add(int v, int w, Edge*& head) { this->v = v; this->w = w; this->next = head; head = this; } } edges[200100]; Edge* h[100100]; struct Q { int v; int t; bool operat... |
/*
* 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 long long N = 2e5 + 5; const long long inf = 1e16 + 7; long long m, n, h; long long ans = 0; long long seg[4 * N]; long long lazy[4 * N]; long long ind[N]; vector<long long> b; vector<long long> a; void build(long long p, long long val, long long... |
//
// 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)
// ... |
//---------------------------------------------------------------------------
//-- Copyright 2015 - 2017 Systems Group, ETH Zurich
//--
//-- This hardware module is free software: you can redistribute it and/or
//-- modify it under the terms of the GNU General Public License as published
//-- by the Free Software ... |
#include <bits/stdc++.h> using namespace std; const int N = 300500; int n, a[N]; vector<int> v; int cnt[N]; vector<int> all; int main() { scanf( %d , &n); for (int i = 1; i <= n; ++i) { scanf( %d , &a[i]); v.push_back(a[i]); } sort(v.begin(), v.end()); v.resize(unique(v.beg... |
// file: sys_mon.v
// (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
// laws.
//
// DISCLAIMER
// This disclaimer is not a licens... |
#include<bits/stdc++.h> using namespace std; #define ll long long #define mod 1000000007 void solve() { int k,n,m; cin >> k >> n >> m; vector<int> a(n); for(auto &i:a) { cin >> i; } vector<int> b(m); for(auto &i:b) ... |
module dec_5to32 (
input [4:0] a,
output [31:0] b);
and (b[0 ], ~a[4], ~a[3], ~a[2], ~a[1], ~a[0]);
and (b[1 ], ~a[4], ~a[3], ~a[2], ~a[1], a[0]);
and (b[2 ], ~a[4], ~a[3], ~a[2], a[1], ~a[0]);
and (b[3 ], ~a[4], ~a[3], ~a[2], a[1], a[0]);
and (b[4 ], ~a[4], ~a[3], a[2], ~a[1], ~a[0]);
and (b[5 ... |
#include <bits/stdc++.h> using namespace std; int n, m, flag; int ar[101][101], ars[101][101], c[101][101], q[101][101]; int fu() { int y = 1; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if (ars[i][j] != c[i][j]) y = 0; return y; } void f() { flag = max(flag, fu());... |
/**
* 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; #pragma warning(disable : 4996) int a[100010], cnt[100010]; int queries[100010][2]; bool res[100010]; bool xpeHb[100010]; int main() { int t; scanf( %d , &t); for (int y = 0; y < t; y++) { int m, k; scanf( %d %d , &m, &k); for (in... |
/**
* 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, n; cin >> T; while (T--) { cin >> n; long long ans = 0; for (int i = 1; i <= n / 2; i++) { ans += i * 1ll * i; } cout << ans * 8 << n ; } return 0; } |
#include <bits/stdc++.h> using namespace std; short p[402][402 * 402]; int a[402][402], n, m, l, r, j, i, d[402][402], f[402][402], ans; int main() { scanf( %d%d , &n, &m); for (i = 1; i <= n; ++i) for (j = 1; j <= m; ++j) scanf( %d , &a[i][j]); for (j = 1; j <= m; ++j) { for (l = n; l >... |
#include <bits/stdc++.h> using namespace std; int n, m, ans, tot; int b[200010], rt[200010]; struct nu { int val, id; } a[200010]; char s[200010]; struct node { int ls, rs, sum; } tree[200010 * 20]; inline bool cmp(const nu &x, const nu &y) { if (x.val == y.val) return x.id < y.id; ... |
/**
* 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: 04/27/2016 08:14:07 AM
// Design Name:
// Module Name: FPU_UART
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// R... |
module main;
reg [2:0] Q;
reg clk, clr, up, down;
reg flag;
(*ivl_synthesis_off *)
initial begin
clk = 0;
up = 0;
down = 0;
clr = 1;
#1 clk = 1;
#1 clk = 0;
if (Q !== 0) begin
$display("FAILED");
$finish;
end
if (flag !== 0) begin
... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long i, T, n; cin >> T; while (T--) { double h, c, t, ans; cin >> h >> c >> t; double res = h, freq = 1.0, diff = fabs(((h + c) / 2) - t); if (h == t) { ... |
#include <bits/stdc++.h> using namespace std; void debug_out() { cerr << n ; } template <typename H, typename... T> void debug_out(H h, T... t) { cerr << << (h); debug_out(t...); } int n; string a, b; char flip(char ch) { return (char)( 0 + ( 1 - ch)); } char ch(int i, int cnt) { retur... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const int inf = 0x3f3f3f3f; const int maxn = 1e5 + 5; void Solution() { int n; cin >> n; cout << (n / 2) + 1 << n ; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; ci... |
#include <bits/stdc++.h> using namespace std; const int iinf = 1e9 + 7; const long long linf = 1ll << 60; const double dinf = 1e60; template <typename T> inline void scf(T &x) { bool f = 0; x = 0; char c = getchar(); while ((c < 0 || c > 9 ) && c != - ) c = getchar(); if (c == - ) {... |
/*
* 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... |
module interstage_buffer_if_id(clock);
register#(4) id_control_signals_buffer(if_control_signals,
clock,
id_control_signals);
register#(4) ex_control_signals_buffer(id_control_signals,
... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1); int main() { ios::sync_with_stdio(false); int m, n, k; while (cin >> m >> n >> k) { k *= 2; if (m >= k && n >= k) { cout << First << endl; } else { cout << Second << endl; } } ... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const long long inf2 = 0x3f3f3f3f3f3f3f3f; const double eps = 1e-6; const int mod = 1000000007; namespace fastio { char in[100000]; int itr = 0, llen = 0; char get() { if (itr == llen) llen = fread(in, 1, 100000, stdin), itr... |
#include <bits/stdc++.h> using namespace std; int main() { double n; cin >> n; double sum = 0, y; for (int i = 0; i < n; i++) { cin >> y >> y; sum += y; } sum = sum / n; cout << sum + 5 << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, m, a, n2, m2; cin >> n >> m >> a; if ((a * (n / a)) == n) n2 = n / a; else n2 = (n / a) + 1; if ((a * (m / a)) == m) m2 = m / a; else m2 = (m / a) + 1; cout << n2 * m2 << endl; return ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; pair<int, int> a[n], b[m]; for (int i = 0; i < n; i++) { cin >> a[i].first >> a[i].second; } for (int i = 0; i < m; i++) { cin >> b[i].first >> b[i].second; } set<int> s; for (int i = ... |
#include <bits/stdc++.h> using namespace std; const bool DEBUG = false; int main() { ios::sync_with_stdio(0); cin.tie(0); bool puede = true; int N, M; cin >> N >> M; unordered_set<int> conj; vector<string> cad(N); vector<int> index(M); for (int i = 0; i < N; i++) { cin >>... |
#include <bits/stdc++.h> using namespace std; int n, K; int pover[64000]; int ipover[64000]; int dt[503][503]; int lsum[2][503][503]; const int mod = 1000000007; int main() { scanf( %d%d , &n, &K); int maxval = 0; pover[0] = 1; for (int i = 1; i < 64000; i++) { pover[i] = (pover[i ... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const double INF = 1e20; const int N = 102; const int M = 1010; const int K = 10; int n; double C, T; const double Y = 1. / 0.9; pair<int, int> a[N]; double dp[N][M]; void read() { ... |
#include <bits/stdc++.h> using namespace std; int main() { int q; scanf( %d , &q); while (q--) { int n; scanf( %d , &n); vector<int> a(n); for (int i = 0; i < n; i++) scanf( %d , &a[i]); sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); n =... |
#include <bits/stdc++.h> using namespace std; const int N = 200000; int a[N], n, m, k; int check(int x) { int cnt = 1, space = k; for (int i = x; i < n; i++) { if (a[i] <= space) space -= a[i]; else { if (cnt == m) return 0; ++cnt, space = k - a[i]; } } ... |
// Double buffering with dual-port RAM
// Uses single-port RAM to write switches to a section while reading from the same section to control LEDs,
// so each switch acts as if connected directly to the corresponding LED.
// Flip SW0 to change sections.
module top (
input clk,
input [15:0] sw,
... |
/*
* 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; map<long long int, map<long long int, bool> > my; int main() { long long int n; cin >> n; my[1][n] = 1; if (n % 2 == 0) { cout << white << endl; cout << 1 << << 2 << endl; } else cout << black << endl; return 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, tmp, curr = 0; cin >> n; int v[n], res[n]; for (int i = 0; i < n; i++) { cin >> tmp; v[tmp] = i + 1; } for (int i = 0; i < n; i++) { cin >> tmp; if (v[tmp] > curr) { res[i] = v[tmp] - curr; ... |
#include <bits/stdc++.h> using namespace std; long long int modularPower(long long int x, unsigned long long int y, long long int mod) { long long int res = 1; x %= mod; while (y > 0) { if (y & 1) res = (res * x) % mod; y >>= 1; x = (x * x) % mod; } ... |
#include <bits/stdc++.h> using namespace std; const int N = 100100; int n; vector<pair<int, int>> a; int main() { scanf( %d , &n); for (int i = 0; i < n; ++i) { int x, y; scanf( %d%d , &x, &y); a.emplace_back(x, 1); a.emplace_back(y + 1, -1); } sort(a.begin(), a.end());... |
// cpu interface
module cpu_if
(
input CLK,
input RESET_X,
// CPU
input [7:0] ADR,
output reg [31:0] RDATA,
input RD,
input WR,
input [31:0] WDATA,
output reg INT,
//REGISTERS
output reg SOFT_RESET,
output reg START,
inp... |
`timescale 1ns / 1ns
module menc_parser
(input c,
input [7:0] rxd,
input rxdv,
input direction,
output [31:0] enc_usecs,
output [31:0] enc_angle,
output [31:0] enc_vel,
output [15:0] enc_raw,
output [2:0] halls,
output [31:0] temp_celsius);
wire [6:0] byte_cnt;
r #(7) byte_cnt_r
(.c(c), .en(rxdv), .rst(~rxdv... |
/*
* BCH Encode/Decoder Modules
*
* Copyright 2014 - Russ Dill <>
* Distributed under 2-clause BSD license as contained in COPYING file.
*/
`timescale 1ns / 1ps
`include "config.vh"
`include "bch_defs.vh"
/*
* Calculate syndrome method 1:
*
* S_j = r_0 + alpha^j * (r_1 + alpha^j * ...(r_(n-2) + alpha^j * r_(n... |
`define Rotary_NOP 4'h0
`define Rotary_RDLS 4'h1
`define Rotary_RDRS 4'h2
`define Rotary_State_Reset 2'h0
`define Rotary_State_Ready 2'h1
`define Rotary_State_Error 2'h2
module Rotary(clock,reset,inst,inst_en,rotary,rotary_left_status,rotary_right_status);
input wire clock;
input wire reset;
... |
/*
File: eproto_tx.v
This file is part of the Parallella Project.
Copyright (C) 2014 Adapteva, Inc.
Contributed by Fred Huettig <>
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... |
//Legal Notice: (C)2016 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> using namespace std; bool debug; const int inf = 1e9 + 5; const int nax = 205; int k; namespace MinCost { struct Edge { int w, c, v, rev; Edge(int _w, int _c, int _v, int _rev) : w(_w), c(_c), v(_v), rev(_rev) {} }; int odl[nax], pot[nax], pop[nax], pop_kraw[nax]; ve... |
/*
* 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... |
module top;
reg pass = 1'b1;
reg signed [7:0] arr [0:7];
integer idx;
reg signed [1:0] idx2;
reg [7:0] res;
real rarr [0:7];
real rres;
reg signed [2:0] a [0:3];
wire signed [2:0] n [0:3];
assign n[3] = 0;
assign n[0] = -1;
initial for (idx = 0; idx < 8 ; idx = idx + 1) rarr[idx] = idx+1.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 la... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.