#include <bits/stdc++.h>using namespace std;#define ll long long#define inf 0x3f3f3f3f#define N 2000int main(){ ofstream outfile; outfile.open("out.txt"); string sss; while(1){ getline(cin,sss); stringstream ss(ss
先求0,1的个数,然后贪心输出01即可 #include<bits/stdc++.h>using namespace std;#define ll long long ll a,b,c,d,tot1,tot0;int main(){ cin>>a>>b>>c>>d; //a=0,b=0的情况优先考虑 if(!a && !b && !c && !d){ puts(&q
原文链接:https://blog.csdn.net/henryzhang2009/article/details/45706163 public class IPUtils { /** * 将字符串形式IP地址127.0.0.1转换10234564321 * * @param strIP * @return */ public static long ip2Long(
output standard output Little Dima has two sequences of points with integer coordinates: sequence (a1, 1), (a2, 2), ..., (an, n) and sequence (b1, 1), (b2, 2), ..., (bn, n). Now Dima wants to count the number of distinct sequences of points
题目链接:http://lightoj.com/volume_showproblem.php?problem=1245 I was trying to solve problem '1234 - Harmonic Number', I wrote the following code long long H( int n ) { long long res = 0; for( int i = 1; i <= n; i++ )
传送门 看题目就想到 $dp$,想不出来就去想贪心... 考虑按右端点排序,一个个修,如果在修某个建筑 $i$ 时发现来不及了,说明前 $i$ 个建筑最多只能修 $i-1$ 个 那么我们把前 $i$ 个中耗时最长的那个放弃,这样省下的时间最多 然后用优先队列维护一下就行 #include<iostream>#include<cstd
After Incident, a feast is usually held in Hakurei Shrine. This time Reimu asked Kokoro to deliver a Nogaku show during the feast. To enjoy the show, every audience has to wear a Nogaku mask, and seat around as a circle. There are N guests Reimu ser
人群淹没,你我不及诉说。一声雁过,往事如昨。只望离别不多,再赏盛世烟火。 题目描述 张琪曼以数值的形式将人的一生的每个关键时间点以数值表示,快乐值越高,分值越高,痛苦值越高,分值越低甚至会成为负数。进一步研究,她又发现人性是复杂的,每个人的感知能力也是不尽相同的,例如有些人对
Remainder Problem 题面: You are given an array a consisting of 500000 integers (numbered from 1 to 500000). Initially all elements of a are zero. You have to process two types of queries to this array: 1 x y — increase ax by y; 2 x y — compute ∑i∈R
把a,b合并起来跑一遍就行 记录一下板子 #include<bits/stdc++.h>#define ll long long #define ull unsigned long long#define fi first#define se second#define mp make_pair//#define endl '\n'#define pii pair<ll,ll>#define all(x) x.begin(),x.end()#define I
以某个题为例 Description 给出一个序列,包含n个数,有正数、0及负数。 现取连续的一段数,问它们和的绝对值的最小、最大值分别为多少? Input 第一行一个数n,表示序列长度。(1<=n<=1e5) 第二行包含n个整数,a[1],a[2]…a[n]。(-1e7<=a[i]<=1e7) Output 一行包含两个数 最小值、最大值。
CF-1207F 分块题 可以说是原题了 哈希冲突 分块 按模数分块 超过sqrt(n)sqrt(n)sqrt(n) 的暴力找 小于的 我们也在n∗sqrt(n)n*sqrt(n)n∗sqrt(n) 预处理了 之后单点修改 也是sqrt(n)的复杂度 #include <bits/stdc++.h> #define fastio ios::sync_with_stdio(false);cin.tie(0)
excrt的理解 问对于方程组x = ai % ci 的 通解 x+tM, (x+tM) % k 是否有唯一值 看tm%k是否==0即可 #include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#include<queue>#include<vector>using namespace std;const int maxn = 1e5+100;ty
(传送门)[https://vjudge.net/contest/320030#problem/A] #include <iostream> #include <cstdio> #define ll long long #define INF 0x3f3f3f3f using namespace std; const int N=1e5+5; int main(){ int t,s,n; cin>>t; int a[N]; while(t
这次吧,就是最大能力了,发挥的很正常。 自己也不再那么天真了,更追求实际的东西了。 T1 chinese 一道好题,考察的是对于公式实际意义的理解和转化题目的能力。 考场上一眼看上去啥都不会,但是看了眼数据,5以内60分,嘿嘿嘿…… 打着表,就跳了这道题。 下面讲正解。 我
1.调取对方的接口,对象自动转型成LinkedHashMap,直接用类型强会抛cast.Exception,解决方案 先序列化对象,再反序列化接受对象。 2.调取对方接口返回Long类型的值,我放直接使用Long接报Integer cast to Long异常,解决方案:使用Integer接并.longValue获取Long值。 3.调取对方Get请求,我方
原文链接:https://blog.csdn.net/buki26/article/details/78289302 32位编译器: char :1个字节 指针变量: 4个字节 short int : 2个字节 int: 4个字节 unsigned int : 4个字节 float: 4个字节 double: 8个字节 long: 4个字节 long long: 8
Creative Snap C. Creative Snap time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Thanos wants to destroy the avengers base, but he needs to destroy the avengers along with their base. Let we re
题面 https://www.luogu.org/problem/P4248 题解 这里,提供后缀数组的做法。 #include<cstdio>#include<cstring>#include<algorithm>#include<iostream>const int N=1000050;using namespace std;char s[N];int n,m,rank[N],sa[N],tax[N],tp[N],height[N];struct rm
题意: 有一个\(n*n*n\)的三维直角坐标空间,问从\((0,0,0)\)看能看到几个点。 思路: 按题意研究一下就会发现题目所求为\(\sum_{i=0}^n\sum_{j=0}^n\sum_{k=0}^ngcd(i,j,k)==1\),那么我们定义\(f(n)\)为\(gcd(i,j,k)==n\)的对数,\(F(n)\)为\(gcd(i,j,k)\)是\(n\)倍数的对数,显然\(F(n)\)
service public void deleteCategoriesById(Long id,Long pid) { //获取对象 Category category1 = this.categoryMapper.selectByPrimaryKey(id); //创建子对象的id的列表 List<Long> sons = new ArrayList<>(); //创建中间列
一、数据类型 1.整形 int a = 5; //定义一个整形变量a,并初始化值为5,4个字节 unsigned int b; //无符号整形,4个字节 short int c; //短整形,2个字节,可以写成 short c; long int d; //长整形,8个字节,可以写成 long c; long long int e; //
题意: 多个输入样例,以字符串END结束。对于每个串输出其最长回文子串 思路: 对于回文串来说,我们可能一开始会想到 \(O(n^2)\)的 循环中心位置然后往左右两端匹配。然后Manacher算法则可以将其直接降到 \(O(n)\) ,运用的则是回文串本身对称性的原理。 由于任意一个字符串长度有奇偶,对
m个询问 每个询问有三个节点 求出 一个节点 使得这三个节点到该结点的距离之和最小 输出该节点和距离之和 一开始用线段树给三条边均加1 最大值的节点就是答案 但是T了 可以优化log 观察三个节点的lca可发现 如果三个lca都相同 那么就是该节点 如果两个相
D. Print a 1337-string... 输出一个字符串 里面包含n个子序列 1337 #include<bits/stdc++.h>using namespace std;#define sc(x) scanf("%I64d",&x);#define int long longint t,n;int C[100005];void init(){ for(int i=1; i<=100000; i++) { C[i]=((