text stringlengths 59 71.4k |
|---|
//
// 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> #pragma GCC optimize( Ofast ) using namespace std; long long int invmod(long long int x, long long int n, long long int mod) { if (n == 0) return 1 % mod; long long int half = invmod(x, n / 2, mod); half = (half * half) % mod; if (n % 2 == 1) half = (half * (x % mod)) % mo... |
/*
* Copyright (c) 2000 Yasuhisa Kato <>
*
* 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; const int maxN = 2000 + 5; int n, mark[maxN], m, st[maxN], start, high[maxN], on[maxN], cnt; vector<int> adj[maxN]; vector<int> s; void DFS(int v) { s.push_back(v); on[v] = mark[v] = 1; st[v] = high[v] = start++; for (int i = 0; i < adj[v].size()... |
#include <bits/stdc++.h> using namespace std; const int N = 2501; mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count()); int n, p[2 * N], a[N][N], cur; void no() { puts( NOT MAGIC ); exit(0); } struct edge { int u, v, w; edge(int a = 0, int b = 0, int c = 0) { u = ... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; int n, v[N], id[N], now[N], p[N]; bool is_lucky(int x) { while (x) { if (x % 10 != 7 && x % 10 != 4) return false; x /= 10; } return true; } void change(int pos1, int pos2) { swap(now[p[pos1]], now[p[pos2]]); ... |
#include <bits/stdc++.h> using namespace std; string s; int k; int main() { cin >> s; for (int i = 0; i < s.length(); i++) if (s[i] == 1 ) k++; if (k > 1) cout << (s.length() + 1) / 2 << endl; else cout << s.length() / 2 << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; const int maxn = 105; int n, m; char g[maxn][maxn]; int vis[3]; map<char, int> mp; int main() { mp[ R ] = 0; mp[ G ] = 1; mp[ B ] = 2; scanf( %d%d , &n, &m); for (int i = 0; i < n; i++) scanf( %s , g[i]); bool ok = true; if (g[0][0]... |
`include "uart.vh"
module infra(
input clk_i,
output clk_o_uart_rx,
output clk_o_uart_tx,
input rst_i,
output [7:0] led_o,
input rx_i,
output [`UART_DATA_LENGTH - 1 : 0] rx_o,
output rx_o_v,
input [`UART_DATA_LENGTH - 1 : 0] tx_i,
... |
// (C) 2001-2017 Intel Corporation. All rights reserved.
// Your use of Intel Corporation's design tools, logic functions and other
// software and tools, and its AMPP partner logic functions, and any output
// files from any of the foregoing (including device programming or simulation
// files), and any associated ... |
//Legal Notice: (C)2021 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; int main() { int d, L, v1, v2; cin >> d >> L >> v1 >> v2; printf( %lf n , 1.0 * (L - d) / (v1 + v2)); } |
#include <bits/stdc++.h> using namespace std; const int N = 1001000; int n; void add(long long* a, int x, long long y) { for (; x <= n; x += x & -x) a[x] += y; } long long gsm(long long* a, int x) { long long ret = 0; for (; x; x &= x - 1) ret += a[x]; return ret; } long long sum0[N], su... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; int n, m; char s[5005]; long long state[5005]; long long dp[5005][5005]; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= m; i++) { scanf( %s , s + 1); for (int j = 1; j <= n; j++) if (s[j] == ... |
#include <bits/stdc++.h> using namespace std; const int max_n = 20222, mod = 998244353; int n, k, q, A[max_n], a[max_n]; int dp[max_n]; int solve() { int q1 = 0, q2 = 1; memset(dp, 0, sizeof(dp)); dp[0] = 1; for (int i = 0; i < n; ++i) { for (int j = min(i + 1, k); j >= max(1, k - (n - i... |
/**
* bsg_mem_1rw_sync_mask_write_byte_banked.v
*
* This module has the same interface/functionality as
* bsg_mem_1rw_sync_mask_write_byte.
*
* This module can be used for breaking a big SRAM block into
* smaller blocks. This might be useful, if the SRAM generator does not
* support sizes of SRAM that are... |
/**
* 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... |
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2021 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
module t(/*AUTOARG*/
// Inputs
clk
);
input clk;
integer cyc = 0;
reg [63:0] crc;
re... |
#include <bits/stdc++.h> using namespace std; long long t1, t2, x1, x2, t0, ans1, ans2, z1, z2, y20; inline void trr(const long long& y1_gdssdfjsdgf, const long long& y2) { if (y1_gdssdfjsdgf == 0 && y2 == 0) return; if (ans1 == -1) { if ((y1_gdssdfjsdgf * t1 + y2 * t2) >= t0 * (y1_gdssdfjsdgf + y2)... |
// --------------------------------------------------------------------------------
//| Avalon Streaming Channel Adapter
// --------------------------------------------------------------------------------
`timescale 1ns / 100ps
module lab3_master_0_b2p_adapter (
// Interface: clk
input cl... |
#include <bits/stdc++.h> using namespace std; int n, a[1001], k; int main() { scanf( %d%d , &n, &k); n = 2 * n + 1; for (int i = 1; i <= n; ++i) scanf( %d , &a[i]); for (int i = 2; i < n; i += 2) if (k && a[i - 1] + 1 < a[i] && a[i] > a[i + 1] + 1) { a[i]--; k--; } ... |
#include <bits/stdc++.h> using namespace std; int n, x; vector<int> w; vector<int> v; bool volt[1111]; int main() { ios_base::sync_with_stdio(false); cin >> n; for (int i = 1; i <= n; i++) { cin >> x; v.push_back(x); } reverse(v.begin(), v.end()); for (int i = 0; i < v.si... |
#include <bits/stdc++.h> using namespace std; int n, na, nb, nc; vector<int> a, b; vector<int> start; int solve(vector<pair<int, int> > &c, vector<pair<int, int> > &b) { int nb = b.size(); int nc = c.size(); int ans = 0; sort(c.begin(), c.end()); sort(b.begin(), b.end()); int i = 0, j ... |
#include <bits/stdc++.h> char s[2000000], t[2000000]; int n, i, YY = 0, YN = 0, NY = 0, NN = 0, Yaro = 0, Andrew = 0; int main() { scanf( %d n , &n); for (i = 0; i < 2 * n; i++) scanf( %c , &s[i]); scanf( n ); for (i = 0; i < 2 * n; i++) scanf( %c , &t[i]); for (i = 0; i < 2 * n; i++) { ... |
#include <bits/stdc++.h> using namespace std; long long n, m; string s; long long q; char ch; long long k = 0; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m >> s; for (long long i = 0; i < n - 1; i++) if (s[i] == . && s[i + 1] == . ) k++; ... |
`timescale 1ns / 1ps
`include "Defintions.v"
`define LOOP1 8'd8
`define LOOP2 8'd5
module ROM
(
input wire[15:0] iAddress,
output reg [27:0] oInstruction
);
always @ ( iAddress )
begin
case (iAddress)
0: oInstruction = { `NOP ,24'd4000 };
1: oInstruction = { `STO , `R7,16'b0001 };
2: o... |
#include <bits/stdc++.h> using namespace std; int mini; map<char, int> M; set<int> s; int n; void rec(int ind, vector<int> c, vector<int> d) { if (ind == 10) { int rem = n; int X = c.size() + d.size(); int i, j; set<int> S = s; set<int>::iterator it; for (i = 0; i < c... |
// $Id: c_wf_alloc_wrapper.v 1833 2010-03-22 23:18:22Z dub $
/*
Copyright (c) 2007-2009, Trustees of The Leland Stanford Junior University
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistribution... |
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { vector<int> v; long long res, me = 0, mf = 0; for (int i = 0; i < n; i++) { int c; cin >> c; v.push_back(c); } long long res1 = 1000000 - v[0]; res = 1000007; ... |
/**
* 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 Coherent_Coff(
input clk,
input [11:0] Data_A,Data_B,Data_C,Data_D,Data_E,Data_F,Data_G,Data_H,
output reg [7:0] Coff
);
wire [15:0] R1,R2,R3,R4,R5,R6,R7,R8;
wire [15:0] I1,I2,I3,I4,I5,I6,I7,I8;
reg [15:0] R_IN1,R_IN2,R_IN3,R_IN4,R_IN5,R_IN6,R_IN7,R_IN8;
reg [15:0] I_IN1,I_IN2,I_IN3,I_IN4,I_IN... |
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 19:15:54 04/12/2017
// Design Name: vga_display
// Module Name: D:/Dropbox/2nd Year USC/EE 354/Final_Project/verilog_projects/VGA/vga_sprites/vga_sprites/vga_... |
/**
* 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... |
//Legal Notice: (C)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
//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; int main() { long long int n, i, j; cin >> n; long long int a[n], b[n], t[n]; for (i = 1; i < n; i++) cin >> a[i]; for (i = 1; i < n; i++) cin >> b[i]; for (i = 0; i < 4; i++) { t[0] = i; for (j = 1; j < n; j++) { if (a[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... |
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 1995/2015 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
//
/... |
#include <bits/stdc++.h> using namespace std; long long geti() { long long ret = 0; char ch = getchar(), k = 1; while ((ch < 0 || ch > 9 ) && ch != - ) ch = getchar(); if (ch == - ) k = 0, ch = getchar(); while (ch >= 0 && ch <= 9 ) ret = ret * 10 + ch - 0 , ch = getchar(); return k... |
#include <bits/stdc++.h> using namespace std; long double s, a, b, c; int main() { cin >> s >> a >> b >> c; if (a + b + c == 0) { cout << 0 << << 0 << << 0 << endl; return 0; } long double x = s * a / (a + b + c); long double y = s * b / (a + b + c); long double z = s *... |
// Accellera Standard V2.3 Open Verification Library (OVL).
// Accellera Copyright (c) 2005-2008. All rights reserved.
`include "std_ovl_defines.h"
`module ovl_cycle_sequence (clock, reset, enable, event_sequence, fire);
parameter severity_level = `OVL_SEVERITY_DEFAULT;
parameter num_cks = 2;
... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); ; cin.tie(NULL); ; int n, b; double total = 0, maxx = 0; cin >> n >> b; double ar[n]; for (int i = 0; i < n; i++) { cin >> ar[i]; total += ar[i]; maxx = max(maxx, ar[i])... |
#include <bits/stdc++.h> using namespace std; const int N = 1000 * 100 + 10; const long long INF = 1000 * 1000 * 1000LL * 1000 * 10000; int n, q, pt = 1, cnt; vector<long long> ans; set<pair<long long, long long> > s; set<pair<long long, long long> >::iterator it1, it2; long long po[100], a[N], sum[N * ... |
// Copyright 1986-2014 Xilinx, Inc. All Rights Reserved.
// --------------------------------------------------------------------------------
// Tool Version: Vivado v.2014.3 (lin64) Build Fri Oct 3 16:31:15 MDT 2014
// Date : Sun Oct 25 15:41:08 2015
// Host : arthas-ubuntu running 64-bit Ubuntu 14.04.3... |
/*
* Copyright (c) 2000 Intrinsity, Inc.
*
* 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; #define TC 1 #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define deb(...) [ << #__VA_ARGS__ : << (__VA_ARGS__) << ] using ll = long long; template <typename T> vector<T> readArr(int n) { vector <T> v(n); for (auto &it ... |
#include <bits/stdc++.h> using namespace std; vector<long long> sp; vector<pair<long long, long long>> bases; int main() { int s, b; cin >> s >> b; long long num, num2; for (int i = 0; i < s; i++) { cin >> num; sp.push_back(num); } for (int i = 0; i < b; i++) { cin >> n... |
#include <bits/stdc++.h> using namespace std; int n, q, f[1000010], mn, rt, ans; int cnt, head[1000010], to[2000010], nxt[2000010]; void add(int x, int y) { cnt++; to[cnt] = y; nxt[cnt] = head[x]; head[x] = cnt; } void dfs(int x, int fa, int now) { f[x] = now; for (int i = head[x]; i... |
#include <bits/stdc++.h> using namespace std; int Read() { char c; while (c = getchar(), (c != - ) && (c < 0 || c > 9 )) ; bool neg = (c == - ); int ret = (neg ? 0 : c - 48); while (c = getchar(), c >= 0 && c <= 9 ) ret = ret * 10 + c - 48; return neg ? -ret : ret; } const ... |
#include <bits/stdc++.h> const int maxx = 2e5 + 7; const int maxn = 1e9 + 7; using namespace std; inline int read() { int s = 0, w = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) w = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) s = s * 10 + ch - 0... |
#include <bits/stdc++.h> using namespace std; const long long inf = 2147383647; const double pi = 2 * acos(0.0); const double eps = 1e-9; struct debugger { template <typename T> debugger& operator,(const T& v) { cerr << v << ; return *this; } } dbg; inline long long gcd(long lon... |
// megafunction wizard: %LPM_MULT%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: lpm_mult
// ============================================================
// File Name: acl_int_mult64s.v
// Megafunction Name(s):
// lpm_mult
//
// Simulation Library Files(s):
// lpm
// =====================================... |
/*
* In The Name Of God
* ========================================
* [] File Name : cache_ctl_t.v
*
* [] Creation Date : 04-03-2015
*
* [] Last Modified : Thu, Apr 2, 2015 10:12:18 AM
*
* [] Created By : Parham Alvani ()
* =======================================
*/
`timescale 1 ns/100 ps
module cache_ctl_t;... |
#include <bits/stdc++.h> using namespace std; int n, m, k, kk; vector<int> g[10], e[10]; int cnt = 0; bool used[10] = {}, vis[10] = {}; int usedCnt, visCnt; long long cur; int st; int pc[1024]; void go(int v) { vis[v] = true, ++visCnt; vector<int> &f = e[v]; int sz = 0; for (int x : ... |
/**
* 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 p[1100000], r[1100000], cnt; int main() { long long n, bac; cin >> n; if (n == 1) { printf( 1 n ); return 0; } bac = n; long long i; for (i = 2; i * i <= n; i++) { if (bac % i == 0) { cnt++; p[cnt... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 10:40:46 05/12/2015
// Design Name:
// Module Name: ID_EX
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependenc... |
#include <bits/stdc++.h> using namespace std; long long int dpmax[200005][20]; long long int dpmin[200005][20]; long long int a[200005], b[200005]; int n; void ST() { for (int i = 1; i <= n; i++) { dpmax[i][0] = a[i]; dpmin[i][0] = b[i]; } for (int j = 1; (1 << j) <= n; j++) { ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 10; const int MOD = 1e9 + 7; int n, l, m; struct Matrix { int mat[105][105]; void init() { memset(mat, 0, sizeof mat); } }; Matrix operator*(Matrix A, Matrix B) { Matrix C; C.init(); for (int i = 0; i < m; i++) { ... |
#include <bits/stdc++.h> using namespace std; vector<vector<int> > v; vector<vector<int> > vv; vector<vector<long long int> > dp; void merg(int x) { if (v[x].size() == 1) return; if (v[x].size() == 2) { vector<int> v1; v1.push_back(0); for (int i = 0; i < v[x * 2].size(); i++) { ... |
// Copyright 1986-2017 Xilinx, Inc. All Rights Reserved.
// --------------------------------------------------------------------------------
// Tool Version: Vivado v.2017.2 (win64) Build Thu Jun 15 18:39:09 MDT 2017
// Date : Fri Sep 22 22:04:20 2017
// Host : DarkCube running 64-bit major release ... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 06/23/2015 05:17:53 PM
// Design Name:
// Module Name: testcase_basic
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//... |
/* lab2_part5.v
*
* Copyright (c) 2014, Artem Tovbin <arty99 at gmail dot com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope tha... |
// (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; template <class T> inline void maz(T &a, T b) { if (a < b) a = b; } template <class T> inline void miz(T &a, T b) { if (a > b) a = b; } template <class T> inline T abs(T a) { return a > 0 ? a : -a; } const int N = 100100, INF = 1e9; const... |
#include <bits/stdc++.h> using namespace std; template <class T> T abs(T x) { return x > 0 ? x : -x; } const double eps = 1e-10; int n; int m; double ax, ay, az, vx, vy, vz, R, r, ox, oy, oz, px, py, pz; double scal(double x1, double y8687969, double z1, double x2, double y2, double ... |
module uart
#(parameter cnt_max=433)
(
input clk, rst,
output reg txd,
input rxd,
input [7:0] din,
input din_en,
output [7:0] dout,
output dout_en,
output reg of_err
);
reg [7:0] din_fifo[63:0];
reg [5:0] fifo_head;
reg [5:0] fifo_tail;
wire [5:0] ... |
#include <bits/stdc++.h> using namespace std; long long n; bool isvalid(long long x) { if (x >= 0 && x <= n - 1) return true; else return false; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; vector<long long> a(n); for (long long i = 0; i... |
module j1soc#(
//parameter bootram_file = "../../firmware/hello_world/j1.mem" // For synthesis
parameter bootram_file = "../firmware/Hello_World/j1.mem" // For simulation
)(
uart_tx, ledout,
sys_clk_i, sys_rst_i, sclk, miso, mosi,ss, mic_in, ... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 11:09:49 05/12/2015
// Design Name:
// Module Name: one_iteration
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// D... |
`timescale 1ns/10ps
module Computer_System_VGA_Subsystem_VGA_PLL_video_pll(
// interface 'refclk'
input wire refclk,
// interface 'reset'
input wire rst,
// interface 'outclk0'
output wire outclk_0,
// interface 'outclk1'
output wire outclk_1,
// interface 'outclk2'
output wire outclk_2,
// interface ... |
#pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma ) #pragma GCC optimize( unroll-loops ) #include <bits/stdc++.h> using namespace std; typedef long long ll; #define S second #define v vector #define dbg(x) cout<<#x<< = <<(x)<<endl; ... |
#include <bits/stdc++.h> using namespace std; struct LCA { int logn; vector<int> depth; vector<vector<int> > lca; vector<vector<int> > *edges; LCA(int n, vector<vector<int> > *edges) { logn = log(n) / log(2) + 1; depth.resize(n + 1, 0); lca.resize(n + 1, vector<int>(logn, 0)); ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 2 * 1e5 + 5; const int INF = 1e9; const int MOD = 1e9 + 7; int N, K, A[MAX], table[20][MAX]; int main() { cin >> N >> K; for (int i = 0; i < (N); ++i) cin >> A[i]; for (int i = 0; i < (N); ++i) table[0][i] = A[i]; vector<int> b(N,... |
`default_nettype none
`timescale 1ns / 1ps
//
// Signal Descriptions
// ===================
//
// clk_i Processor clock.
// reset_i 1 to reset the circuit in the next cycle.
// 0 for normal operation.
//
// Inputs from the decode stage:
//
// inpa_i ALU input value A.
// inpb_i ALU input value B.
//
// invB_i 1 to in... |
//*****************************************************************************
// (c) Copyright 2008 - 2013 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
/... |
#include <bits/stdc++.h> using namespace std; long long tab[70]; void Tab() { for (int i = 0; i < 64; i++) tab[i] = pow(2, i); } long long Sum(long long n) { long long m = n + 1; if ((long long)(m) % 2 == 0) m /= 2; else n /= 2; long long sum = m * n; return sum; } long... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; const double eps = 1e-6; const int inf = 0x3f3f3f3f; const long long INF = 100000000000000000ll; const int MAXN = 4004; const int MAXM = 300030; int dp[MAXN][MAXN]; int main() { int n; cin >> n; dp[0][0] = 1; for... |
#include <bits/stdc++.h> using namespace std; long long int power(long long int x, long long int y, long long int p) { long long int res = 1; x = x % p; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } in... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5, maxm = 1e4 + 5, maxe = maxn * 4 + maxm, maxp = 4 * maxe; int n, m, b[maxe], id[maxe], tot, cnt, d; double p[maxp], ans; int read() { int ret = 0, f = 1; char ch = getchar(); while (ch > 9 || ch < 0 ) { if ... |
//Legal Notice: (C)2018 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... |
// (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 ... |
#include <bits/stdc++.h> using namespace std; int z[150005]; long long tir[150005]; int find(int a) { if (a != z[a]) { z[a] = find(z[a]); } return z[a]; } void mix(int a, int b) { z[find(a)] = find(b); } int main() { int n, m; scanf( %d%d , &n, &m); for (int i = 1; i <= n; i+... |
#include <bits/stdc++.h> using namespace std; long long int mod = 1e9 + 7; long long int casei(long long int tc) { long long int n, i, trn = 1, fct = 1; cin >> n; for (i = 1; i <= n; i++) { if (i < n) trn *= 2; fct *= i; trn %= mod; fct %= mod; } long long int ans = fct... |
#include <bits/stdc++.h> using namespace std; template <class T, class L> inline bool smax(T &x, L y) { return x < y ? (x = y, 1) : 0; } template <class T, class L> inline bool smin(T &x, L y) { return y < x ? (x = y, 1) : 0; } const int maxn = 2e2 + 17, maxm = maxn * maxn; int from[maxm], to[... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > vc, va, vb; int a[3], b[3], c[3]; long long n, m, s, p[50], pp[1 << 20]; void fac(int k, vector<pair<int, int> > &v) { int m = sqrt(k); for (int i = 2; i <= m; i++) if (k % i == 0) { int cnt = 0; while (k % i =... |
//==============================================================================
// Copyright (C) John-Philip Taylor
//
//
// This file is part of a library
//
// This file is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Fre... |
#include <bits/stdc++.h> template <typename T> void MACRO_VAR_Scan(T& t) { std::cin >> t; } template <typename First, typename... Rest> void MACRO_VAR_Scan(First& first, Rest&... rest) { std::cin >> first; MACRO_VAR_Scan(rest...); } template <typename T> void MACRO_VEC_ROW_Init(int n, T& t) ... |
/**
* 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 (C) 2009 , Olivier Girard
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must re... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; string s; cin >> s; vector<int> vec(n); vector<int> kactane(30, 0); vector<int> harfmax(30, 0); int res = 0; for (int i = 0; i < n; i++) { 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> int dx[] = {0, 0, 1, -1, 2, 2, -2, -2, 1, -1, 1, -1}; int dy[] = {1, -1, 0, 0, 1, -1, 1, -1, 2, 2, -2, -2}; using namespace std; class PAIR { public: long long int first; long long int second; long long int third; }; vector<long long int> V, V2, V3; long long int ar... |
#include <bits/stdc++.h> using namespace std; struct node { int l; int r; int val; }; node tree[800010]; vector<int> pre[200010]; int ary[200010]; int n, q; void pushup(int cur) { tree[cur].val = min(tree[2 * cur].val, tree[2 * cur + 1].val); } void build(int l, int r, int cur) { ... |
#include <bits/stdc++.h> using namespace std; void calc(int n, long long s, long long m, int i) { if (n == 0) return; s = s / 2; if (s < m) { calc(n - 1, s, m - s, i + 1); cout << i << ; } else { cout << i << ; calc(n - 1, s, m, i + 1); } } int main() { int ... |
/*
* Copyright (c) 2001 Ted Bullen
*
* 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 la... |
// Model of FIFO in Altera
module fifo_1c_1k ( data, wrreq, rdreq, rdclk, wrclk, aclr, q,
rdfull, rdempty, rdusedw, wrfull, wrempty, wrusedw);
parameter width = 32;
parameter depth = 1024;
//`define rd_req 0; // Set this to 0 for rd_ack, 1 for rd_req
input [31:0] data;
input wrreq;
in... |
#include <bits/stdc++.h> using namespace std; const int N = 212345, LG = 21, mod = 1000000007; const double eps = 1e-3, pi = acos(-1.0); char s[5], t[5], a[3]; int main() { long long n, k; scanf( %lld , &n), scanf( %lld , &k); if (n / 2 > k) { printf( %lld n , k * (2 * k - 1) + (n - 2 * k) *... |
#include <bits/stdc++.h> using namespace std; const int N = 200006; vector<vector<int> > edges(N); vector<int> color; bool bipartite; vector<pair<int, int> > e; int n, m; void dfs(int node, int c) { color[node] = c; for (auto to : edges[node]) { if (color[to] == -1) { dfs(to, c ^ 1... |
#include <bits/stdc++.h> using namespace std; char a[2000005]; int n, k, kmp[2000005], z[2000005]; int ch[2000005]; inline void GetKMP() { int j = 0; for (int i = 2; i <= n; i++) { while (j && a[j + 1] != a[i]) j = kmp[j]; if (a[j + 1] == a[i]) j++; kmp[i] = j; } return; } ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.