text stringlengths 59 71.4k |
|---|
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: Xilinx Inc.
// Engineer: Parimal Patel
// Create Date: 06/21/2016 09:22:41 AM
// Module Name: PdmDes
// Project Name: PYNQ
/////////////////////////////////////////////////////////////////////////////////... |
#include <bits/stdc++.h> using namespace std; struct S { int a, b; S() {} S(int _a, int _b) { a = _a; b = _b; } const bool operator<(const S &o) const { return a < o.a; } }; string exm; inline void exf(void) { cout << exm << n ; exit(0); } template <typename T> ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { string b; cin >> b; if (b.length() < 4) { cout << b << n ; continue; } cout << b[0]; for (int i = 1; i < b.length(); i += 2) { cout << b[i]; } ... |
#include <bits/stdc++.h> using namespace std; inline int read() { int a = 0; char c = getchar(); bool f = 0; while (!isdigit(c)) { if (c == - ) f = 1; c = getchar(); } while (isdigit(c)) { a = (a << 3) + (a << 1) + (c ^ 0 ); c = getchar(); } return f ? -a : ... |
#include <bits/stdc++.h> using namespace std; int n, k, tot, arr[105], sum[100050][105], a[100050], s[105]; bool Solved(int x, int y) { for (int i = 1; i <= tot; ++i) if (sum[y][i] - sum[x - 1][i] < s[i]) return false; return true; } int main() { long long ans; scanf( %d%d , &n, &k); ... |
#include <bits/stdc++.h> using namespace std; inline int BITS(long long __a) { short int __c = 0; __a <<= 1; while (__a) __c += ((__a >>= 1) & 1); return __c; } inline bool prime(int n) { for (int i = 3; i * i <= n; i += 2) if (n % i == 0) return false; return true; } set<int> ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; vector<int> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } int lo = 0, hi = m; while (lo < hi) { int mid... |
/**
* 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; pair<int, int> arr[100005]; vector<int> v1[100005]; int visited[100005]; stack<int> s; int n, m; set<int> se[100005]; void dfs(int node) { int i; visited[node] = 1; int n = v1[node].size(); for (i = 0; i < n; i++) { if (visited[v1[node]... |
//Legal Notice: (C)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 do... |
#include <bits/stdc++.h> using namespace std; struct people { int a, d, id; bool operator<(people other) const { if (a != other.a) return a > other.a; return id < other.id; } }; people s[111]; int n; int main() { int i, j, ans = 0; scanf( %d , &n); for (i = 1; i <= n; ++i... |
#include <bits/stdc++.h> using namespace std; long long int MOD = 1e9 + 7; long long int INF = 1e18; long long int sub(long long int a, long long int b, long long int p = MOD) { return ((a % p) - (b % p) + p) % p; } long long int mult(long long int a, long long int b, long long int p = MOD) { return... |
// megafunction wizard: %ROM: 1-PORT%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: altsyncram
// ============================================================
// File Name: small_rom.v
// Megafunction Name(s):
// altsyncram
//
// Simulation Library Files(s):
// altera_mf
// ==============================... |
#include <bits/stdc++.h> using namespace std; int T, n; char Ls[400000 + 5], ps[400000 + 5]; long long ans; 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 ... |
// ==============================================================
// File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC
// Version: 2018.2
// Copyright (C) 1986-2018 Xilinx, Inc. All Rights Reserved.
//
// ==============================================================
`timescale 1 ns / 1... |
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { int j = i - x; int k = i + y; if (j < 0) j = 0; if (k > n - 1) k = n - 1; int min = INT_MAX, ... |
`timescale 1 ns / 1 ps
module averager_tb();
parameter WIDTH = 8;
reg avg_on;
reg clk;
reg [13:0]din;
reg [WIDTH-1:0]period;
reg restart;
reg [WIDTH-1:0]threshold;
reg [32-WIDTH-1:0]n_avg_min;
reg tvalid;
wire [3:0]wen;
wire [31:0]dout;
wire [32-WIDTH-1:0] n_avg;
wire ready;
wire avg_o... |
#include <bits/stdc++.h> using namespace std; int main() { long long int a, s; scanf( %lld , &a); a = a - 2; if (a % 3 == 0) { printf( 1 2 %lld , a - 1); } else printf( 1 1 %lld , a); return 0; } |
#include <bits/stdc++.h> using namespace std; const int Maxn = 200005; const int Maxd = 10; int bits[1 << Maxd]; int t; char str[Maxn]; int slen; int main() { for (int i = 1; i < 1 << Maxd; i++) bits[i] = 1 + bits[i - (i & -i)]; scanf( %d , &t); while (t--) { scanf( %s , str); sl... |
#include <bits/stdc++.h> using namespace std; int n, m; int check(vector<long long> &a, long long q) { multiset<long long> s; for (int j = 0; j < n; ++j) { if (q + a[j] >= 0) { q += a[j]; s.insert(a[j]); } else if (a[j] > (*s.begin())) { q += (a[j] - (*s.begin())); ... |
//////////////////////////////////////////////////////////////////////
//// ////
//// OR1200's register file inside CPU ////
//// ////
//// This file is part of the OpenR... |
#include <bits/stdc++.h> using namespace std; int main() { string s1, s2, t = ; cin >> s1 >> s2; int n = s1.size(), c = 0, c1 = 0, c2 = 0; for (int i = 0; i < n; i++) { if (s1[i] != s2[i]) c++; } if (c % 2 != 0) cout << impossible << endl; else { c1 = c2 = c / 2; ... |
#include <bits/stdc++.h> using namespace std; bool isNonDegenerateTriangle(int a, int b, int c) { return (a + b > c && b + c > a && c + a > b); } bool isDegenerateTriangle(int a, int b, int c) { return (a + b == c || b + c == a || c + a == b); } int main() { int n; cin >> n; long long in... |
#include <bits/stdc++.h> using namespace std; bool check(string s) { for (int i = 0; i < s.size() / 2; i++) if (s[i] != s[s.size() - 1 - i]) return 0; return 1; } int main() { int jopa; string s; cin >> s; int p = 0; char a = s[0]; for (int i = 0; i < s.size(); i++) i... |
// ==============================================================
// File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC
// Version: 2014.4
// Copyright (C) 2014 Xilinx Inc. All rights reserved.
//
// ==============================================================
`timescale 1 ns / 1 ps
m... |
(************************************************************************)
(* v * The Coq Proof Assistant / The Coq Development Team *)
(* <O___,, * INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2010 *)
(* \VV/ **************************************************************)
(* // * Th... |
#include <bits/stdc++.h> using namespace std; int a[301][301], h, w, dp[301][301]; int used[601][601]; int dx[] = {0, 1, -1, 0, 0, 1, -1, 1, -1}; int dy[] = {0, 0, 0, 1, -1, 1, 1, -1, -1}; int read() { int x; scanf( %d , &x); return x; } bool check(int x, int y) { if (x >= 1 && x <= h &&... |
// ***************************************************************************
// ***************************************************************************
// Copyright 2014 - 2017 (c) Analog Devices, Inc. All rights reserved.
//
// In this HDL repository, there are many different and unique modules, consisting
// of... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 7; const int MOD = 1e9 + 7; const int MAXN = 1e6 + 3; const double EPS = (1e-7); int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; } long long gcd(long long a, long long b) { if (b == 0) return a; ... |
#include <bits/stdc++.h> using namespace std; void work(); int main() { work(); return 0; } char S[222222]; char T[222222]; int t[256][256]; void work() { int n; while (scanf( %d , &n) == 1) { memset(t, 0, sizeof(t)); int ans = 0; scanf( %s%s , S + 1, T + 1); for ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } sort(a.begin(), a.end()); int curr_len = 0; int l = 0, r = a.size() - 1; while (l <= r) { if (a[l] - 1 < int(1e6) - a[r]) { ... |
#include <bits/stdc++.h> using namespace std; mt19937 gen(chrono::system_clock::now().time_since_epoch().count()); const int M = 3e5 + 7; const int N = 1e6 + 7; int n, q, l, r, t[N * 4], ans[N], k, x, tn = 1; map<int, vector<int> > p; map<int, vector<pair<int, int> > > otr; map<int, vector<pair<int, int... |
#include <bits/stdc++.h> using namespace std; using vint = vector<int>; using pint = pair<int, int>; using vpint = vector<pint>; template <typename A, typename B> inline void chmin(A& a, B b) { if (a > b) a = b; } template <typename A, typename B> inline void chmax(A& a, B b) { if (a < b) a = ... |
#include <bits/stdc++.h> using namespace std; int t; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> t; while (t--) { int m; int n; cin >> m >> n; vector<int> a[500]; vector<int> b[500]; for (int i = 0; i < m; i++) { for (int j = 0; j < n; ... |
/*
* Copyright (c) 2000 Stephen Williams ()
*
* 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)
* ... |
/*
* 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; long long t, t0, t2, x, x2; void cmp(long double &temp, long long &o, long long &o2, long long y, long long y2) { if (y2 > x2) return; long double newTemp = (1.0 * t * y + t2 * y2) / (y + y2); if (newTemp < t0) return; if (newTemp > temp + 1... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 02.03.2016 13:08:19
// Design Name:
// Module Name: d2str
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revisio... |
#include <bits/stdc++.h> using namespace std; bool prime[100001]; bool ispoweroftwo(long long int x) { return x && !(x & (x - 1)); } long long int xorcal(long long int n) { if (n % 4 == 0) return n; if (n % 4 == 1) return 1; if (n % 4 == 2) return n + 1; if (n % 4 == 3) return 0; } void siev... |
#include <bits/stdc++.h> using namespace std; int n, v[10004]; vector<array<int, 3> > ans; void go(int x, int y, int z) { v[x] -= x * z; v[y] += x * z; ans.push_back({x, y, z}); } int main() { int t; cin >> t; while (t--) { ans.clear(); int sum = 0; cin >> n; ... |
#include <bits/stdc++.h> using namespace std; long long a, b, c, n, m, k, x, y, z, cnt, ans, tt; string s; vector<long long> v, q, t; int main() { long long c0, c1, h; cin >> tt; while (tt--) { cin >> n >> c0 >> c1 >> h >> s; cnt = 0; ans = 0; for (long long i = 0; i < s.si... |
#include <bits/stdc++.h> #pragma GCC optimaze( Ofast ); #pragma GCC optimize( unroll-loops ) using namespace std; const long long maxk = 1e8 + 113; const long long maxb = 1e18 + 113; const long long inf = 2e18; struct line { long long k, b; line() { this->k = 0; this->b = 0; } ... |
#include <bits/stdc++.h> using namespace std; bool compare(vector<long long> &A, vector<long long> &B) { if (A[0] - A[1] > B[0] - B[1]) return true; return false; } int main() { long long(n), (a), (b); scanf( %lld%lld%lld , &(n), &(a), &(b)); ; vector<vector<long long>> A, B; long lo... |
/**
* 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 debug = 0; int n, m, k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; string direc = RDLU ; long long ln, lk, lm; void etp(bool f = 0) { puts(f ? YES : NO ); exit(0); } void addmod(int &x, int y, int mod = 1000000007) { x += y; ... |
#include <bits/stdc++.h> using namespace std; int key; long long dis[1000]; struct pt { long long x, y, z; } f[8], point[8]; long long meow(int a, int b) { long long ta, tb, tc; ta = f[a].x - f[b].x; tb = f[a].y - f[b].y; tc = f[a].z - f[b].z; return (ta * ta + tb * tb + tc * tc); ... |
// Fast Multisource Pulse Registration System
// Module:
// event_tagger
// Pulse Registration and Time Stamping
// (c) Sergey V. Polyakov 2006-forever
module event_tagger(
strobe_channels,
delta_channels,
clk,
reset_counter,
capture_operate, counter_operate,
data,
ready
);
input [3:0] strobe_cha... |
#include <bits/stdc++.h> const long long int mod = 1e9 + 7; using namespace std; long long int p, q, r, s; long long int len(long long int x) { long long int count = 0; while (x > 0) { x = x / 10; count++; } return count; } long long int fx(long long int x) { long long int co... |
#include <bits/stdc++.h> const double pi = (double)(2.0 * acos(0.0)); const int inf = 1 << 30; const double eps = 1E-9; const double e = exp(1.0); const int sz = 100000 + 5; const int mod = 1000000000 + 7; using namespace std; int main() { double x, y, z, res, v; string st = ; scanf( %lf %... |
#include <bits/stdc++.h> using namespace std; int N, K; int A[310000]; int dp[31000][210][4][2]; int ins(int i, int k, int bit) { if (k == 1) { if (bit % 2 == 0) return A[i]; return -A[i]; } if (k == K) { if (bit / 2 == 0) return -A[i]; return A[i]; } int res = 0; ... |
#include <bits/stdc++.h> using namespace std; const int M = 11, L = 11, N = 1002; const int Mod = 1e9 + 9; char a[L], to[99]; int n; int dp[2][M * L][N], ch[M * L][4], fail[M * L]; int len[N]; int ans = 0; inline void mo(int& x) { x = (x >= Mod ? x - Mod : x); } struct AC_automaton { int cnt; ... |
`timescale 1 ns / 1 ps
module axis_trigger #
(
parameter integer AXIS_TDATA_WIDTH = 32,
parameter AXIS_TDATA_SIGNED = "FALSE"
)
(
// System signals
input wire aclk,
input wire pol_data,
input wire [AXIS_TDATA_WIDTH-1:0] msk_data,
input wire [AXI... |
#include <bits/stdc++.h> using namespace std; const long long int maxn = 2e5 + 6; const long long int inf = 2e18 + 1; long long int a[maxn]; int main() { long long int n, k; cin >> n >> k; long long int next[n]; for (long long int i = 0; i < n; i++) { cin >> a[i]; } next[n - 1] =... |
//==================================================================================================
// Filename : RKOA_OPCHANGE.v
// Created On : 2016-10-26 23:25:59
// Last Modified : 2016-10-27 09:51:09
// Revision :
// Author : Jorge Esteban Sequeira Rojas
// Company : Instituto Tec... |
#include <bits/stdc++.h> using namespace std; inline void read(int &x) { char ch = getchar(); x = 0; while (!isdigit(ch)) ch = getchar(); while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar(); } int n, m, mx, now, a[5200]; signed main() { read(n), read(m); int tmp = 0; for (int ... |
// Copyright (c) 2000-2012 Bluespec, Inc.
// 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, pub... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 100; const int MAXT = 1e10 + 1000; int N; long long T; const double EPS = 1e-12; const double CHTLB = -1; const double CHTUB = 1e20; double V, t; double pow(double b, long long p) { assert(p >= 0); if (p == 0) return 1; ... |
#include <bits/stdc++.h> using namespace std; void solve() { int a, b, n; cin >> n >> a >> b; vector<int> A(n); for (int &x : A) cin >> x; sort(A.begin(), A.end()); if (A[b] - A[b - 1] == 0) { cout << 0 n ; return; } cout << A[b] - A[b - 1] << n ; } int main() { ... |
#include <bits/stdc++.h> using namespace std; string name[1010]; int score[1010]; bool good[1010]; map<string, int> mp; int main(void) { int N, i; cin >> N; for ((i) = 0; (i) < (int)(N); (i)++) cin >> name[i] >> score[i]; for ((i) = 0; (i) < (int)(N); (i)++) mp[name[i]] += score[i]; int ... |
/*
* Milkymist SoC
* Copyright (C) 2007, 2008, 2009, 2010 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 distribut... |
#include <bits/stdc++.h> using namespace std; int T, n, m, sa[40010], sb[40010], ls, du[201], ans; bool g[201][201]; int getint() { int w = 0; bool q = 0; char c = getchar(); while ((c > 9 || c < 0 ) && c != - ) c = getchar(); if (c == - ) c = getchar(), q = 1; while (c >= 0 && 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 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) 2001-2011 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; const int MAX = 2e5 + 5; int now; int n, m, c, a[MAX]; int main() { cin >> n >> m >> c; c /= 2; while (m--) { int x; scanf( %d , &x); if (x <= c) { for (int i = 1; i <= n; i++) { if (a[i] == 0 || a[i] > x) { ... |
#include <bits/stdc++.h> const int MN = 1e3 + 10; const int K = 20; int N, M, T, id[MN], t[MN], ctr, m[1 << K]; bool conn[MN][MN]; char s[10]; std::vector<int> a[MN], on[K + 1]; struct Mod { public: char c; int a, b; void out() const { printf( %c %d %d n , c, a, b); } }; std::vector<Mod... |
#include <bits/stdc++.h> using namespace std; int long long n, a, b, x = 4, y = 2, ans, m, ans1, ans2, ans3; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin >> m >> a >> b; while (x > 0 || y > 0) { ans++; n = m; while (x > 0 && n >= 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; const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0}; const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1}; const int MAX = 2 * 1000 + 10; const long long INF = 1e18; const int MOD = 1e9 + 7; long long n, m, x, y, a[MAX], b[MAX], c[MAX], d[MAX]; long long dp[MAX][20]; l... |
// ========== Copyright Header Begin ==========================================
//
// OpenSPARC T1 Processor File: bw_clk_gl_fdbk.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 an... |
#include <bits/stdc++.h> using namespace std; int main() { int k, x, n, m; scanf( %d%d%d%d , &k, &x, &n, &m); for (int f1 = 0; f1 <= 1; f1++) { for (int f2 = 0; f2 <= 1; f2++) { for (int f3 = 0; f3 <= 1; f3++) { int h1 = n, h2 = m; if (f1) h1--; if (f1 || f3) ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int sz2 = 5e5 + 1; int fact[sz2]; int inv_fact[sz2]; int mul(int a, int b) { return (long long)a * b % mod; } int add(int a, int b) { int res = (long long)a + b; if (res < 0) res += mod; else if (res > mod) ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int b, p, f; int h, c; cin >> b >> p >> f >> h >> c; if (b >= p * 2 + f * 2) cout << p * h + f * c << endl; else { if (c >= h) { cout << min(b / 2, f) * c + m... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 03/06/2016 02:02:25 PM
// Design Name:
// Module Name: mdct_myidct
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
/... |
#include <bits/stdc++.h> using namespace std; int l[5010], r[5010]; vector<int> vc; long long f[2][10100]; int cost[10100]; int doit(int x, int y) { if (vc[x] <= l[y]) return l[y] - vc[x]; if (vc[x] >= r[y]) return vc[x] - r[y]; return 0; } int main() { int start = 0; int n; scan... |
// megafunction wizard: %RAM: 1-PORT%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: altsyncram
// ============================================================
// File Name: RAMB16_S4_altera_new.v
// Megafunction Name(s):
// altsyncram
//
// Simulation Library Files(s):
// altera_mf
// =======... |
#include <bits/stdc++.h> using namespace std; long long a[5010], b[5010], n, dp[5010]; int main() { cin >> n; for (long long i = 1ll; i <= n; i++) scanf( %I64d , &a[i]), b[i] = a[i]; sort(b + 1ll, b + n + 1ll); dp[0ll] = (long long)1000000000000000007; for (long long i = 1ll; i <= n; i++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, k, ans = 0, t; cin >> t; while (t--) { cin >> n >> k; ans = 0; while (n > 0) { if (n % k == 0) { n /= k; ans++; ... |
/*+--------------------------------------------------------------------------
Copyright (c) 2015, Microsoft Corporation
All rights reserved.
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 ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e6 + 7; int cnt[N], a[N], idx, l, r, n; long long ans, sum; int main() { scanf( %d , &n); for (int i = (1); i <= (n); ++i) { scanf( %d , a + i); if (a[i] >= i) l++, cnt[a[i] - i]++; else r++; ans += ab... |
/*
* 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... |
//
// .. hwt-autodoc::
//
module FullAdder (
input wire a,
input wire b,
input wire ci,
output reg co,
output reg s
);
always @(a, b, ci) begin: assig_process_co
co = a & b | (a & ci) | (b & ci);
end
always @(a, b, ci) begin: assig_process_s
s = a ^ b ^ ci;
en... |
//-----------------------------------------------------------------
// AltOR32
// Alternative Lightweight OpenRisc
// V2.0
// Ultra-Embedded.com
// Copyright 2011 - 2013
//
// Email:
//
// ... |
#include <bits/stdc++.h> using namespace std; template <typename T> static ostream& operator<<(ostream& stream, const vector<T>& t); template <typename T> static istream& read(T, T, istream& = cin); template <typename T> static istream& operator>>(istream& stream, vector<T>& t) { return read((t).begin... |
//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 associate... |
#include <bits/stdc++.h> using namespace std; char buf[1 << 20], *p1, *p2; template <class T> inline void read(T &n) { char ch = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2) ? 0 : *p1++); T w = 1, x = 0; while (!isdigit(ch)) { if (c... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); double fRand(double fMin, double fMax) { double f = (double)rand() / RAND_MAX; return fMin + f * (fMax - fMin); } template <class T> T min(T a, T b, T c) { return min(a, min(b, c)); } template <class T> T max(T a, ... |
#include <bits/stdc++.h> using namespace std; int S[1000007], X[1000007], Y[1000007], W[1000007], C[1000007]; char s[10]; void dfs(int x) { if (!S[x]) { W[x] = X[x]; return; } dfs(X[x]); if (S[x] > 1) dfs(Y[x]); if (S[x] == 1) W[x] = W[X[x]] ^ 1; if (S[x] == 2) W[x] = W[X[x]]... |
// Copyright (C) 2020-2021 The SymbiFlow Authors.
//
// Use of this source code is governed by a ISC-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/ISC
//
// SPDX-License-Identifier:ISC
(* abc9_box, lib_whitebox *)
module adder_lut4(
output lut4_out,
(* abc9_carr... |
// Copyright (c) 2015 CERN
// Maciej Suminski <>
//
// 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 late... |
// Library - static, Cell - th24w22, View - schematic
// LAST TIME SAVED: May 23 16:50:53 2014
// NETLIST TIME: May 23 16:51:13 2014
`timescale 1ns / 1ns
module th24w22 ( y, a, b, c, d );
output y;
input a, b, c, d;
specify
specparam CDS_LIBNAME = "static";
specparam CDS_CELLNAME = "th24w22";
spec... |
#include <bits/stdc++.h> using namespace std; mt19937_64 rng( (unsigned)chrono::system_clock::now().time_since_epoch().count()); const long double error = 1e-7; const long double PI = acosl(-1); const int nmax = 2e5 + 10; int master[nmax]; int sz[nmax]; void init(int u) { master[u] = u; sz... |
/*
This file is part of Fusion-Core-ISA.
Fusion-Core-ISA 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.
Fusion-Core-... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; void err() { cout << 033[39;0m << endl; } template <class T, class... Ts> void err(const T& arg, const Ts&... args) { cout << arg << ; err(args...); } const int N = 100000 + 5; int n, h, m, k; int H[N]; pair<int,... |
/*!
* <b>Module:</b>gtx_comma_align
* @file gtx_comma_align.v
* @date 2015-07-11
* @author Alexey
*
* @brief comma aligner implementation
*
* @copyright Copyright (c) 2015 Elphel, Inc.
*
* <b>License:</b>
*
* gtx_comma_align.v is free software; you can redistribute it and/or modify
* it under the t... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; int tt; cin >> tt; while (tt--) { int n; cin >> n; cout << (1ll * ((n - 1) / 2) * (((n - 1) / 2) + 1) * (2 * ((n - 1) / 2) + 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 law... |
// ----------------------------------------------------------------------------
// -- capeta_test.v: CSoC scan chain control and cadence ATPG
// -- All the received characters are echoed
// ----------------------------------------------------------------------------
// -- (C) BQ. Fev 2017. Written by Leandro Heck ()
//... |
/**
* 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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.