text stringlengths 59 71.4k |
|---|
//-----------------------------------------------------------------
// AltOR32
// Alternative Lightweight OpenRisc
// V2.0
// Ultra-Embedded.com
// Copyright 2011 - 2013
//
// Email:
//
// ... |
#include <bits/stdc++.h> using namespace std; int main() { vector<int> v(6); for (int i = 0; i < 6; ++i) cin >> v[i]; int n; cin >> n; vector<pair<int, int>> a; int num; for (int i = 0; i < n; ++i) { cin >> num; for (int j = 0; j < 6; ++j) { a.push_back({num - v[j], 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 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; double n, r; signed main() { scanf( %lf%lf , &n, &r); printf( %.10f n , 2.0 * n * 0.5 * r * r * sin(acos(-1.0) / (2.0 * n)) / sin(acos(-1.0) - (acos(-1.0) / (2.0 * n)) * 3) * sin(2 * acos(-1.0) / (2.0 * n)));... |
/**
*@file tai_ecc.v
*@brief Automatically detect error of TAI counter
*@author LUAN Yuezhen
*@date Origin 2016.11.17
*@tab Tab size = 4 spaces
*/
module tai_ecc(
input clk,
input rst_n,
input pps,
input [63 : 0] tai_sec_1,
input [63 : 0] tai_sec_2,
input [63 : 0] tai_sec_3,
output [63 : 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; bool si[1000007]; int x0 = 1000007; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int x2; cin >> x2; si[0] = si[1] = false; for (int i = 2; i < 1000007; i++) { si[i] = true; } for (int i = 2; i < 10... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-10; const long long N = 2e5 + 10; ; long long n, p[N], t[N], a[N], b[N], Ma[N], Mi[N], T; long long check(double m) { double M = 0.0; for (long long i = 1, j = 1; i <= n; i++) { while (j <= n && p[b[j]] < p[b[i]]) M = ... |
// megafunction wizard: %ROM: 1-PORT%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: altsyncram
// ============================================================
// File Name: diploma_new.v
// Megafunction Name(s):
// altsyncram
//
// Simulation Library Files(s):
// altera_mf
// ============================... |
#include <bits/stdc++.h> using namespace std; const int N = 5000 + 10; const int BASE = 1e9 + 7; int n; int memo[N][N], _memo[N][N]; string s; int _solve(int pos_1, int pos_2) { if (pos_1 > n || pos_2 > n) return 0; if (_memo[pos_1][pos_2] != -1) return _memo[pos_1][pos_2]; int cur = 0; if... |
`timescale 1 ns / 1 ps
`include "Speck_Block_Cipher_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
... |
// generated by gen_VerilogEHR.py using VerilogEHR.mako
// Copyright (c) 2019 Massachusetts Institute of Technology
// 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... |
`timescale 1ns/10ps
/**
* `timescale time_unit base / precision base
*
* -Specifies the time units and precision for delays:
* -time_unit is the amount of time a delay of 1 represents.
* The time unit must be 1 10 or 100
* -base is the time base for each unit, ranging from seconds
* to femtoseconds, and must be:... |
#include <bits/stdc++.h> #define int long long #define INF (1e15 + 7) #define pii pair<int, int> using namespace std; struct Node { int x, y; Node(int _x = 0, int _y = 0) : x(_x), y(_y) {} bool operator<(const Node &u)const { if (x < u.x) return true; if (x > u.x) r... |
module LCD_TEST ( // Host Side
iCLK,iRST_N,
d0,d1,d2,d3,d4,d5,
// LCD Side
LCD_DATA,LCD_RW,LCD_EN,LCD_RS );
// Host Side
input iCLK,iRST_N;
// Data test
input [15:0] d0,d1,d2,d3,d4,d5;
// LCD Side
output [7:0] LCD_DATA;
output LCD_RW,LCD_EN,LCD_RS;
// Internal Wires/Registers
reg [... |
module FramesyncFSM(clk,rst,DataIn,DataOut,DataOutEn,State,inter,S);
input wire clk,rst,DataIn;
output reg DataOut,DataOutEn;
output reg [1:0]State;
output wire S;
output reg inter;
reg [1:0]MissCount;
reg [1:0]RecCount;
reg [7:0]count;
reg CountEn;
Probe u0(DataIn,S,clk);
//Count256 u1(clk,CountEn,inter);
... |
// ========== Copyright Header Begin ==========================================
//
// OpenSPARC T1 Processor File: cpx_buf_pm_even.v
// Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
//
// The above named program is free software; you can redistribute it a... |
#include <bits/stdc++.h> using namespace std; int readint() { char c; while (c = getchar(), (c < 0 || c > 9 ) && c != - ) ; bool flag = (c == - ); if (flag) c = getchar(); int x = 0; while (c >= 0 && c <= 9 ) { x = x * 10 + c - 48; c = getchar(); } return fl... |
#include <iostream> #include <vector> #include <algorithm> #include <map> using namespace std; const int64_t INF = 1e15; struct Dinic { struct Edge { int v; int64_t f, c; Edge(int _v = 0, int64_t _f = 0, int64_t _c = 0): v(_v), f(_f), c(_c) {}; }; int n; vector<int> idx, ... |
#include <bits/stdc++.h> using namespace std; int main() { int t, n, cnt[2000000]; scanf( %d , &n); for (int i = 0; i < 2000000; ++i) cnt[i] = 0; for (int i = 0; i < n; ++i) { scanf( %d , &t); cnt[t]++; } long long ans = 0; for (int i = 0; i < 2000000 - 1; ++i) { cnt[i ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; vector<int> AdjList[maxn]; bool vis[maxn]; int child[maxn]; char ans[maxn]; int n; void dfs(int s, int p = -1) { child[s] = 1; for (int u : AdjList[s]) { if (vis[u]) continue; if (u == p) continue; dfs(u, s... |
`timescale 1 ns / 1 ps
`include "d_axi_pdm_v1_2_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 S_AXI_MAX_BURST_LENGTH 1
`define S_A... |
/*
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a[5], sum = 0; for (int i = 0; i < 5; i++) { cin >> a[i]; sum += a[i]; } n = sum / 5; if (sum == 0) cout << -1; else if (n * 5 == sum) cout << n; else cout << -1; return 0; } |
#include <bits/stdc++.h> using namespace std; int n, m, n1, m1; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> n >> m; n1 = n, m1 = m; if ((n1 == m1 + 1 and !(n1 + m1 % 2)) or n1 > m1 + 1 or m1 / 2 + (m1 % 2) > n1 + 1 or (m1 / 2 + (m1 % 2)) == n1 + 1 and !(m1... |
// megafunction wizard: %ROM: 1-PORT%VBB%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: altsyncram
// ============================================================
// File Name: ninja_life.v
// Megafunction Name(s):
// altsyncram
//
// Simulation Library Files(s):
// altera_mf
// =========================... |
// -----------------------------------------------------------------------
//
// Copyright 2004,2007,2008 Tommy Thorn - All Rights Reserved
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foun... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; const long long MOD = 1e9 + 7; const int inf = 1e9; const int N = 3e5 + 5; bool flag; template <typename T> istream& operator>>(istream& is, vector<T>& v) { for (auto& i : v) is >> i; return is; } template <typename T>... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int arr[n], brr[m], check[n], indexer = 0; for (int i = 0; i < n; i++) cin >> arr[i], check[i] = -2; for (int i = 0; i < m; i++) { cin >> brr[i]; for (int j = 0; j < n; j++) if (brr[i] == arr[... |
#include <bits/stdc++.h> using namespace std; int N, M, i, X, A[100005]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N >> M; for (i = 0; i < 2 * M; i++) { cin >> X; A[X]++; } if (N == M) { for (i = 1; 1; i++) { if (A[i] != 2) { ... |
// ********************************************************************/
// Actel Corporation Proprietary and Confidential
// Copyright 2009 Actel Corporation. All rights reserved.
//
// ANY USE OR REDISTRIBUTION IN PART OR IN WHOLE MUST BE HANDLED IN
// ACCORDANCE WITH THE ACTEL LICENSE AGREEMENT AND MUST BE APPROV... |
//////////////////////////////////////////////////////////////////////
//// ////
//// spi_clgen.v ////
//// ////
//// This file is part of the SPI 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 la... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; int t; long long n; vector<int> v; long long cnt[30]; long long pos[30]; long long fact[21]; void init() { for (int i = 0; i < int(30); i++) cnt[i] = pos[i] = 0; v.clear(); } int main() { cin.tie(0); ios_ba... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
#include <bits/stdc++.h> using namespace std; int mymax(int x) { int max = 0; while (x) { int s = x % 10; if (s > max) max = s; x /= 10; } return max; } int zh(int x, int n) { int s = 0, p = 1; while (x) { s += x % 10 * p; x /= 10; p *= n; } re... |
#include <bits/stdc++.h> using namespace std; vector<vector<pair<long long, long long>>> adj; vector<long long> d; long long n; vector<bool> mark; vector<long long> trains; void dijktras(long long s) { d[s] = 0; priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, ... |
`timescale 1 ns / 1 ps
module hapara_bram_dma_switch_v1_0 #
(
// Users to add parameters here
parameter integer BRAM_ADDR_WIDTH = 14,
// User parameters ends
// Do not modify the parameters beyond this line
// Parameters of Axi Slave Bus Interface S00_AXI
parameter integer C_S00_AXI_DATA_WIDTH =... |
/////////////////////////////////////////////////////////////////////
//// ////
//// WISHBONE rev.B2 compliant I2C Master byte-controller ////
//// ////
//// ... |
//--------------------------------------------------------------------------------
//
// Copyright (C) 2013 Iztok Jeras
//
// 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 versio... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 4e5 + 5; int n, I; int a[MAXN], num[MAXN]; int read() { int s = 1, x = 0; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) s = -1; ch = getchar(); } while (isdigit(ch)) { x = 10 * x + ch - 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... |
// bsg_nonsynth_dpi_to_fifo: A FIFO Interface for transmitting FIFO
// data from C/C++ into simulation via DPI
//
// Parameters:
//
// width_p: is the bit-width of the FIFO interface. Must be a power
// of 2 and divisible by 8, i.e. a ctype.
//
// debug_p: is the intial value to set on debug_o and to contro... |
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2012 by Jeremy Bennett.
// SPDX-License-Identifier: CC0-1.0
// see bug 591
package pkg1;
parameter PARAM2 = 16;
parameter PARAM3 = 16;
endpackage : pkg1
package pkg10;
imp... |
/////////////////////////////////////////////////////////////////////
//// Author: Zhangfeifei ////
//// ////
//// Advance Test Technology Laboratory, ////
//// Institute of Computing Technol... |
/**
* 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 MX = (int)2e5 + 10; const int mod = (int)1e9 + 7; bool check(string& t) { bool ok = true; int n = t.size(); for (int j = 0; j < n / 2; ++j) { ok &= t[j] == t[n - j - 1]; } return ok; } int main(int argc, char* argv[]) { ci... |
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2003 by Wilson Snyder.
module t (/*AUTOARG*/
// Inputs
clk
);
input clk;
// verilator lint_off GENCLK
reg [7:0] cyc; initial cyc=0;
reg [7:0] padd;
reg ... |
#include <bits/stdc++.h> using namespace std; int N, A[100001], BIT[100001], res[100001]; vector<int> v; map<int, int> m; int main() { scanf( %d , &N); for (int i = 1; i <= N; ++i) scanf( %d , &A[i]), v.push_back(A[i]); sort(v.begin(), v.end()); v.resize(unique(v.begin(), v.end()) - v.begin())... |
#include <bits/stdc++.h> inline char gc() { static const int L = 23333; static char sxd[L], *sss = sxd, *ttt = sxd; if (sss == ttt) { ttt = (sss = sxd) + fread(sxd, 1, L, stdin); if (sss == ttt) { return EOF; } } return *sss++; } template <class T> inline bool read(... |
#include <bits/stdc++.h> const int MAXN = 1000 + 5; char str[MAXN]; int n; inline std::vector<int> query(std::vector<int> d) { std::vector<int> ans; printf( ? ); for (auto x : d) printf( %d , x); puts( ); std::fflush(stdout); scanf( %s , str + 1); for (int i = 1; i <= n; ++i) ans.... |
// -----------------------------------------------------------------------
//
// Copyright 2004 Tommy Thorn - All Rights Reserved
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation,... |
/*
* 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 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) Copyright 1995 - 2010 Xilinx, Inc. All rights reserved. *
* *
* This file contains confidential and proprietary information ... |
#include <bits/stdc++.h> using namespace std; int cnt[10]; int main() { int n; while (scanf( %d , &n) != EOF) { int sum = 0; memset(cnt, 0, sizeof(cnt)); for (int i = 0; i < n; i++) { int j; scanf( %d , &j); cnt[j]++; sum += j; } int ans = -1; ... |
#include <bits/stdc++.h> using namespace std; vector<string> ans; string f = 1 ; bool sort2(string &a, string &b) { if (a.size() == b.size()) { return a < b; } return a.size() < b.size(); } void calc(string s) { if (s.size() >= 11) { return; } ans.push_back(s); s += ... |
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved.
// --------------------------------------------------------------------------------
// Tool Version: Vivado v.2016.4 (win64) Build Wed Dec 14 22:35:39 MST 2016
// Date : Tue May 30 22:39:44 2017
// Host : GILAMONSTER running 64-bit major release (... |
/**
* 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... |
// hps_design_SMP_HPS.v
// This file was auto-generated from altera_hps_hw.tcl. If you edit it your changes
// will probably be lost.
//
// Generated using ACDS version 15.0 145
`timescale 1 ps / 1 ps
module hps_design_SMP_HPS #(
parameter F2S_Width = 0,
parameter S2F_Width = 0
) (
output wire h2f_rst... |
#include <bits/stdc++.h> using namespace std; int main() { int n; vector<int> g; while (cin >> n) { int xi, xf; xi = -1; xf = -1; bool init = false; g = vector<int>(n); for (int i = 0; i < n; i++) { cin >> g[i]; if (init == false && g[i] == 1) { ... |
// (C) 2001-2016 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 any of the foregoing (including device programming or simulation
// files), and any associated docum... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 205; const long long modulo = 1000000007; struct point { long long x, y; }; point operator-(point A, point B) { point C; C.x = A.x - B.x; C.y = A.y - B.y; return C; } bool operator==(point A, point B) { return (A.x == B.x... |
#include <bits/stdc++.h> using namespace std; void task(); int main() { srand(time(0)); task(); return 0; } const int INF = 0x3f3f3f3f; const int N = 1e5 + 10; const int M = 1e5 + 10; int n, x; int l[N]; int r[N]; long long int dp[2 * N + 10]; vector<int> v; void task() { scanf... |
#include <bits/stdc++.h> using namespace std; int n, m; int c[1010100], cc[1010100]; int lowbit(int x) { return x & (-x); } void upd(int v, int idx, int a[]) { while (idx <= n) { a[idx] += v; idx += lowbit(idx); } } int qu(int idx, int a[]) { int sum = 0; if (idx == 0) 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... |
module ram_1p (
clk_i,
rst_ni,
req_i,
we_i,
be_i,
addr_i,
wdata_i,
rvalid_o,
rdata_o
);
parameter signed [31:0] Depth = 128;
input clk_i;
input rst_ni;
input req_i;
input we_i;
input [3:0] be_i;
input [31:0] addr_i;
input [31:0] wdata_i;
output reg rvalid_o;
output reg [31:0] rdata_o;
parameter sign... |
#include <bits/stdc++.h> using namespace std; long long int powr(long long a, long long b) { if (b == 0) { return 1; } if (b % 2 == 0) { return powr(((a % 1000000007) * (a % 1000000007)) % 1000000007, b / 2); } else { if (b == 1) { return a; } else { return (a... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
//======================================================================
//
// sha256_k_constants.v
// --------------------
// The table K with constants in the SHA-256 hash function.
//
//
// Author: Joachim Strombergson
// Copyright (c) 2013, Secworks Sweden AB
// All rights reserved.
//
// Redistribution and use in ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1005; bool vis[maxn]; int n, m, k, p[maxn], a[maxn]; char s[maxn][maxn]; void func(int x, int y) { --m; if (x <= y) { s[m][x] = s[m][y] = / ; } else { s[m][x] = s[m][y] = ; } } int main() { scanf( %d , &n... |
#include <bits/stdc++.h> using namespace std; int N; vector<int> Q[100010]; long long F[100010][2]; bool vis[100010]; void dfs(int u) { if (vis[u]) return; vis[u] = true, F[u][1] = 1LL, F[u][0] = 0LL; if (!Q[u].size()) return; long long d0, d1; for (int i = 0; i < Q[u].size(); i++) { ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; template <class c> struct rge { c b, e; }; template <class c> rge<c> range(c i, c j) { return rge<c>{i, j}; } template <class c> auto dud(c* x) -> decltype(cerr << *x, 0); template <class c> char dud(...); struct ... |
module registerfile(
Q1,Q2.DI,clk,reset written,AD,A1,A2
);
output [31:0] Q1,Q2;
input [31:0] DI;
input clk,reset,written;
input [4:0] AD,A1,A2;
wire [31:0] decoderout,regen;
wire [31:0] q[31:0];
decoder dec_0(decoderout,AD);
assign regen[0] = decoderout[0]& written;
assign reg... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:268435456 ) using namespace std; template <typename T> inline T abs(T a) { return ((a < 0) ? -a : a); } template <typename T> inline T sqr(T a) { return a * a; } template <class T> T gcd(T a, T b) { return a ? gcd(b % a, a) : b; ... |
//
// 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; int cf[45], nc[45]; vector<int> ppf[45]; bool canadd(int i, int m) { for (int p : ppf[m]) { if (nc[p] && cf[p] != i % p) return false; } return true; } void add(int i, int m) { for (int p : ppf[m]) { if (nc[p] == 0) cf[p] = i % p; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); string s; cin >> s; int br = 0; for (int i = 0; i < s.size() / 2; i++) { if (s[i] == s[s.size() - i - 1]) continue; br++; } if (br >= 2 || br == 0) { if (s.size() % 2 == 1 && br == 0... |
#include <bits/stdc++.h> using namespace std; const long long INF = LLONG_MAX / 2; int extractMin(set<int> &mySet) { set<int>::iterator it = mySet.begin(); int ans = *(it); mySet.erase(it); return ans; } int search(set<int> &mySet, int index) { set<int>::iterator it = mySet.lower_bound(ind... |
// $Id: c_fifo_tracker.v 5188 2012-08-30 00:31:31Z dub $
/*
Copyright (c) 2007-2012, 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:
Redistributio... |
/**
* 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; char types[11]; bool possible[1005][12][11]; int m; int pre[1005][12][11][3]; int main() { scanf( %s , types); scanf( %d , &m); for (int i = 0; i < 11; ++i) for (int d = 0; d <= 10; ++d) possible[0][i][d] = 0; possible[0][0][0] = 1; int... |
/*
* Author : Tom Stanway-Mayers
* Description : Pre-Fetch Unit
* Version: :
* License : Apache License Version 2.0, January 2004
* License URL : http://www.apache.org/licenses/
*/
`include "riscv_defs.v"
module merlin_pfu32ic
#(
parameter C_FIFO_PASSTHROUGH = 0,
... |
// (c) Copyright 1995-2014 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 ... |
/*
Distributed under the MIT license.
Copyright (c) 2017 Dave McCoy ()
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, mo... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, m; cin >> n >> m; long long mod = 1; int k = 0; while (k < n) { if (mod > m) { break; } mod *= 2; k++; } cout << m % mod << endl; } |
/**
* 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; std::vector<long long> v[100009]; long long vis[100009], c = 0; void dfs(long long x) { c++; vis[x] = 1; for (auto i : v[x]) if (!vis[i]) dfs(i); } signed main() { ios_base::sync_with_stdio(false), cin.tie(NULL); long long i, n, m, s = ... |
//Legal Notice: (C)2013 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 associate... |
#include <bits/stdc++.h> using namespace std; int n, q, a[200010]; struct node { int l, r, color; node(int ll = 0, int rr = 0, int cc = 0) : l(ll), r(rr), color(cc) {} }; node p[200010]; vector<int> vec[200010]; bool cmp(node a, node b) { if (a.l != b.l) return a.l < b.l; return a.r > b.r;... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5; char s[maxn]; int a[maxn]; int n, l, r, i, x; int main() { scanf( %s , s + 1); n = strlen(s + 1); for (i = 1; i <= n; i++) a[i] = s[i] - 0 ; l = 1; r = n; if (a[l] != a[r]) { a[l]--; a[l + 1] += 10; ... |
/*
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> using namespace std; const int N = 200009; int a[N], pos[N]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) { int x; cin >> x; pos[x] = i; } for (int i = 1; i <= n; i++) a[i] = pos[a[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 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... |
/**
* 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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.