text stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const double eps = 1e-6; const double PI = 3.14159265358979323846264338f; const double pi = acos(-1.0); const int inf = 0x3f3f3f3f; const long long mod = 1e9 + 7; const int MAXN = 1005; inline int read() { int c = 0, f = 1; char ch = getchar(); w... |
#include <bits/stdc++.h> using namespace std; string arr[12] = { C , C# , D , D# , E , F , F# , G , G# , A , B , H }, a, b, c; int ok(int a1, int a2, int a3) { int dis1, dis2; if (a2 > a1) dis1 = a2 - a1; else dis1 = 12 - a1 + a2; if (a3 > a2... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int k; cin >> k; string s; cin >> s; long long tot = 0; int av[11]; memset(av, 0, sizeof(av)); int ans = 0; for (char a : s) tot += a - 0 , av[9 - (a - 0 )]++; for (int i... |
#include <bits/stdc++.h> using namespace std; const int N = 109; int n, suma, K, sumb, f[10086][N], ans = 0; struct node { int a, b; } c[N]; bool cmp(const node& a, const node& b) { return a.b > b.b; } int main() { scanf( %d , &n); for (register int i = 1; i <= n; i++) scanf( %d , &c[i].a), su... |
#include <bits/stdc++.h> using namespace std; long long bigmod(long long a, long long b) { if (b == 0) return 1; if (!(b & 1)) { long long ret = bigmod(a, b / 2); return ((ret % 1000000007) * (ret % 1000000007)) % 1000000007; } else return ((a % 1000000007) * (bigmod(a, b - 1) % 100000... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int x, y, z; cin >> x >> y >> z; int x1, y1, z1; cin >> x1 >> y1 >> z1; int a[6]; for (auto &z : a) cin >> z; int sum = 0; if (x < 0) sum += a... |
#include <bits/stdc++.h> using namespace std; struct sak { int x, y; sak(int x1, int y1) { x = x1; y = y1; } }; vector<sak> A, B; vector<int> AA, BB; int findA(int k) { int t1 = -1; for (int i = 0; i < A.size(); i++) if (A[i].x <= k && AA[i] == 0 && (t1 == -1 || A[t1].y... |
#include <bits/stdc++.h> using namespace std; void readi(int &x) { int v = 0, f = 1; char c = getchar(); while (!isdigit(c) && c != - ) c = getchar(); if (c == - ) f = -1; else v = v * 10 + c - 0 ; while (isdigit(c = getchar())) v = v * 10 + c - 0 ; x = v * f; } void ... |
//-----------------------------------------------------------------------------
// Title : 10/100/1G Ethernet FIFO for 8-bit Client Interface
// Project : Virtex-6 Embedded Tri-Mode Ethernet MAC Wrapper
// File : eth_fifo_8.v
// Version : 1.5
//----------------------------------------------------------... |
/**
* 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; vector<long long> graph[300005]; long long col[300005]; long long ans, r, b; pair<long long, long long> dfs(long long x, long long p = -1) { long long a1, b1; a1 = 0; b1 = 0; if (col[x] == 1) a1++; if (col[x] == 2) b1++; for (long long i = ... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1 << 30; typedef struct { long long x, y; } point; priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > pq; vector<pair<pair<int, int>, int> > vpp; vector<pair<int, int> > vp; con... |
`include "defines.v"
module ctrl (
input wire rst,
input wire stallreq_from_id,
input wire stallreq_from_ex,
input wire[`RegBus] excepttype_i,
input wire[`RegBus] cp0_epc_i,
output reg[5:0] stall,
output reg[`RegBus] new_pc,
output reg flush
);
always @(*) begin
if (rst == `RstEnable) be... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 9, inf = 1e18, mod = 1e9 + 7; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; int t; cin >> t; while (t--) { int a, b, c, d, k; cin >> a >> b >> c >> d >> k; int x = (a + c -... |
#include <bits/stdc++.h> using namespace std; const int mx = 2e3 + 505; struct node { double x, y; } a[mx]; double pw(double x) { return x * x; } double dist(node a, node b) { return sqrt(pw(a.x - b.x) + pw(a.y - b.y)); } double f[2][mx], g[2][mx]; int main() { int n; scanf( %d , &n); fo... |
//alt_oct_power CBX_AUTO_BLACKBOX="ALL" CBX_SINGLE_OUTPUT_FILE="ON" device_family="Stratix IV" parallelterminationcontrol rdn rup seriesterminationcontrol
//VERSION_BEGIN 11.0SP1 cbx_alt_oct_power 2011:07:03:21:10:32:SJ cbx_cycloneii 2011:07:03:21:10:33:SJ cbx_lpm_add_sub 2011:07:03:21:10:33:SJ cbx_lpm_compare 2011:07:... |
/*
* 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.
*
... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; long long n, a[N], sum; vector<long long> v; void fact() { if (sum % 2 == 0) { v.push_back(2); while (sum % 2 == 0) sum /= 2; } for (long long i = 3; i * i <= sum; i += 2) { if (sum % i == 0) { v.push_ba... |
module mem(
input clk,
input we,
input [ADDR_WIDTH - 1 : 0] waddr,
input [DATA_WIDTH - 1 : 0] d,
input re,
input [ADDR_WIDTH - 1 : 0] raddr,
output [DATA_WIDTH - 1 : 0] q
);
parameter ADDR_WIDTH = 8;
parameter DATA_WIDTH = 16;
localparam ... |
#include <bits/stdc++.h> const int MAXN = 1e5 * 5; const int INF = 1e9 + 7; const int N = 5000; using namespace std; int n, m, h[N], c[N], cnt; char a[N][N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j... |
#include <bits/stdc++.h> using namespace std; const int maxn = 300005; const int maxm = 5005; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { int n; scanf( %d , &n); int a[maxn]; bool exist[maxm]; for (int i = 0; i < maxm; ++i) exist[i] = true; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long test; cin >> test; while (test--) { long long b, p, f, h, c; cin >> b >> p >> f >> h >> c; long long profit = 0; if (h > c) { if (b - 2 * p >= 0) { profit += p * h; b = b - 2 * p; ... |
#include <bits/stdc++.h> using namespace std; char buf[1 << 21], *p1 = buf, *p2 = buf; inline int qread() { register char c = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++); register int x = 0, f = 1; while (c < 0 || c > 9 )... |
#include <bits/stdc++.h> using namespace std; void Debug(vector<int> v) { for (int i : v) { cerr << i << ; } } void Debug(int a[]) { for (int i = 0; i < 5; i++) { cerr << a[i] << ; } } void Debug(int a) { cerr << a; } void Debug(string a) { cerr << a; } void Debug(long ... |
#include <bits/stdc++.h> using namespace std; const int maxn = (int)2e5 + 5; int n, a[maxn], vis[2 * maxn], mx[maxn]; long long ans; vector<int> slist[maxn]; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } void doit(int d) { for (int i = 0; i < d; i++) mx[i] = 0; for (int i = 0; i < n; i++... |
#include <bits/stdc++.h> using namespace std; int main() { int BIG = 1000000; int n, k; cin >> n >> k; string s; int a[2][n + 2 * k]; int x[2][n + 2 * k]; for (int i = 0; i < 2; i++) { cin >> s; for (int j = k; j < n + k; j++) { if (s[j - k] == - ) a[i][j] ... |
#include <bits/stdc++.h> #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize( Ofast ) #pragma GCC optimize( inline ) #pragma GCC optimize( -fgcse ) #pragma GCC optimize( -fgcse-lm ) #pragma GCC optimize( -fipa-sra ) #pragma GCC optimize( -ftree-pre ) #pragma GCC optimize( -ftree-vrp )... |
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 22:54:34 03/11/2015
// Design Name: Condition
// Module Name: F:/ISE/work/cpu/cpu/Cond_Test.v
// Project Name: cpu
// Target Device:
// Tool versions:
// Descrip... |
#include <bits/stdc++.h> using namespace std; int mod = 1e9 + 7; long long binpow(long long a, long long b) { long long res = 1; while (b > 0) { if (b & 1) res = (res % mod) * (a % mod), res %= mod; a = (a % mod) * (a % mod); a %= mod; b >>= 1; } return res; } long long... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; const double pi = acos(-1.0); const int INF = 0x3f3f3f3f; const long long inf = (((long long)1) << 61) + 5; const int N = 200005; int a[N]; int b[N]; int f1[N]; int f2[N]; int bit[N]; int n; int sum(int i) { int s = 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << (n * n) / 4 << endl; for (int i = 1; i <= n / 2; i++) cout << n << << i << endl; for (int i = 1; i <= n / 2; i++) for (int j = n / 2 + 1; j < n; j++) cout << i << << j << endl; } |
#include <bits/stdc++.h> using namespace std; struct Point { double x, y; Point() : x(0), y(0) {} Point(double _x, double _y) : x(_x), y(_y) {} bool operator<(const Point &b) const { return tie(x, y) < tie(b.x, b.y); } bool operator==(const Point &b) const { return tie(x, y) == tie(b.x, b.y); } ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e3 + 5; const int P = 998244353; template <typename T> void chkmax(T &x, T y) { x = max(x, y); } template <typename T> void chkmin(T &x, T y) { x = min(x, y); } template <typename T> void read(T &x) { x = 0; int f = 1;... |
#include <bits/stdc++.h> using namespace std; char ch[500005]; bool vis[200]; int n; double f[500005], g[500005]; void init() { vis[ I ] = vis[ E ] = vis[ A ] = vis[ O ] = vis[ U ] = vis[ Y ] = true; int i; n = strlen(ch + 1); f[0] = g[0] = 0.0; for (i = 1; i <= n; i++) { f[i] = f[... |
#include <bits/stdc++.h> using namespace std; int n, m; string a, b, c, d, e; vector<vector<int> > vals; vector<vector<int> > forms(1); map<string, int> getind; int doop(int left, int right, int op) { if (op == 2) return left ^ right; if (op == 3) return left & right; else return l... |
/* -------------------------------------------------------------------------------
* (C)2012 Korotkyi Ievgen
* National Technical University of Ukraine "Kiev Polytechnic Institute"
* -------------------------------------------------------------------------------
*
* pl_input_port
*
* - Buffers incoming flits an... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 60; const int IN = 0; const int AND = 1; const int OR = 2; const int XOR = 3; const int NOT = 4; struct Node { int val, p1, p2; int op; } node[maxn]; int n, p1, p2; string op; bool change[maxn]; int eval(int cur) { ... |
#include <bits/stdc++.h> using namespace std; class base { public: long double a, b; base(void) { a = 0; b = 0; } base(long double _a, long double _b) { a = _a; b = _b; } base(long double _a) { a = _a; b = 0; } base operator*(const base& b2) { ... |
module user_design(clk, rst, exception, input_timer, input_rs232_rx, input_ps2, input_i2c, input_switches, input_eth_rx, input_buttons, input_timer_stb, input_rs232_rx_stb, input_ps2_stb, input_i2c_stb, input_switches_stb, input_eth_rx_stb, input_buttons_stb, input_timer_ack, input_rs232_rx_ack, input_ps2_ack, input_i2... |
#include <bits/stdc++.h> using namespace std; const long long int N = 500010; vector<vector<long long int> > ch, ar; void multiply(vector<vector<long long int> > &a, vector<vector<long long int> > &b) { vector<vector<long long int> > c; c.resize(a.size(), vector<long long int>(b[0].size(... |
/*
* Milkymist SoC
* Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq
*
* 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, version 3 of the License.
*
* This program is distributed in ... |
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////
// Company: California State University San Bernardino
// Engineer: Bogdan Kravtsov
// Tyler Clayton
//
// Create Date: 14:40:00 10/31/2016
// Module Name: MEM_WB
// Project Name: MIPS
//... |
#include <bits/stdc++.h> using namespace std; bool cmp(pair<int, int> p1, pair<int, int> p2) { return p2.second < p1.second; } vector<pair<int, int> > k; vector<pair<int, int> > c; vector<pair<int, int> > ans; int main() { int n, v; int t, p; cin >> n >> v; for (int i = 0; i < n; i++) { ... |
// Execute-Memory Pipeline Register
module mem_pipe_reg
(
input wire clk,
input wire reset,
input wire clr,
input wire valid_mem_pipe_reg_i,
input wire reg_wr_mem_pipe_reg_i,
input wire mem_to_reg_mem_pipe_reg_i,
... |
#include <bits/stdc++.h> using namespace std; int main() { int t, n, p, x; cin >> t; for (int u = 0; u < t; u++) { cin >> n >> p; x = 2 * n + p; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { cout << i + 1 << << j + 1 << n ; x--; ... |
/*TODO:
Test byte masks
Add timeout
Add FIFO mode
*/
module wb_bfm_transactor
#(parameter aw = 32,
parameter dw = 32,
parameter VERBOSE = 0,
parameter MAX_BURST_LEN = 5,
parameter MEM_LOW = 0,
parameter MEM_HIGH = 32'hffffffff)
(input wb_clk_i,
input wb_rst_i,
output... |
#include <bits/stdc++.h> using namespace std; stack<int> a[27]; stack<int> b[27]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; int n; cin >> n; string f, s; cin >> f >> s; for (int i = 0; i < f.size(); ++i) { if (f[i] == ? ) { a[26].pus... |
/**
* 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; const int maxn = 2007; int n, m, a[maxn][maxn]; long long sr[maxn][maxn], sc[maxn][maxn], sumr[maxn], sumc[maxn], allsumr[maxn], allsumc[maxn]; int main() { scanf( %d %d , &n, &m); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; long long int x; long long int k; long long int res; long long int curr; long long int exponentiation(long long int base, long long int power) { long long int ans = 1; while (power > 0) { if (power % 2) ans = (ans * base)... |
/**
* 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 = 1100; int N, K, L; string S; int nc[26]; vector<char> res[MAXN]; int main() { ios_base::sync_with_stdio(0); for (int i = 0; i < 26; i++) nc[i] = 0; cin >> N >> L >> K >> S; for (int i = 0; i < S.length(); i++) nc[S[i] - a ]++;... |
#include <bits/stdc++.h> using namespace std; const int M = 998244353; int main() { long long n; cin >> n; map<long long, long long> mp; long long a[200005]; for (long long i = 0; i < n; i++) { cin >> a[i]; mp[a[i]] = i; } long long ans = 1, w = mp[a[0]]; for (int i = 0... |
#include <bits/stdc++.h> using namespace std; int n, m, k; struct Lesson { long long a, b; int c, id; bool operator<(const Lesson &t) const { return c < t.c; } } ls[55]; int fstc[110]; long long dp[55][55][110]; pair<int, int> trans[55][55][110]; inline void upd(int x1, int y1, int z1, int y... |
`timescale 1ns/1ps
module fifo_axi_lcl(
input clk ,
input rst_n,
input clr ,
//FIFO status
output reg ovfl ,
... |
/**
* 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 argc, char const *argv[]) { int h1, a1, c1; int h2, a2; cin >> h1 >> a1 >> c1; cin >> h2 >> a2; int th1 = h1; int th2 = h2; int count = 0; while (th2 > 0) { if (th1 > a2 || th2 - a1 <= 0) { count++; th2 ... |
/**
* 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 a[1000010]; long long l[1000010], r[1000010]; vector<pair<int, int>> g1[1000010], g2[1000010]; int n, q; long long ans[1000010]; const int N = 1000000; long long sum[N * 4]; long long flag[N * 4]; int cnt_v; void build(int n) { cnt_v = 1;... |
#include <bits/stdc++.h> using namespace std; long long const M = 2e5 + 10, M2 = 1e5 + 10, mod = 1e9 + 7, inf = 1e9 + 10; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n; cin >> n; long long tmp = 1; for (long long i = 1;; i++) { if (tmp - 1 >= n) 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 law... |
//
// 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)
// ... |
#include <bits/stdc++.h> using namespace std; long long int fast_exp(long long int base, long long int exp1) { long long int res = 1; while (exp1 > 0) { if (exp1 & 1) res = (res * base) % 1000000007; base = (base * base) % 1000000007; exp1 /= 2; } return res % 1000000007; } lon... |
// -------------------------------------------------------------
//
// Generated Architecture Declaration for rtl of inst_6_e
//
// Generated
// by: wig
// on: Mon Jun 26 08:25:04 2006
// cmd: /cygdrive/h/work/eclipse/MIX/mix_0.pl ../../generic.xls
//
// !!! Do not edit this file! Autogenerated by MIX !!!
// $Auth... |
#include <iostream> #include <string> #include <algorithm> #include <map> #include <vector> #include <cmath> #include <queue> #include <set> #include <bitset> using namespace std; typedef long long ll; ll MOD = 1000000007; void solve(int testCase) { ll n; cin >> n; for (int i... |
/*------------------------------------------------------------------------------
* 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... |
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2005 by Wilson Snyder.
module t (/*AUTOARG*/
// Inputs
clk
);
input clk;
integer cyc; initial cyc=1;
reg [7:0] crc;
// Build up assignments
wire [7:0] bitre... |
#include <bits/stdc++.h> using namespace std; const int maxk = 999 + 5; int a[maxk]; vector<int> vec; int main() { int n, k, p, x, y; scanf( %d%d%d%d%d , &n, &k, &p, &x, &y); for (int i = 0; i < k; i++) scanf( %d , a + i); if (y > p) { printf( -1 n ); return 0; } sort(a, a ... |
#include <bits/stdc++.h> using namespace std; const int N = 2510; const int INF = 0x3f3f3f3f; int prime[400]; bool isprime[N]; int k; void init() { k = 0; for (int i = 2; i <= N; i++) { if (!isprime[i]) { prime[k++] = i; for (int j = i + i; j <= N; j += i) isprime[j] = 1; ... |
/*
Copyright (c) 2014-2017 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, distri... |
/*
* 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 maxn = 6010; int ans, f[maxn], r[maxn], m[maxn][maxn]; void dfs(int x, int y, int p) { int k = lower_bound(f, f + p, r[x]) - f; int t = f[k]; f[k] = r[x]; ans = max(ans, k); p = max(k + 1, p); for (int i = 1; i <= m[x][0]; i++) ... |
#include <stdio.h> // #include <iostream> #include <algorithm> // #include <cmath> // #include <string> // #include <string.h> // #include <vector> // #include <bits/stdc++.h> using namespace std; // const int INF32 = 2000000000; // const int INF64 = 2000000000000000000; // const int MOD17 = 10... |
#include <bits/stdc++.h> int main() { int n, i, j; int a[110][110]; long long ans[150]; while (scanf( %d , &n) != EOF) { for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) scanf( %d , &a[i][j]); memset(ans, 0, sizeof(ans)); for (i = 1; i <= n; i++) { for (j = 1; j <= n... |
// ----------------------------------------------------------------------
// 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:... |
/////////////////////////////////////////////////////////////////////
//// ////
//// Non-restoring unsigned divider ////
//// ////
//// Author: Richard Herveille ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, q, l[N], r[N], level[N], p[N][20], res[N]; int import[N], numCity, numVirus; vector<int> adj[N]; vector<pair<int, int> > newAdj[N]; struct T { int city, speed; }; T virus[N]; pair<pair<int, int>, int> top; struct Less ... |
#include <bits/stdc++.h> using namespace std; const int M = 512; const int T = 101; int n, m; long long a[M][M]; long long b[M][M]; int t; int x[T], y[T]; void solve(int xl, int xr, int yl, int yr) { if (xl == xr && yl == yr) { b[xl][yl] = a[xl][yl]; } else if (xl != xr) { int tm =... |
// (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... |
/* talu - a verilog test,
* illustrating problems I had in fragments of an ALU from an 8-bit micro
*/
module talu;
reg error;
reg [7:0] a;
reg [7:0] b;
reg cin;
reg [1:0] op;
wire cout;
wire [7:0] aluout;
alu alu_m(a, b, cin, op, aluout, cout);
initial begin
error = 0;
/... |
#include <bits/stdc++.h> void answer(unsigned long long v) { std::cout << v << n ; } void solve(unsigned n, unsigned k) { const auto s = n * (n - 1ull) / 2; if (k > n / 2) return answer(s); const auto m = n - 2 * k; const auto d = m * (m - 1ull) / 2; answer(s - d); } int main() { unsig... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int m, k, n, s; cin >> m >> k >> n >> s; int len = m - k * (n - 1); vector<int> a(m); for (auto& i : a) { cin >> i; } int bad = 0; vector<int> cnt(5e5 + 1); for (int... |
#include <bits/stdc++.h> using namespace std; long long qk(long long x, long long y) { long long ans = 1; while (y) { if (y & 1) ans = ans * x % 1000000007; y >>= 1; x = x * x % 1000000007; } return ans; } const int dx[8] = {0, -1, 0, 1, -1, -1, 1, 1}, dy[8] = {-1, ... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9 + 100; const int MX = 200503; int N, M, k; int arr[MX]; int cnt[MX]; vector<int> G[MX]; int vis[MX]; vector<int> sr; void dfs(int x) { vis[x] = 1; for (int i = 0; i < G[x].size(); i++) { int ch = G[x][i]; if ... |
// soc_design_mm_interconnect_0_avalon_st_adapter_001.v
// This file was auto-generated from altera_avalon_st_adapter_hw.tcl. If you edit it your changes
// will probably be lost.
//
// Generated using ACDS version 16.0 211
`timescale 1 ps / 1 ps
module soc_design_mm_interconnect_0_avalon_st_adapter_001 #(
parame... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; const int INF = 2e9; const int MOD = 1e9 + 7; int main() { vector<int> RES; string S = ; cin >> S; int N = S.size(), last = -1, depth = 0; for (int i = 0; i < N; i++) { if (S[i] == ( ) depth++; e... |
#include <bits/stdc++.h> using namespace std; int main() { int n, flag; cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; if (n == 2) cout << a[0] + 2 * (a[1] - a[0]); else { for (int i = 0; i < n - 2; i++) { if ((a[i + 2] - a[i + 1]) != (a[1 + i] - a[i])) { ... |
#include <bits/stdc++.h> using namespace std; char str[100010]; int dp[26][100010]; int maxP[260][260][260]; int len[3]; int idx[3]; char desc[3][260]; int get(int rel) { int m = maxP[idx[0] - (rel == 0)][idx[1] - (rel == 1)][idx[2] - (rel == 2)]; if (m == 100010) return 100010; return dp[de... |
/*
* University of Illinois/NCSA
* Open Source License
*
* Copyright (c) 2007-2014,The Board of Trustees of the University of
* Illinois. All rights reserved.
*
* Copyright (c) 2014 Matthew Hicks
*
* Developed by:
*
* Matthew Hicks in the Department of Computer Science
* The University of Illinois at... |
// -*- Mode: Verilog -*-
// Filename : wb_master_interface.v
// Description : Wishbone Bus Master
// Author : Philip Tracton
// Created On : Fri Nov 27 16:22:45 2015
// Last Modified By: Philip Tracton
// Last Modified On: Fri Nov 27 16:22:45 2015
// Update Count ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; int a = 2, b = 3, c = 5, d = 7; int ab = 6, ac = 10, ad = 14, bc = 15, bd = 21, cd = 35; int abc = 30, bcd = 105, abd = 42, acd = 70; int abcd = 210; cout << n - (n / a + n / b + n / c + n / d) + ... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; const long double PI = 4 * atan((long double)1); const long long mod = 1e9 + 7; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long tt = 1; while ((tt)--) { long long n, m; cin >>... |
// megafunction wizard: %FIFO%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: dcfifo
// ============================================================
// File Name: fifo64_clock_crossing.v
// Megafunction Name(s):
// dcfifo
//
// Simulation Library Files(s):
// altera_mf
// =================================... |
`timescale 1 ns / 1 ps
`include "AXI_to_audio_v1_0_tb_include.vh"
// lite_response Type Defines
`define RESPONSE_OKAY 2'b00
`define RESPONSE_EXOKAY 2'b01
`define RESP_BUS_WIDTH 2
`define BURST_TYPE_INCR 2'b01
`define BURST_TYPE_WRAP 2'b10
// AMBA AXI4 Lite Range Constants
`define S00_AXI_MAX_BURST_LENGTH 1
`defin... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:10000000000 ) #pragma GCC optimize( O3 ) using namespace std; const int MOD = 1000000007; const int INF = 1000000007LL; const long long INF2 = 1LL << 62LL; const long double EPS = 1e-9; const int SIZE = 200010; mt19937 rng(time(0)); uniform_in... |
///////////////////////////////////////////////////////////////////////////////
//
// File name: axi_protocol_converter_v2_1_9_b2s_r_channel.v
//
// Description:
// Read data channel module to buffer read data from MC, ignore
// extra data in case of BL8 and send the data to AXI.
// The MC will send out the read data a... |
// Check behaviour with out-of-range and undefined array indices
// on LHS of non-blocking procedural assignment.
`ifdef __ICARUS__
`define SUPPORT_CONST_OUT_OF_RANGE_IN_IVTEST
`endif
module top;
reg array1[2:1];
reg array2[1:0];
`ifndef VLOG95
real array3[2:1];
real array4[1:0];
`endif
integer index;
reg fai... |
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; vector<int> a(n); int psum = 0, msum = 0; int zero = 0; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] > 0) psum += a[i]; if (a[i] < 0) msum += a[i]; } if (psum > abs(msum)) { p... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline T read() { register T sum = 0; register char cc = getchar(); int sym = 1; while (cc != - && (cc > 9 || cc < 0 )) cc = getchar(); if (cc == - ) sym = -1, cc = getchar(); sum = sum * 10 + cc - 0 ; cc = getc... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.