text stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int s[10000], g[10000]; set<int> v; int main() { int k, n; cin >> k >> n; for (int i = 0; i < n; i++) { cin >> s[i] >> g[i]; } for (int i = 1; i <= 100; i++) { bool f = 1; for (int j = 0; j < n; j++) { if ((s[j] + i - 1)... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100 * 1005; bool bad[maxn]; vector<int> blocked; vector<int> g[maxn]; bool seen[maxn]; int deg[maxn]; vector<int> good; int n, m, k; bool can(double mid) { memset(bad, 0, sizeof(bad)); memset(deg, 0, sizeof(deg)); memset(seen... |
`default_nettype none
`timescale 1ns / 1ps
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 ... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > seq; const int mod = 1e6; const long long A = 42344; const long long B = 333; int seed = 239; int mrand() { static int now = -1; if (now == -1) now = seed; else now = (A * now + B) % mod; return now; } st... |
#include <bits/stdc++.h> using namespace std; int N; char s[1005], z[1005]; int solve1() { int ans = 0; int lz, rz, ls, rs; lz = ls = 0; rz = rs = N - 1; while (ls <= rs) { if (z[rz] >= s[rs]) rz--, rs--; else ans++, lz++, rs--; } return ans; } int sol... |
(* Copyright (c) 2008-2012, Adam Chlipala
*
* This work is licensed under a
* Creative Commons Attribution-Noncommercial-No Derivative Works 3.0
* Unported License.
* The license text is available at:
* http://creativecommons.org/licenses/by-nc-nd/3.0/
*)
Require Import Eqdep List.
Require Omega.
Set Impli... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t, s, q; cin >> t >> s >> q; int ans = 0; int tot = s; while (tot < t) { tot *= q; ++ans; } cout << ans << endl; } |
#include <bits/stdc++.h> using namespace std; int main() { int t, n, k; int nums[1005]; cin >> t; while (t--) { cin >> n >> k; for (int i = 0; i < n; i++) cin >> nums[i]; sort(nums, nums + n); int sum = 0; for (int i = 1; i < n; i++) sum += (k - nums[i]) / nums[0]; ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, d; cin >> n >> d; int ld = 0, rd = n * (n - 1) / 2; for (int i = 1, cd = 0; i <= n; ++i) { if (!(i & (i - 1))) ++cd; ld += cd - 1; } if (!(ld <= d && d <= ... |
#include <bits/stdc++.h> using namespace std; int n, m, max; vector<int> a[100000]; bool visited[100000] = {0}; char col[100000] = { Z }; void f(int x) { queue<int> q; q.push(x); visited[x] = 1; char temp = A ; col[x] = temp; while (!q.empty()) { int p = q.front(); q.pop... |
#include <bits/stdc++.h> using namespace std; int main() { int x1, y1, z, x, y; cin >> x1 >> y1 >> z; x = x1 - y1 + z; y = x1 - y1 - z; if (x > 0 && y > 0) cout << + << n ; else if (x < 0 && y < 0) cout << - << n ; else if (x == 0 && y == 0) ... |
#include <bits/stdc++.h> using namespace std; long long st; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n, m, k; cin >> n >> m >> k; if (k < n) { cout << (long long)(k + 1) << << 1; return 0; } k -= (long long)(n - 1); long long row = k /... |
/**
* 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-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 ... |
/**
* 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... |
/*
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.
*/
module dvi_encoder_13 (
input pclk,
input pclkx2,
input pclkx10,... |
//////////////////////////////////////////////////////////////////////
//// ////
//// eth_register.v ////
//// ////
//// This file is part of the Ether... |
/**
* 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; template <typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << ; cout << endl; } template <typename T> void chmin(T &t, const T &f) { if (t > f) t = f; } template <typename T> void chmax(T &t, const T &f) { if (t < f)... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, first, second, third, fourth; cin >> a >> b >> c; first = a + b + c; second = 2 * (a + b); third = 2 * (b + c); fourth = 2 * (a + c); cout << min(first, min(second, min(third, fourth))); } |
#include <bits/stdc++.h> const int N = 50; std::vector<int> *graph[N][N], *igraph[N][N]; std::vector<int> expand(std::vector<int> *graph[N][N], std::vector<int> queue, int max) { for (int t = 0; t + 1 < (int)queue.size() && (int)queue.size() <= max; ++t) { int u = queue[t]; ... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
#include <bits/stdc++.h> int main() { int n, i, c = 0; char s[500]; scanf( %d %s , &n, s); for (i = 0; i < n - 1; i++) { if (((s[i] == R ) && (s[i + 1] == U )) || ((s[i] == U ) && (s[i + 1] == R ))) { c++; i++; } } printf( %d n , n - c); 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... |
// $Header: /devl/xcs/repo/env/Databases/CAEInterfaces/versclibs/data/fuji/BUFR.v,v 1.6 2011/08/09 22:45:10 yanx Exp $
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 1995/2005 Xilinx, Inc.
// All Right Reserved.
//////////////////////////////////////////////////////////... |
/*
* Copyright (c) 2011, Stefan Kristiansson <>
* All rights reserved.
*
* Redistribution and use in source and non-source forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, th... |
// 4 3 2 1 0
// L W S E N
// sram: x: 00 y: 10
// scheduler: x: 00 y: 01
module mapreduce(clk, rst, scheduler_wen);
parameter WIDTH=36;
parameter DEPTH=8;
parameter ADDR=4;
parameter lhsCount=5;
parameter rhsCount=5;
input clk;
input rst;
// Start the scheduler from the outside.
// Since the sch... |
/**
* 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 n, c[3010]; struct info { int x, y; }; struct as { int a, b, c; } ans; struct node { int x, id; } a[3010]; inline bool cmp(node a, node b) { return a.x > b.x; } inline info max(info a, info b) { if (a.x < b.x) return b; return a; ... |
#include <bits/stdc++.h> using namespace std; const int N = 100005, logN = 18; int n, q, l, r, tim; struct vec { int x, y, num; bool operator<(const vec &A) const { return x < A.x || x == A.x && y > A.y; } } a[N]; inline long long calc(vec *a) { return a->x + 1LL * tim * a->y; } inline long long c... |
#include <bits/stdc++.h> using namespace std; pair<long long, long long> a[100001]; long long start = 0; long long h; long long res; long long c[100001]; long long n; int main() { ios_base::sync_with_stdio(false); cin >> n >> h; for (int i = 1; i <= n; ++i) { cin >> a[i].first; a... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e6; const long long MX = -1e7 - 3; const long long MN = 1e7 + 3; long long n, m, cnt, ans, x, y, mx = MX, mn = MN, a, b, c, d, T, l, r, k; float p = 3.14159; bool bl, bl1; string str = , s; map<char, long long> mp, mp1; vector<long... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
//Legal Notice: (C)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; template <class T> T sqr(T x) { return x * x; } struct sp { int x, y; bool operator<(const sp &a) const { return x < a.x || x == a.x && y < a.y; } bool operator==(const sp &a) const { return x == a.x && y == a.y; } }; namespace std { template... |
#include <bits/stdc++.h> using namespace std; void imprimirVector(vector<int> v) { if (!v.empty()) { int p = v.size(); cout << [ ; for (int i = 0; i < (int)(p - 1); i++) cout << v[i] << , ; cout << v[p - 1] << ] << endl; } else cout << [] << endl; } int toNumber(strin... |
/*
* 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... |
//////////////////////////////////////////////////////////////////////
//// ////
//// OR1200's IC FSM ////
//// ////
//// This file is part of the OpenR... |
/**
* 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) 2014-2017 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... |
/**
* 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... |
`timescale 1ns / 1ps
/* All files are owned by Kris Kalavantavanich.
* Feel free to use/modify/distribute in the condition that this copyright header is kept unmodified.
* Github: https://github.com/kkalavantavanich/SD2017 */
//////////////////////////////////////////////////////////////////////////////////
// Creat... |
/*
Copyright (c) 2016-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... |
/*
Copyright (c) 2015-2016 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; void solve() { long long int n; cin >> n; long long int ans = 0; long long int t = 1; long long int x = 2; while (n - (t * (t + 1) / 2) >= 0) { long long int val = t * (t + 1) / 2; n -= val; t += x; x *= 2; ans++; ... |
#include <bits/stdc++.h> using namespace std; typedef int arr32[5000010]; arr32 x, rk, l, r; int n; long long ans; bool cmp(const int &a, const int &b) { return x[a] < x[b]; } void erase(int x) { r[l[x]] = r[x], l[r[x]] = l[x]; } int main() { cin >> n; for (int i = 1; i <= n; ++i) { scanf(... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 100; const long long inf = 1e18; vector<int> g[maxn]; bool visit[maxn]; int cnt = 0; void dfs(int u) { cnt = 0; queue<int> q; q.push(u); visit[u] = true; cnt++; while (!q.empty()) { int u = q.front(); ... |
#include <bits/stdc++.h> using namespace std; int main() { int xa, ya, xb, yb, n, count = 0; cin >> xa >> ya >> xb >> yb; if (xa > xb) { int t = xa; xa = xb; xb = t; } if (ya > yb) { int t = ya; ya = yb; yb = t; } cin >> n; int x[n], y[n], r[n]; ... |
#include <bits/stdc++.h> using namespace std; int main() { int s, n, a[10000] = {0}, m = -1, y, i; cin >> s >> n; int c = n; while (n--) { cin >> i >> y; a[i] += y; m = max(m, i); } for (int i = 0; i < 10000; i++) { if (s > i) { s += a[i]; } } s ... |
#include <bits/stdc++.h> using namespace std; vector<vector<int> > ans; void gen(int n) { for (int e = 0; e < n; e++) ans.push_back({6 * e + 1, 6 * e + 2, 6 * e + 3, 6 * e + 5}); } int main() { int n, k; cin >> n >> k; cout << k * (6 * n - 1) << endl; gen(n); for (auto &it : ans)... |
//Legal Notice: (C)2015 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; using ll = long long; using ld = long double; constexpr int MAXN = 100005; int SQRTN; int n, k; int t[MAXN], a[MAXN]; ll p[MAXN]; ll ans[MAXN]; ll cur = 0; int ind[MAXN], left_ind[MAXN], right_ind[MAXN]; int freq[3 * MAXN]; struct query { int l... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9 + 7; const int N = 1e5 + 10; vector<int> v[N]; void init() { int tot = 0; for (int i = 1; i < N; i++) { for (int j = i; j < N; j += i) { v[j].push_back(i); } tot = max(tot, (int)v[i].size()); } } ... |
#include <bits/stdc++.h> using namespace std; int a, b, n; int main() { cin >> a >> b >> n; for (int i = 0; i < n - 1; ++i) { b = a + b; a = b - a; } cout << b << endl; 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; int main() { int count = 0, size; cin >> size; char c; vector<char> num; for (int i = 0; i < size; i++) { cin >> c; num.push_back(c); } for (int i = 0; i < num.size(); i++) { if (num[i] == 8 ) count++; if ((size / 11)... |
// ==============================================================
// File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC
// Version: 2017.3
// Copyright (C) 1986-2017 Xilinx, Inc. All Rights Reserved.
//
// ==============================================================
`timescale 1ns/1ps
m... |
#include <bits/stdc++.h> int inp() { char c = getchar(); int neg = 1; while (c < 0 || c > 9 ) { if (c == - ) neg = -1; c = getchar(); } int sum = 0; while (c >= 0 && c <= 9 ) { sum = sum * 10 + c - 0 ; c = getchar(); } return sum * neg; } int a[110];... |
/**
* 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... |
// FGPA Test of TOP functional block.
// Copyright 2010 University of Washington
// License: http://creativecommons.org/licenses/by/3.0/
// 2008 Dan Yeager
// Maps FPGA IO onto RFID tag (top.v)
module toptest(LEDR, LEDG, GPIO_0, KEY, SW, EXT_CLOCK,
HEX0, HEX1, HEX2, HEX3, HEX4, HEX5, HEX6, HEX7);
in... |
#include <bits/stdc++.h> using namespace std; long long n, m, cnt, num, sub_d[(2600)], d[(2600)], root, cut[(2600)], t; char s[55][55]; bool mark[(2600)], p, cycle; vector<long long> e[(2600)]; void dfs(long long x, long long par = 0) { bool tmp = 0; if (!t) cnt++; mark[x] = 1; sub_d[x] = d[... |
#include <bits/stdc++.h> std::vector<int> V[200010], V2[200010]; int check[200010]; std::stack<int> St; void init(int k) { if (check[k] == 1) return; check[k] = 1; for (int i = 0; i < V[k].size(); i++) init(V[k][i]); St.push(k); } int color[200010]; void makeSCC(int k, int c) { if (col... |
//
// 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... |
#include <bits/stdc++.h> using namespace std; const int MAX = 500004, inf = 0x3f3f3f3f; int a[MAX]; int no[102]; int nex[MAX][102]; int f[102][102 * 102]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, k, p; cin >> n >> k >> p; for (int i = 1; i <= n; i++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n; int a[n], i; for (i = 0; i < n; ++i) cin >> a[i]; cin >> m; int b[m]; for (i = 0; i < m; ++i) cin >> b[i]; sort(a, a + n, greater<int>()); sort(b, b + m, greater<int>()); cout << a[0] << << b[0... |
#include <bits/stdc++.h> using namespace std; int n, m, K, bs[500005], hs[500005], ht[500005], ht2[500005], lpos[500005], rpos[500005], ansl, ansr; bool flag; set<int> S; set<int>::iterator it; struct node { int len, id; } a[500005]; char s[500005], t[500005]; int Hashs(int fr, int to) { ... |
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2010 by Wilson Snyder.
//
// --------------------------------------------------------
// Bug Description:
//
// Issue: The gated clock gclk_vld[0] toggles but dvld[0]
// i... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, pair<int, int> > > v[100005]; vector<int> ans; int n; bool has_cycle(int mid) { int indeg[100005]; int cnt = 0, x; memset(indeg, 0, sizeof(indeg)); for (int i = 1; i <= n; ++i) { for (auto g : v[i]) { if (g.second.fir... |
module midi_in(CLK, RES, MIDI_IN,
CH_MESSAGE,
CHAN, NOTE, VELOCITY, LSB, MSB //параметры сообщений
);
input wire CLK; // 50 MHz clock
input wire RES; // reset
input wire MIDI_IN; // MIDI in data
//note control
output reg [3:0] CHAN; // номер канала, в который отпр... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, l, r, c, ans; cin >> a >> b >> l >> r; c = l % (a + b); if (c > a) { ans = 1; l += (a + b - c + 1); if (l <= r) ans += min(a, r - l + 1); if (a > b) { l += (2 * b); if (l <= r) ans += m... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int getRand(int l, int r) { uniform_int_distribution<int> uid(l, r); return uid(rng); } unordered_map<string, int> X; long long get_sum(long long n) { if (n == 1) { return 1; ... |
#include <bits/stdc++.h> using namespace std; int v, m, d, f; int main() { int n, a, b, c; cin >> n; for (int i = 0; i < n; i++) { cin >> a >> b >> c; if (a == 1) { v += b; m += c; } else { d += b; f += c; } } if (v >= m) cout << L... |
`timescale 1ns / 1ps
module display_data(
input clk,
input [15:0] decimal_nybble,
output reg [3:0] seg_an_reg,
output reg [7:0] seg_cat_reg
);
integer slowdown;
reg [1:0] state;
//reg [3:0] seg_an_reg;
//reg [7:0] seg_cat_reg;
integer ID;
integer digit;
integer dig0;
integer dig1;
integer dig2;
inte... |
#include <bits/stdc++.h> using namespace std; void Solve() { int n; string a, b; cin >> n >> a >> b; a = - + a + - ; b = - + b + - ; int val = 0; for (int i = 1; i <= n; i++) { if (a[i] != b[i]) val += 2; else if (a[i] == 0 ) { val++; if (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... |
#include <bits/stdc++.h> using namespace std; long long t[5005], c[5005], ans[5005], n, i, l, b, v; int main() { cin >> n; for (i = 1; i <= n; i++) cin >> t[i]; for (l = 1; l <= n; l++) { for (i = 1; i <= n; i++) c[i] = 0; b = 0; for (i = l; i <= n; i++) { v = t[i]; c... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 4010; int N; long long V[MAXN], D[MAXN], P[MAXN]; set<int> st; int main() { if (fopen( input.txt , r )) { freopen( input.txt , r , stdin); } ios::sync_with_stdio(false); cin >> N; for (int i = 1; i <= N; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n = 0; cin >> n; vector<int> ans; int k = 0; if (n == 1) { cout << 1 << endl << 1; return 0; } for (int i = 1; i <= n; i... |
#include <bits/stdc++.h> const int N = 157, inf = 1e9 + 500; int n, m, del, t, dis[N]; int ans = inf; std::queue<int> q; struct node { int u, v, w; bool operator<(const node &a) const { return w < a.w; } } e[N]; inline int read() { int x = 0; char c = getchar(); while (!isdigit(c)) 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; const int mod = int(1e9 + 7); const double PI = acos(-1.0); const int N = 200000; long long n, a; long long p[N], b[N]; bool check(int x) { long long i, m; m = a; for (i = 0; i < x; i++) if (b[n - x + i] < p[i]) m -= p[i] - b[n - x + i]; ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 111111; int N; char s[MAX]; int f[MAX]; int sum[MAX]; bool match(int i, int j) { if (i < 1 || j < 1) return 0; if (s[i - 1] == ) ) return s[j - 1] == ( ; else return s[j - 1] == [ ; } int get(int i) { return f[i -... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; int dp[maxn], num[30]; int main() { int i, j, k, n, m, t, l, ans, x, y, z; char s[maxn]; scanf( %d , &t); while (t--) { scanf( %d%d%d , &n, &m, &k); scanf( %s , s); ans = 1e9; memset(num, 0, sizeof(nu... |
#include <bits/stdc++.h> using namespace std; template <class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& v) { os << ( << v.first << << v.second << ) ; return os; } template <typename T, typename U = typename T::value_type, typename = typename enable_if<!is_sa... |
#include <bits/stdc++.h> using namespace std; char c[503][503]; vector<pair<int, int> > v[503][503]; int main() { int n, m, k; cin >> n >> m >> k; int s = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> c[i][j]; if (c[i][j] == . ) s++; } }... |
//
// chrgen.v -- character generator
//
module chrgen(clk, pixclk,
chrcode, chrrow, chrcol,
pixel,
attcode_in, blank_in, hsync_in, vsync_in, blink_in,
attcode_out, blank_out, hsync_out, vsync_out, blink_out);
input clk;
input pixclk;
input [7:0] chr... |
#include <bits/stdc++.h> using namespace std; int n, r; long long A[1000005], sum; int main() { scanf( %d %d , &n, &r); for (int i = (0); i < (1 << n); i++) scanf( %lld , &A[i]), sum += A[i]; printf( %.12lf n , 1.0 * sum / (1 << n)); for (int i = (0); i < (r); i++) { int x; long long... |
#include <bits/stdc++.h> using namespace std; int n; char a[5]; char s1[3], s2[3]; void solve() { int i, vt, kq1, kq2; scanf( %d , &n); n = n % 4; a[0] = v ; a[1] = < ; a[2] = ^ ; a[3] = > ; for (i = 0; i < 4; i++) if (a[i] == s1[0]) vt = i; kq1 = 0; kq2 = 0; ... |
#include <bits/stdc++.h> using namespace std; namespace ioput { template <typename T> T read() { T x = 0, f = 1; char c = getchar_unlocked(); while ((c < 0 ) || (c > 9 )) { if (c == - ) f = -1; c = getchar_unlocked(); } while ((c >= 0 ) && (c <= 9 )) x = (x << 1) + (x ... |
#include <bits/stdc++.h> using namespace std; int n, a[1005]; int main() { int i, t, mini = 1000000, s, val, tfin; cin >> n; for (i = 1; i <= n; i++) cin >> a[i]; for (t = 1; t <= 105; t++) { s = 0; for (i = 1; i <= n; i++) { val = abs(t + 1 - a[i]); val = min(val, abs(... |
/*
* Copyright (c) 2000 Intrinsity, Inc.
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* ... |
#include <bits/stdc++.h> using namespace std; int n; int dpr[300005]; int dpl[300005]; int A[300005]; pair<int, int> B[300005]; int fr(int pos) { if (A[pos] == 0) return pos - 1; if (pos == n - 1) return n - 1; if (dpr[pos] != -1) return dpr[pos]; dpr[pos] = fr(pos + 1); return dpr[pos... |
///////////////////////////////////////////////////////////////////////////////
//
// Project: Aurora Module Generator version 2.8
//
// Date: $Date: 2007/09/28 12:50:36 $
// Tag: $Name: i+HEAD+134158 $
// File: $RCSfile: rx_stream.ejava,v $
// Rev: $Revision: 1.2 $
//
// ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100050; const int inf = 0x3f3f3f3f; struct Edge { int v, w; }; vector<Edge> G[maxn]; bool vis[maxn]; vector<int> st; int dep[maxn], f[maxn][20]; long long dis[maxn]; void dfs(int x, int par, long long sum) { f[x][0] = par; ... |
// ***************************************************************************
// ***************************************************************************
// Copyright 2014(c) Analog Devices, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, h, a, b, k, t1, f1, t2, f2; scanf( %lld%lld%lld%lld%lld , &n, &h, &a, &b, &k); while (k--) { scanf( %lld%lld%lld%lld , &t1, &f1, &t2, &f2); if (t1 == t2) printf( %lld n , abs(f2 - f1)); else { l... |
#include <bits/stdc++.h> using namespace std; unsigned long long power(unsigned long long x, unsigned long long y) { if (y == 0) return 1; unsigned long long tmp = power(x, y / 2); tmp *= tmp; if (y % 2) tmp *= x; return tmp; } unsigned long long get(unsigned long long n) { if (n <= 9) r... |
//#pragma GCC target ( avx2 ) //#pragma GCC optimization ( O3 ) //#pragma GCC optimization ( unroll-loops ) #include<bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> //using namespace __gnu_pbds; #define eps 1e-8 #define eq(x,y) (fabs((x)-(y)) < eps) usi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.