text stringlengths 59 71.4k |
|---|
// (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; const int N = 2005; const int MOD = 1e9 + 7; int a[N][N]; vector<pair<int, pair<int, int> > > vv; int p[N], dist[N][N]; std::vector<pair<int, int> > v[N]; int visit[N]; int root(int x) { while (x != p[x]) { p[x] = p[p[x]]; x = p[x]; } ... |
/**
* ------------------------------------------------------------
* Copyright (c) All rights reserved
* SiLab, Institute of Physics, University of Bonn
* ------------------------------------------------------------
*/
`timescale 1ps/1ps
`default_nettype none
module gpio_sbus #(
parameter BASEADDR = 16'h0000,... |
// Copyright 1986-2017 Xilinx, Inc. All Rights Reserved.
// --------------------------------------------------------------------------------
// Tool Version: Vivado v.2017.3 (lin64) Build Wed Oct 4 19:58:07 MDT 2017
// Date : Tue Oct 17 19:49:28 2017
// Host : TacitMonolith running 64-bit Ubuntu 16.04.3... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; string second; cin >> n >> second; string t = second; bool ok = 1; vector<int> vec; for (int i = 0; i < n; i++) { if (second[i] == W ) continue; if... |
/*
* Milkymist VJ 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 ... |
/**
* bsg_cache_to_axi_tx.v
*
* @author tommy
*/
`include "bsg_defines.v"
module bsg_cache_to_axi_tx
#(parameter `BSG_INV_PARAM(num_cache_p)
,parameter `BSG_INV_PARAM(data_width_p)
,parameter `BSG_INV_PARAM(block_size_in_words_p)
,parameter tag_fifo_els_p=num_cache_p
,parameter `BSG_INV_... |
//revision date: 2013/6/1
module udiv
#(parameter aw = 18,
parameter bw = 10)(
input [aw -1:0] a,
input [bw -1:0] b,
output [aw-1:0] quo,
output [bw-1:0] res,
output divide_by_0
);
assign divide_by_0 = b == 0 ? 1'b1:1'b0;
integer i;
reg frac;
reg [aw-1:0] quo... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 110; int a[MAXN]; int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } int main() { int n, i; while (scanf( %d , &n) == 1) { scanf( %d , &a[0]); int temp = a[0]; int mmax = a[0]; for (i = 1; i < n; i++) { ... |
/*
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law... |
#include <bits/stdc++.h> using namespace std; void getZarr(const string &str, int Z[]) { int n = str.length(); int L, R, k; L = R = 0; for (int i = 1; i < n; ++i) { if (i > R) { L = R = i; while (R < n && str[R - L] == str[R]) R++; Z[i] = R - L; R--; } els... |
/*
Copyright (c) 2014-2018 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... |
#include <bits/stdc++.h> #pragma GCC optimize( O2,unroll-loops ) using namespace std; const int inf = 1000000010; const long long INF = 10000000000000010LL; const int mod = 1000000007; const int MAXN = 300010, LOG = 20; int n, m, k, u, v, x, y, t, a, b, ans; int par[MAXN], h[MAXN], leaf[MAXN]; vector<... |
#include <bits/stdc++.h> using namespace std; const int N = 2e6 + 10; int a[N], nx[N]; long long pr[N]; int main() { int n, q; scanf( %d %d , &n, &q); for (int i = 1; i <= n; i++) scanf( %d , &a[i]), a[i + n] = a[i]; for (int i = 1; i <= n + n; i++) pr[i] = pr[i - 1] + a[i]; while (q--) { ... |
/*
* 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 DramWriter(
input fclk,
input rst_n,
//AXI port
output M2S_AXI_ACLK,
output reg [31:0] M2S_AXI_AWADDR,
input M2S_AXI_AWREADY,
output reg M2S_AXI_AWVALID,
output [63:0] M2S_AXI_WDATA,
output [7:0] M2S_AXI_WSTRB,
input M2S_AXI_WREADY,
output M2S_AXI_WVALID... |
/* Tests unused logic removal to ensure no useful logic is removed from the circuit */
module bm_arithmetic_unused_bits(clk,
add_31_16_in0, add_31_16_in1, add_31_16_out,
add_15_0_in0, add_15_0_in1, add_15_0_out,
add_31_24_in0, add_31_24_in1, add_31_24_out,
add_7_0_in0, add_7_0_in1, add_7_0_out,
sub_31_16_in0,... |
#include <bits/stdc++.h> using namespace std; long long int ans = 0; vector<int> vx[200005]; bool vu[200005]; int n, k; int dfs(int v, int p) { int aa = 0, aa2 = 0; for (int i = 0; i < vx[v].size(); i++) { if (vx[v][i] == p) continue; int pr = dfs(vx[v][i], v); aa += pr; aa2 ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const double eps = 1e-9; char mapp[110][110]; int main() { cin.sync_with_stdio(false); int n, m; int ans, cnt; int x1, x2, y1, y2; while (cin >> n >> m) { ans = 0; x1 = 0x3f3f3f3f, x2 = -1, y1 = 0x3f3f... |
// test_simulation_shifter_left_16_test.v
module f1_test(input [15:0] IN, input [4:0] SHIFT, output [15:0] OUT);
assign OUT = IN << SHIFT;
endmodule
// test_simulation_shifter_left_32_test.v
module f2_test(input [31:0] IN, input [5:0] SHIFT, output [31:0] OUT);
assign OUT = IN << SHIFT;
endmodule
// test_simulatio... |
// (C) 2001-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 doc... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { while (a) b %= a, swap(a, b); return b; } char x[1000005], y[1000005]; int aux[1000005][26]; int main() { long long n, m; cin >> n >> m; scanf( %s %s , x, y); int lenx = strlen(x), leny = strlen(y... |
#include <bits/stdc++.h> using namespace std; int main() { double a, b, c; cin >> a >> b >> c; cout << (int)ceil(c * (a - b) / b); } |
#include <bits/stdc++.h> using namespace std; const int MAXN = -1; struct disk { long long L; double p; disk(long long L = 0, double p = 0.) : L(L), p(p) {} }; bool operator<(disk a, disk b) { return (a.L * a.p * (1 - b.p)) > (b.L * b.p * (1 - a.p)); } int n; vector<disk> P; int main()... |
#include <bits/stdc++.h> struct node { int* children; node() { children = new int[2]; children[0] = children[1] = -1; } int& operator[](int i) { return children[i]; } }; struct trie { std::vector<node> nodes; int root; trie() { nodes.push_back(node()); root = 0;... |
#include <bits/stdc++.h> using namespace std; namespace my_template { const long double PI = 3.14159265358979323846264338327950288419716939937510582097494L; template <typename T> pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.first + b.first, a.second + b.second... |
/**
* 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) 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... |
// 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 : Tue Sep 19 09:38:30 2017
// Host : DarkCube running 64-bit major release ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; using ii = pair<long long, long long>; using ll = long long; using ull = unsigned long long; using ld = long double; using vec = vector<long long>; using vecc = vector<vector<long long> >; namespace royyaha { template <typen... |
#include <bits/stdc++.h> using namespace std; const int N = int(2e6) + 12, mod = int(1e9) + 7; int n, z[N]; char second[N]; int Z(string x) { int m = int(x.size()); string t = x; reverse((t).begin(), (t).end()); string second = x + # + t; int res = 0; for (int i = 1, l = 0, r = 0; i ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long n; cin >> n; set<int> used; for (int i = 2; i * i <= n; i++) { if (n % i == 0 && !used.count(i)) { used.insert(i); n /= i; break; } ... |
/************************
* Willard Wider
* 6-5-17
* ELEC3725
* alu32.v
* building a 32 bit ALU
************************/
`timescale 1ns / 1ps//Unit time
//The top module of the entire project. The declaration of the entire ALU itself.
module alu32 (d, Cout, V, a, b, Cin, S);
output[31:0] d;//the output bus
o... |
// megafunction wizard: %LPM_COUNTER%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: LPM_COUNTER
// ============================================================
// File Name: rda_bitcounter.v
// Megafunction Name(s):
// LPM_COUNTER
//
// Simulation Library Files(s):
// lpm
// =============================... |
#include <bits/stdc++.h> using namespace std; using ll = long long; struct par { ll l; ll r; }; int n; ll s; par mas[200100]; bool cmp(par a, par b) { return (a.l < b.l); } bool good(ll m) { vector<par> grp1; vector<par> grp2; vector<par> grp3; for (int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k = 0; string ans = ; cin >> n; while (n > 1) { ans += 8 ; k += 1; n -= 2; } if (n == 1) { ans += 9 ; k++; n--; } if (k < 19) cout << ans; else cout << -1; re... |
/*
* Copyright 2013, Homer Hsing <>
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to ... |
//************************************
// Designed by: Wenyi Xu
// Last updated: 15/10/21
//************************************
module word_com(clk, rst, data_in, letter_in);
parameter letter_size = 8;
parameter word_length = 128; // 128-bit 128/8 = 16 letters in one word
parameter word_num = 63; // This v... |
#include <bits/stdc++.h> using namespace std; template <class T> T max(T a, T b, T c) { return max(a, max(b, c)); } int nextInt() { int x = 0, p = 1; char c; do { c = getchar(); } while (c <= 32); if (c == - ) { p = -1; c = getchar(); } while (c >= 0 && c <... |
#include <bits/stdc++.h> #define int long long #pragma GCC target ( avx2 ) #pragma GCC optimization ( O3 ) #pragma GCC optimization ( unroll-loops ) /*#include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<int, null_type,l... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int N = 5e10 + 5; int main() { bool flag = 0; int n, ans = 0, k; cin >> n; int arr[n + 5]; for (int i = 0; i < n; i++) { cin >> arr[i]; } sort(arr, arr + n); k = n / 2; for (int i = 0; i < 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 law... |
#include <bits/stdc++.h> using namespace std; const int inf = 1e9 + 9; int n, vl, ans, tmp[110000], ret[110000]; void redo(vector<int>& a) { int i, j, s, p, q, nn = 0; for (i = 0; i < a.size(); i++) { if (nn == 0 || a[nn - 1] < a[i]) a[nn++] = a[i]; } a.resize(nn); } void dfs(int id, v... |
#include <bits/stdc++.h> using namespace std; long long read() { long long w = 0, f = 1; char c = ; while (c < 0 || c > 9 ) c = getchar(), f = c == - ? -1 : f; while (c >= 0 && c <= 9 ) w = w * 10 + c - 48, c = getchar(); return w * f; } long long read14() { char c = getchar()... |
#include <bits/stdc++.h> using namespace std; int main() { int i = 0; ios_base::sync_with_stdio(false); cin.tie(NULL); vector<int> ans; int n; int m; cin >> n >> m; int a[110]; int b[20]; memset(a, 0, sizeof a); memset(b, 0, sizeof b); for (int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; int n, ans; bool pr[100003]; bool mark[100003]; vector<int> v; vector<int> e; vector<pair<int, int> > res; int main() { scanf( %d , &n); for (int i = 2; i <= n; i++) if (!pr[i]) { v.push_back(i); for (int j = 2 * i; j <= n; j +=... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 5, inf = 1e9 + 7; long long n, k; string s, t; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); long long i, j, a, b, ans = 0; cin >> n >> k >> s >> t; ans = n; i = 0; while (i < n && s[i] == t[i])... |
#include <bits/stdc++.h> using namespace std; long long a[100005]; long long d[800][800], g[800][800]; int w[100]; vector<long long> v; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %lld , &a[i]); long long x = a[i]; int cnt = 0; while (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 law... |
#include <bits/stdc++.h> using namespace std; int n; int a[6], b[6], ord[6], c[6]; vector<pair<int, int> > v, nv; struct S { vector<pair<int, int> > v; int from; S(vector<pair<int, int> > v, int from) : v(v), from(from) {} S() {} }; vector<S> s; void pr(int a, int b) { if (a == 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 (c) 2008 Xilinx, Inc. All rights reserved.
//
// XILINX CONFIDENTIAL PROPERTY
// This document contains proprietary information which is
// protected by copyright. All rights are reserved. This notice
... |
/*
* 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 N = 260, mo = 777777777; int f[30][N][N], c[N * 2][N * 2], n, k, ans; int power(int x, int y) { int s = 1; for (; y; y /= 2, x = 1ll * x * x % mo) if (y & 1) s = 1ll * s * x % mo; return s; } int main() { scanf( %d%d , &n, &k); ... |
#include <bits/stdc++.h> using namespace std; template <class T> string toStr(const T &x) { stringstream s; s << x; return s.str(); } template <class T> int toInt(const T &x) { stringstream s; s << x; int r; s >> r; return r; } vector<string> pals; bool check(string s) ... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
/*
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law... |
`include "v2k_typedef_yee_inc.v"
module v2k_typedef_yee
(/*AUTOARG*/
// Outputs
sub2_out_pixel, ready, sub1_to_sub2_and_top,
// Inputs
sub1_in_pixel, reset, pixel_ff, cp
);
//-----------------------
// Output definitions
//
output logic_t sub1_to_sub2_and_top; // Explicit output port
... |
/*------------------------------------------------------------------------------
* This code was generated by Spiral Multiplier Block Generator, www.spiral.net
* Copyright (c) 2006, Carnegie Mellon University
* All rights reserved.
* The code is distributed under a BSD style license
* (see http://www.opensource.or... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( avx,avx2,fma ) #pragma GCC optimization( unroll-loops ) using namespace std; const long long MOD = 998244353; const long long INF = 0x7f7f7f7f7f7f7f7f; const int INFi = 0x7f7f7f7f; const long long N = 150001; vector<long long> ... |
#include <bits/stdc++.h> using namespace std; bool debug = 1; int n, m, k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; long long ln, lk, lm; int dp[1 << 20], s[105], t[105]; string ac[105]; int main() { scanf( %d , &n); for (int(i) = 0; (i) < (int)(n); (i)++) scanf( %d , s + i); sort(s... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; while (cin >> a >> b) { if (a == 0 && b == 0) cout << NO << endl; else { c = abs(a - b); if (c == 0 || c == 1) cout << YES << endl; else cout << NO << endl; } ... |
#include <bits/stdc++.h> using namespace std; const int mod = (int)1e9 + 7; const int N_ = (int)1e6 + 2; long long Hash_a[N_]; long long Hash_b[N_]; long long pow26[N_]; string a, b; long long n; long long get_hash_a(long long x, long long y) { return (Hash_a[y] - Hash_a[x - 1] * pow26[y - x + 1] ... |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0; char ch = getchar(); bool positive = 1; for (; ch < 0 || ch > 9 ; ch = getchar()) if (ch == - ) positive = 0; for (; ch >= 0 && ch <= 9 ; ch = getchar()) x = x * 10 + ch - 0 ; return positive ? x : -x;... |
#include <bits/stdc++.h> using namespace std; void read(int &val) { int x = 0; int bz = 1; char c; for (c = getchar(); (c < 0 || c > 9 ) && c != - ; c = getchar()) ; if (c == - ) { bz = -1; c = getchar(); } for (; c >= 0 && c <= 9 ; c = getchar()) x = x * 10 + c... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 2, MAX2 = 2e6 + 4; int ans[MAX], val[MAX], depth[MAX]; vector<int> G[MAX], d[MAX2], occ[MAX2]; void init(int a) { if (d[a].size()) return; for (int i = 2; i * i <= a; i++) { if (a % i == 0) { d[a].push_back(a / i); ... |
/*
Copyright (c) 2015-2018 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... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( sse2 ) using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout... |
#include <bits/stdc++.h> using namespace std; int n; long long dp[26][2][2]; long long need; bool hasone = 0; int ans[55]; inline void upd(long long &a, long long b) { a += b; } inline long long getval(int p, int v) { memset(dp, 0, sizeof(dp)); dp[0][0][0] = 1; for (int i = 0; i < (n + 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... |
module timer(
input CLK,
input switch_up,
input switch_dn,
input switch_cancel,
input switch_start_stop,
output [7:0] SEG,
output [3:0] DIGIT,
output BUZZER
);
wire s_up, s_dn, s_cancel, s_start_stop;
debouncer d1(.CLK (CLK), .switch_input (switch_up), .trans_up (s_up)... |
/******************************************************************************
* License Agreement *
* *
* Copyright (c) 1991-2013 Altera Corporation, San Jose, California, USA. *
... |
#include <bits/stdc++.h> using namespace std; int main() { int dem = 0; int n; int tong = 0; int s; cin >> n; for (int i = 9; i >= 1; i--) { if (n % i == 0) { s = i; break; } } int z; z = n / s; cout << z << endl; while (z) { cout << s <<... |
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved.
// --------------------------------------------------------------------------------
// Tool Version: Vivado v.2016.4 (win64) Build Mon Jan 23 19:11:23 MST 2017
// Date : Sun Jun 18 18:41:11 2017
// Host : DESKTOP-GKPSR1F running 64-bit major re... |
#include <bits/stdc++.h> using namespace std; char s[1000001], t[1000001]; long long z[1000001], c[1000001]; int main() { int n, k; scanf( %d%d%s%s , &n, &k, s + 1, t + 1); if (k == 1) { printf( %d n , k * n); return 0; } int o = 1; while (o <= n && s[o] == t[o]) o++; if ... |
`timescale 1ns / 1ps
/*
-- Module Name: DES Sbox 2
-- Description: Sbox 2 del algoritmo DES
-- Dependencies: -- none
-- Parameters: -- none
-- Original Author: Héctor Cabrera
-- Current Author:
-- Notas:
-- History:
-- Creacion 05 de Junio 2015
*/
module des_sbox2
... |
#include <bits/stdc++.h> using namespace std; int main() { long long int q; cin >> q; while (q--) { long long int n; cin >> n; long long int x, y; int l, u, r, s; long long int nl = -100000, nu = 100000, nr = 100000, ns = -100000; for (long long int i = 0; i < n; i++)... |
#include <bits/stdc++.h> using namespace std; int a, b, diff, n_div; int main() { int i; cin >> a >> b; diff = a - b; if (diff < 0) { cout << 0 << endl; } else if (diff == 0) { cout << infinity << endl; return 0; } else { for (i = 1; i * i <= diff; i++) ... |
/*
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law... |
#include <bits/stdc++.h> using namespace std; vector<int> childs[100000 + 1]; long long s[100000 + 1]; int p[100000 + 1]; long long a[100000 + 1]; bool flag = false; void fill(int v, long long prevsum) { if (s[v] != -1) { a[v] = s[v] - prevsum; if (a[v] < 0) flag = true; for (int i =... |
#include <bits/stdc++.h> using namespace std; vector<long long> v[70]; int n; long long ans[100010], cur = 0; int main() { cin >> n; for (int i = 1; i <= n; i++) { long long x; cin >> x; for (int j = 60; j >= 0; j--) if ((x >> j) & 1) { v[j].push_back(x); ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long b, long long y) { return b > 0 ? gcd(y % b, b) : y; } long long lcm(long long b, long long y) { return b * y / gcd(b, y); } double dis(double x1, double x2, double y1, double y2) { double ans = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2... |
`timescale 1 ns / 1 ns
//////////////////////////////////////////////////////////////////////////////////
// Company: Rehkopf
// Engineer: Rehkopf
//
// Create Date: 01:13:46 05/09/2009
// Design Name:
// Module Name: address
// Project Name:
// Target Devices:
// Tool versions:
// Description: Address logic w/ S... |
#include <bits/stdc++.h> using namespace std; int cnt[15]; int s[15]; char c[1 << 20]; int need[15]; int digits(int first) { return !first ? 0 : 1 + digits(first / 10); } int main(void) { int n; string str; cin >> (c + 1) >> str; n = strlen(c + 1); for (auto it : str) ++need[it - 0 ];... |
#include <bits/stdc++.h> using namespace std; int a[1000005]; int main() { int t, n; cin >> t; while (t--) { cin >> n; int g = 0, s = 0, b = 0; int m = n / 2; for (int i = 1; i <= n; i++) { cin >> a[i]; } int i = 1; while (a[i] == a[1] && i <= m) { ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); string str; cin >> str; int n = str.length(); map<char, int> mp; for (int i = 0; i < n; i++) { mp[str[i]]++; } if (mp.size() % 2 == 1) cout << IGNORE HIM!... |
#include <bits/stdc++.h> using namespace std; void doRoutine() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } void minus1(string &s) { long long i = (long long)s.size() - 1; while (i >= 0 && s[i] == 0 ) { s[i] = 9 ; --i; } --s[i]; if (i == 0 && s[i] ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1005; struct Edge { int u, v, w, id; Edge() {} Edge(int a, int b, int c, int d) : u(a), v(b), w(c), id(d) {} bool operator<(const Edge e) const { return w > e.w; } } e[maxn * maxn]; int fa[maxn << 1]; int Find(int x) { return fa[... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; int n, s; long long a[maxn], b[maxn], c[maxn]; vector<int> p[2]; bool cmp1(int i, int j) { return b[i] - c[i] > b[j] - c[j]; } bool cmp2(int i, int j) { return c[i] - b[i] > c[j] - b[j]; } int main() { scanf( %d%d , &n, &s); ... |
`timescale 1ns/10ps
/*
功能:读写地址生成
输入:nrst-0复位
clk-时钟
wr_en-允许写
wr_inc-1写地址自增
load_w2r-加载写地址到读地址
rd_inc-读地址自增
rd_step-读地址自增大小,有符号数,负数为地址减小
输出:addr_wr-写地址
addr_rd-读地址
wr_end-1写满(写地址到达读地址)
修改:eleqian 2016-01-22
*/
module addr_gen(nrst, clk, wr_en, wr_inc, load_w2r, rd_inc, rd_step, ... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n, x; cin >> n >> x; long long a[n]; for (auto &i : a) cin >> i; long long pre[n + 1]; pre[0] = 0; for (long long i = 1; i <= n; i++) pre[i] = (pre[i - 1] + a[i - 1]) % x; long long ans = 0; for (long long i =... |
#include <bits/stdc++.h> using namespace std; ifstream fin( Sisend.txt ); int n, c; bool b[100005]; vector<int> v, v1; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cerr.tie(0); cin >> n; for (int(i) = (0); ((i)) < ((n)); ((i))++) { cin >> c; v.emplace_ba... |
#include <bits/stdc++.h> template <typename T> inline void read(T &x) { x = 0; char c = getchar(); bool flag = false; while (!isdigit(c)) { if (c == - ) flag = true; c = getchar(); } while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar(); if (flag) x = -x; } using names... |
#include <bits/stdc++.h> using namespace std; const int N = 1 << 12 | 5, Q = 1 << 16 | 5; int n, q, B, a[N], p[N], cnt, id[Q]; vector<pair<int, int>> opt; struct node { int n; vector<int> pos; vector<vector<int>> id; node(int _n = 0) { n = _n; pos.resize(n); id.resize(n); ... |
#include <bits/stdc++.h> using namespace std; string s; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int n, p, l = -1, r = 0, i, j, ans = 0; cin >> n >> p; cin >> s; n--, p--; if (p > n / 2) p = n - p; for (i = 0; i <= n / 2; i++) { if (s[... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const int maxn = 1e6 + 6; int a[maxn]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int pt = 0; if (n & 1) { for (int i = 2; i <= n; i += 2) { a[pt++] = i; } ... |
#include <bits/stdc++.h> using namespace std; void solve() { long long int n, i, count = 0; vector<long long int> v; string s1, s2, s3, reverses1, reverses2, reverses3; cin >> s1 >> s2 >> s3; reverses1 = s1; reverses2 = s2; reverses3 = s3; reverse(s1.begin(), s1.end()); reverse(s... |
#include <bits/stdc++.h> using namespace std; long long int a[2005]; long long int cnt[2005]; long long int b[2005]; long long int vis[2005]; vector<long long int> v; vector<long long int> vv; vector<long long int> ans; long long int prime[2005]; bool pr[2005]; set<char> st; priority_queue<long ... |
#include <bits/stdc++.h> static int solve(); using ll = long long; int main(int argc, char* argv[]) { int tc = 1; scanf( %d , &tc); while (tc--) solve(); return 0; } static constexpr int MOD = 998244353; static int solve() { int n, x, y; scanf( %d %d %d , &n, &x, &y); int sum = x... |
#include <bits/stdc++.h> using namespace std; int main() { string n; int count = 0; cin >> n; stack<char> s; for (int i = 0; i < n.length(); i++) { if (n[i] == ( ) { s.push(n[i]); } else if (n[i] == ) ) { if (s.size() != 0) { char tops = s.top(); ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.