text stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> int main() { int n, A[50], B[1001], i, X, C[50], t = 0; scanf( %d , &n); for (i = 0; i <= 1000; i++) { B[i] = 0; } for (i = 0; i < n; i++) { scanf( %d , &A[i]); X = A[i]; B[X] += 1; } for (i = 0; i < n; i++) { X = A[i]; if (B[X] ... |
/*
----------------------------------------------------------------------------------
Copyright (c) 2013-2014
Embedded and Network Computing Lab.
Open SSD Project
Hanyang University
All rights reserved.
----------------------------------------------------------------------------------
Redistribution and use ... |
/**
* 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 n, i, ans, a[500001], f[2][1200001]; int main() { scanf( %lld , &n); f[0][0] = 1; for (i = 1; i <= n; i++) { scanf( %lld , &a[i]); a[i] ^= a[i - 1]; ans += f[i % 2][a[i]]; f[i % 2][a[i]]++; } printf( %lld , ans); ... |
//////////////////////////////////////////////////////////////////////////////////
// BRAMPopControl for Cosmos OpenSSD
// Copyright (c) 2015 Hanyang University ENC Lab.
// Contributed by Kibin Park <>
// Yong Ho Song <>
//
// This file is part of Cosmos OpenSSD.
//
// Cosmos OpenSSD is free software; yo... |
#include <bits/stdc++.h> using namespace std; const double PI = 3.14159265358979323846264338327950288419716939937510582097494459230; const long long MOD = 1e9 + 7; const long long INF = 1e14; long long mpow(long long a, long long b, long long p = MOD) { a = a % p; long long res = 1; while (b... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { int n, m, a, b; cin >> n >> m >> a >> b; a--; b--; vector<vector<int> > graph(n); for (int i = 0; i < m; i++) { int u, v;... |
//
// Copyright 2011 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is dis... |
/*
This file was generated automatically by the Mojo IDE version B1.3.6.
Do not edit this file directly. Instead edit the original Lucid source.
This is a temporary file and any changes made to it will be destroyed.
*/
/*
Parameters:
DATA_IN_SIZE = 30
*/
module fifo_2x_reducer_27 (
input rst,... |
#include <bits/stdc++.h> using namespace std; int n; int a[100002]; int mini[100002][21]; vector<pair<int, int> > vp; int f(int l, int r, int m) { if (l == r) { for (int i = 0; i < a[l] - m; i++) { vp.push_back(make_pair(l, r)); } return a[l] - m; } int i = 0; for (... |
module LUT1(output O, input I0);
parameter [1:0] INIT = 0;
\$lut #(
.WIDTH(1),
.LUT(INIT)
) _TECHMAP_REPLACE_ (
.A(I0),
.Y(O)
);
endmodule
module LUT2(output O, input I0, I1);
parameter [3:0] INIT = 0;
\$lut #(
.WIDTH(2),
.LUT(INIT)
) _TECHMAP_REPLACE_ (
.A({I1, I0}),
.Y(O... |
#include <bits/stdc++.h> int main() { long long n, k; std::cin >> n >> k; long long c = std::max(n - 2 * k, 0LL); std::cout << n * (n - 1) / 2 - c * (c - 1) / 2 << n ; return 0; } |
#include <bits/stdc++.h> using namespace std; long long n; long long arr[1005]; long long dp[1005][3 * 10000]; long long add(long long a, long long b) { return ((a % 1000000007) + (b % 1000000007)) % 1000000007; } long long f(long long idx, long long sum) { if (idx == n + 1) { 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 la... |
#include <bits/stdc++.h> using namespace std; double eps = 1e-9; const int INF = 1e9 + 7; const int MAXN = int(2e5 + 7); int n, k, b, ans; long long cur = 1, t; int main() { cin >> k >> b >> n >> t; while (cur <= t) { cur = cur * k + b; n--; } cout << max(0, ++n); return 0;... |
/*
* These source files contain a hardware description of a network
* automatically generated by CONNECT (CONfigurable NEtwork Creation Tool).
*
* This product includes a hardware design developed by Carnegie Mellon
* University.
*
* Copyright (c) 2012 by Michael K. Papamichael, Carnegie Mellon University
*
* ... |
// ========== Copyright Header Begin ==========================================
//
// OpenSPARC T1 Processor File: bw_clk_cl_dram_ddr.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 i... |
#include <bits/stdc++.h> using namespace std; #define endl n typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef tuple<int, int, int> tiii; typedef tuple<ll, ll, ll> tlll; const int INF = 100000000; const ll INFINITE = 4500000000000000000; int main(void) { 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... |
module fsm(x, y, clk, reset, state_out);
// Inputs:
input wire x, clk, reset;
// Outputs:
output wire y;
output wire [2:0] state_out;
// Internal representation (state):
reg [2:0] State;
reg [2:0] NextState;
// State Encoding Parameters:
localparam STATE_Initial = 3'b000,
STATE_1 = 3'b001,
STATE_2 = 3'b010... |
#include <bits/stdc++.h> using namespace std; long long x, y, m; long long ans; int main() { cin >> x >> y >> m; if (x >= m || y >= m) { cout << 0; return 0; } if (x <= 0 && y <= 0) { cout << -1; return 0; } if (y < 0) swap(x, y); if (x < 0) { ans += cei... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; if (n <= 3 || n == 5 || n == 7 || n == 11) { cout << -1 << n ; } else { if (n % 2 == 0) { cout << n / 4 << n ; } else { ... |
/**
* 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> #pragma GCC optimize( Ofast , 3, inline ) using namespace std; string s, t; int n; void pairr() { if (cin >> t) { s += t; if (t == pair ) s += < , pairr(), s += , , pairr(), s += > ; } else { cout << Error occurred ; exit(0); } } int main(... |
#include <bits/stdc++.h> using namespace std; int n, k; int odd, even; bool win(int k, int odd, int even) { if (odd * 2 <= k || (even * 2 <= k && (k - even) % 2 == odd % 2)) return false; return true; } int main() { scanf( %d%d , &n, &k); for (int i = 1; i <= n; i++) { int x; ... |
/*
Project: RECON 2017
Author: Jeff Lieu <>
Description: Timer module to support delay function
*/
/////////////////////////////////////////////////////////////////////////////////
// synthesis translate_off
`timescale 1ns / 1ps
// synthesis translate_on
`define MILLISEC_OFFSET 0
`define SECOND_OFFSET... |
//=======================================================
// This code is generated by Terasic System Builder
//=======================================================
module DE1_SOC(
//////////// CLOCK //////////
input CLOCK_50,
input CLOCK2_50,
input CLOCK3_50,
input... |
#include <bits/stdc++.h> using namespace std; long long int n; long long int a[100001]; vector<pair<long long int, long long int> > g[100001]; long long int dis[100001]; long long int rem[100001]; long long int dp[100001]; long long int child[100001]; long long int ct = 1; void simpledfs(long long i... |
//////////////////////////////////////////////////////////////////////
//// ////
//// can_register_asyn_syn.v ////
//// ////
//// ... |
/*
* 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; char bd[1100][1100]; int n, m; int rt[1100][1100]; int down[1100][1100]; int cnt[1100][1100]; int check(int width, int height, int x, int y) { int filled = 0; bool first = true; while (true) { int godown = down[x][y] - height; if (godow... |
//IEEE Floating Point Adder (Single Precision)
//Copyright (C) Jonathan P Dawson 2013
//2013-12-12
module adder(
input_a,
input_b,
input_a_stb,
input_b_stb,
output_z_ack,
clk,
rst,
output_z,
output_z_stb,
input_a_ack,
input_b_ack);... |
/**
* 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 N = 100005; vector<int> e[N]; int n, ans, f[N][2], g[N][2]; void dfs1(int x, int fa) { f[x][0] = 0; f[x][1] = 0; int d = e[x].size() - (fa != 0); for (auto i : e[x]) if (i != fa) { dfs1(i, x); f[x][0] = max(f[x][0], ... |
#include <bits/stdc++.h> using namespace std; typedef long long ll; inline int read(){ int x=0,f=1; char ch=getchar(); while(ch< 0 ||ch> 9 ){ if(ch== - ) f=-1; ch=getchar(); } while(ch>= 0 &&ch<= 9 ){ x=(x<<1)+(x<<3)+(ch^48); c... |
//////////////////////////////////////////////////////////////////////
//// ////
//// eth_rxaddrcheck.v ////
//// ////
//// This file is part of the E... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:66777216 ) using namespace std; const int N = 100000 + 5; int n, k; char s[N]; int su[N]; int a[N]; bool check(int md) { for (int i = 1; i <= (int)(n); ++i) { int s = max(i - md, 1); int f = min(i + md, n); if (a[i] == 1 && s... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; set<long long> a = {1, n}; for (long long d = 2; d <= min((long long)sqrt(n) + 10, n - 1); d++) { if (n % d == 0) { a.insert(d); a.insert(n / d); } } long long ans = -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... |
/*
* 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 ... |
//
// Paul Gao 06/2019
//
//
`include "bsg_noc_links.vh"
`include "bsg_wormhole_router.vh"
module bsg_wormhole_router_test_node_master
#(// Wormhole link parameters
parameter `BSG_INV_PARAM(flit_width_p )
,parameter dims_p = 2
,parameter int cord_markers_pos_p[dims_p:0] = '{5, 4, 0}
,parameter `BSG_INV_PA... |
// megafunction wizard: %FIFO%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: dcfifo
// ============================================================
// File Name: Sdram_RD_FIFO.v
// Megafunction Name(s):
// dcfifo
//
// Simulation Library Files(s):
//
// ==================================================... |
#include <bits/stdc++.h> using namespace std; struct Point { double x, y; Point() {} Point(double a, double b) { x = a, y = b; } }; const double eps = 1e-10; Point operator+(Point A, Point B) { return Point(A.x + B.x, A.y + B.y); } Point operator-(Point A, Point B) { return Point(A.x - B.x, A.y ... |
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2018 by Wilson Snyder.
module t (/*AUTOARG*/
// Inputs
clk
);
input clk;
integer cyc=0;
reg [63:0] crc;
reg [63:0] sum;
// Take CRC data and apply t... |
#include <bits/stdc++.h> using namespace std; bool cc(int x) { for (int i = 2; i * i <= x; i++) if (x % i == 0 && x != 2) return false; return true; } int pow(int i, int j) { int x = 1; while (j--) { x *= i; } return x; } int main() { vector<int> v; int n; cin... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const long long MOD = (long long)1e9 + 7; long long add(long long x, long long y) { x += y; if (x >= MOD) return x - MOD; return x; } long long sub(long long x, long long y) { x... |
#include <bits/stdc++.h> using namespace std; int Set(int N, int pos) { return N |= (1LL << pos); } int Reset(int N, int pos) { return N &= ~(1LL << pos); } bool Check(int N, int pos) { return N & (1LL << pos); } int dx[] = {0, 0, 1, -1, 1, -1, 1, -1}, dy[] = {1, -1, 0, 0, 1, -1, -1, 1}; template <class T> ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 3000 + 50; struct Edge { int to, next; long long w; } edge[maxn * 2]; int k = 1, head[maxn]; void add(int u, int v) { edge[++k].to = v; edge[k].next = head[u]; head[u] = k; } long long n, m, b[maxn], w[maxn], v[maxn], sz[... |
#include <bits/stdc++.h> using namespace std; vector<long long int> a; vector<long long int> b; long long int fa(int l, int r) { long long int ret = 0; for (int i = l; i <= r; ++i) ret |= a[i]; return ret; } long long int fb(int l, int r) { long long int ret = 0; for (int i = l; i <= r; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1000000 + 100, logN = 23; long long read() { long long x = 0, f = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) { x = x * 10 + c - 0 ; ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:256000000 ) using namespace std; const int INF = (int)(1e9 + 1e6); const long long LINF = (long long)(4e18); const double EPS = 1e-9; const long long mod = 1e9 + 7; mt19937 ggen; void solve(); int main() { iostream::sync_with_stdio(false); ... |
//*****************************************************************************
// (c) Copyright 2008-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
// ... |
#include <bits/stdc++.h> using namespace std; inline long long getint() { long long _x = 0, _tmp = 1; char _tc = getchar(); while ((_tc < 0 || _tc > 9 ) && _tc != - ) _tc = getchar(); if (_tc == - ) _tc = getchar(), _tmp = -1; while (_tc >= 0 && _tc <= 9 ) _x *= 10, _x += (_tc - 0 ), _t... |
#include <bits/stdc++.h> #define int long long #define F0R(i, n) for(int i = 0; i < (n); i++) using namespace std; signed main() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); int T; cin >> T; F0R(cas,T) { int N; cin >> N; vector<int> a(N); for(int... |
#include <bits/stdc++.h> using namespace std; const double esp = 0.00000001; const int N = 60; const int PSize = 100; const double PCross = 0.3; const double PMuta = 0.05; int a[200010], t[200010]; int n, T; vector<int> res; bool cmp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); string s; cin >> s; string ans = 0 ; int curr = 0; for (int i = 1; i < n; i++) { if (s[i] == ( ) curr = curr ^ 1; ans += (char)(curr + 0 ); if (s[i] == ) ) curr = curr ^ 1; } ... |
#include <bits/stdc++.h> using namespace std; int main() { string s[1005], ss[1005]; cin >> s[0] >> ss[0]; int n; cin >> n; for (int i = 1; i <= n; i++) cin >> s[i] >> ss[i]; for (int i = 0; i <= n; i++) { if (i == 0) { cout << s[0] << << ss[0] << endl; continue; ... |
`timescale 1ns/1ps
`define prop_delay (0.05)
module AND2 (o, a, b);
output o;
input a, b;
and #(`prop_delay,`prop_delay) (o, a, b);
endmodule
module AND3 (o, a, b, c);
output o;
input a, b, c;
and #(`prop_delay,`prop_delay) (o, a, b, c);
endmodule
module NAND2 (o, a, b);
output o;
input a, b;
nand #(`prop_... |
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2004 by Wilson Snyder.
module t (/*AUTOARG*/
// Inputs
clk
);
input clk;
reg [2:0] index_a;
reg [2:0] index_b;
prover #(4) p4 (/*AUTOINST*/
// Inp... |
#include <bits/stdc++.h> #define ll long long using namespace std; int t; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> t; while (t--) { int n; cin >> n; vector<pair<int, int> > a(n + 1); for (int ... |
// NeoGeo logic definition (simulation only)
// Copyright (C) 2018 Sean Gonsalves
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) an... |
//#############################################################################
//# Purpose: MIO Transmit IO #
//#############################################################################
//# Author: Andreas Olofsson #
... |
#include <bits/stdc++.h> using namespace std; long long int power(long long int a) { long long int pdt = 1, i = 0, t = 19; while (i++ < min(a, t)) pdt *= 2; return pdt; } int main() { long long int n, b, i, j, cnt = 0, k = 0; cin >> n >> b; long long int a[n], c[n]; b = power((b * 8)... |
#include <bits/stdc++.h> inline long long read() { long long x = 0, f = 1; char c = getchar(); for (; c > 9 || c < 0 ; c = getchar()) { if (c == - ) f = -1; } for (; c >= 0 && c <= 9 ; c = getchar()) { x = x * 10 + c - 0 ; } return x * f; } int dp[200005]; int a[8... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: Teske Virtual System
// Engineer: Lucas Teske
//
// Create Date: 20:23:28 07/04/2013
// Design Name: Video LVDS Serializer
// Module Name: video_lvds
// GitHub: https://github.com/racerxdl/LVD... |
#include <bits/stdc++.h> using namespace std; const double Pi = acos(-1.0); inline int cmp(double x, double y = 0, double tol = 1e-8) { return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1; } struct point { double x, y; point(double x = 0, double y = 0) : x(x), y(y) {} point operator+(point q) {... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: ITCR
// Engineer: ADRIAN CERVANTES SEGURA
//
// Create Date: 03.03.2016 01:49:40
// Design Name:
// Module Name: LUT_SHIFT
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
// ... |
#include <bits/stdc++.h> using namespace std; namespace debug { void __(short x) { cout << x; } void __(int x) { cout << x; } void __(long long x) { cout << x; } void __(unsigned long long x) { cout << x; } void __(double x) { cout << x; } void __(long double x) { cout << x; } void __(char x) { cout <... |
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2009 by Iztok Jeras.
module t (/*AUTOARG*/
// Inputs
clk
);
input clk;
`define checkh(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got='h%x exp='... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 100; vector<int> G[MAXN]; map<int, int> cnt; bool vis[MAXN]; int sz; int cN, c[MAXN], b[MAXN]; int dp[MAXN]; void dfs(int u) { vis[u] = true; sz++; for (int i = 0; i < G[u].size(); i++) { int v = G[u][i]; if (... |
/*main function
1)parsing packet header
2)fetch the keys from packet header include l3_protocol ,tos,l4_protocol,source ip,derection ip,source port derection port ,tcp_flag icmp layer_type and icmp code
3)combine keys to prepad
*/
/******************************* the prepad format***********************************... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, min, max, i, t, f = 0; cin >> n >> m; cin >> min; max = min; for (i = 1; i < n; i++) { cin >> t; if (t > max) max = t; else if (t < min) min = t; } if (2 * min > max) max = 2 * min; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int a[m]; for (int i = 0; i < m; i++) { cin >> a[i]; if (a[i] > n - i) { cout << -1 << endl; return 0; } } long long suf_sum[m + 1]; suf_sum[m] = 0; for (int i = m - ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; map<int, int> nrs; for (int i = 0; i < n; i++) { int x; cin >> x; nrs[x]++; } int max_times = nrs.begin()->second; for (auto it : nrs) max_times = max(it.second, max_times); if (max_times > ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; string s; cin >> s; int left0 = 0; for (int i = 0; i < n; i++) { if (s[i] == 0 ) { left0 = i + 1; } else { break; } ... |
#include <bits/stdc++.h> using namespace std; const int N = 1000 + 2; double x[4], y[4], r[4]; double dx, dy; double Fun(double dx, double dy) { double ap[4]; for (int i = 0; i < 3; i++) { ap[i] = sqrt(((x[i] - dx) * (x[i] - dx)) + ((y[i] - dy) * (y[i] - dy))) / r[i]; } double ... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 19:47:01 05/24/2016
// Design Name:
// Module Name: Contador_AD
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
/... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; const int INF = 1e9; const long long mod = 1e9 + 7; bool dp[105][55][2][2][205]; string s; int n, sz, realans; int offset(int x) { return x + 100; } bool f(int idx, int sisa, bool flip, bool arah, int ans) { if (idx == sz + 1) { ... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; long long int fastPow(long long int x, long long int y) { long long int p = mod; long long int res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } retur... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int a[N], n, ans[N], b[N]; int main() { scanf( %d , &n); if (n == 1) { printf( 1 n ); return 0; } for (int i = 1; i <= n; i++) scanf( %d , &a[i]); for (int i = 1; i <= n; i++) { b[0] = 0; int to = (... |
`ifdef __ICARUS__
`define SUPPORT_REAL_MODULUS_IN_IVTEST
`endif
module test();
function real pre_inc(input real x);
begin
++x;
pre_inc = x;
end
endfunction
function real pre_dec(input real x);
begin
--x;
pre_dec = x;
end
endfunction
function real post_inc(input real x);
begin
x++;
post_inc = x;
end
en... |
#include <bits/stdc++.h> using namespace std; const long double EPS = 1e-8; const long double PI = 3.1415926535897932384626433832795; const long double E = 2.7182818284; const int INF = 1000000000; const int inf = 100000; int main(void) { int n, m, i, j; char c; scanf( %d%d , &n, &m); char... |
// 32-bit adder
// Using Carry Lookahead adders
module adder
(
input wire [31:0] op1,
input wire [31:0] op2,
input wire cin,
output wire [31:0] sum,
output wire carry,
output wire v_flag
);
wire[6:0] cout;
wire... |
#include <bits/stdc++.h> using namespace std; template <class T> inline T pow2(T a) { return a * a; } template <class T> inline bool mineq(T a, T b) { if (a > b) { a = b; return true; } return false; } void print(long long a) { string str; while (a) { str.push_b... |
#include <bits/stdc++.h> using namespace std; long long x, off = 10; vector<long long> vec[15]; inline long long mul(long long a, long long b) { bool neg = false; long long res = 0; if (b < 0) { neg = true; b = -b; } while (b) { if (b & 1) res = (res + a) % off; a = (... |
#include <bits/stdc++.h> using namespace std; const int NMax = 101000; int N; vector<pair<int, int> > A, B, C, D; bool cmp1(pair<int, int> a, pair<int, int> b) { if (a.first < b.first) return 1; if (a.first > b.first) return 0; if (a.second < b.second) return 1; return 0; } bool cmp2(pair<... |
#include <bits/stdc++.h> using ul = std::uint32_t; using li = std::int32_t; using ull = std::uint64_t; using ll = std::int64_t; std::vector<ul> v; std::string s; int main() { std::getline(std::cin, s); std::stringstream ss(s); while (std::getline(ss, s, , )) { std::stringstream ss(s); ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, a[60], b[60]; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; cin >> m; for (int i = 0; i < m; i++) cin >> b[i]; int BG = -1; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (!(b[j] % a[i... |
#include <bits/stdc++.h> using namespace std; const int N = 25; const int mo = 1000000007; const int inf = (int)1e9; inline int IN() { char ch; (ch = getchar()); int f = 0, x = 0; for (; ((ch) == n || (ch) == r || (ch) == t || (ch) == ); (ch = 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 la... |
#include <bits/stdc++.h> using namespace std; constexpr int power(int x, int e) { return e ? x * power(x, e - 1) : 1; } template <typename T> void transpose(std::vector<std::vector<T>>& M) { auto tmp = M; M.resize(tmp[0].size()); for (auto& row : M) row.resize(tmp.size()); for (int i = 0; i < (i... |
module decode_tb;
//wires
reg clk;
reg rst;
reg wave_instr_valid;
reg[5:0] wave_wfid;
reg[8:0] wave_sgpr_base;
reg[9:0] wave_vgpr_base;
reg[15:0] wave_lds_base;
reg[31:0] wave_instr_pc, wave_instr;
wire issue_wf_halt, issue_valid, issue_vcc_wr, issue_vcc_rd, issue_scc_wr,
issue_scc_rd, issue_exec_rd, i... |
#include <bits/stdc++.h> using namespace std; template <class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { os << { << p.first << , << p.second << } ; return os; } template <class T> ostream& operator<<(ostream& os, const vector<T>& p) { os << [ ; int i = 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { int t, a1, a2, b1, b2, max1, max2; cin >> t; while (t > 0) { cin >> a1 >> b1; cin >> a2 >> b2; max1 = max(a1, b1); max2 = max(a2, b2); if (max1 == max2) { int min1, min2; min1 = min(a1, b1); ... |
/**
* 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 t, n, m; long long r, ans[800005]; stack<int> s; vector<pair<char, vector<int>>> v; char x[800005 * 6]; void dfs(int a) { if (v[a].first == _ ) return; vector<int> tv; for (int i : v[a].second) { dfs(i); if (v[a].first == v[i].firs... |
#include <bits/stdc++.h> using namespace std; int count_on(int mask) { int ans = 0; while (mask) { if (mask & 1) { ans++; } mask >>= 1; } return ans; } int dp[1 << 20]; string bin(int mask) { string str = ; while (mask) { if (mask & 1) { str +=... |
#include <bits/stdc++.h> using namespace std; const int NMAX = 210, INF = 0x3f3f3f3f, VMAX = 20010; int N, A[NMAX], Source, Sink, Flow[NMAX][NMAX], Cap[NMAX][NMAX], Father[NMAX], Even, Odd; bool Used[NMAX], Prime[VMAX]; vector<int> G[NMAX], FlowG[NMAX], CurrentTable; vector<vector<int> > Ans; bool B... |
// Check that all types of constant expression are supported for attributes
module test;
localparam [7:0] x = 1;
// Binary operators
(* attr = x + x *) reg attr0;
(* attr = x - x *) reg attr1;
(* attr = x * x *) reg attr2;
(* attr = x / x *) reg attr3;
(* attr = x % x *) reg attr4;
(* attr =... |
#include <bits/stdc++.h> using namespace std; int f[55], s[55]; long double p[55]; long double dp[55][5005]; bool vis[55][5005]; int main() { int n, r; scanf( %d%d , &n, &r); for (int i = 1; i <= n; i++) { scanf( %d%d%Lf , &f[i], &s[i], &p[i]); p[i] /= 100; } long double lo =... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.