思维
ZzzzGgggHhhh
这个作者很懒,什么都没留下…
展开
-
第 45 届国际大学生程序设计竞赛(ICPC)亚洲区域赛(上海)——I
Sky Garden#include<bits/stdc++.h>#define pi acos(-1.0)using namespace std;typedef long long ll;typedef double db;const int N=1005;db anlen[N];int main() { int n,m; scanf("%d %d",&n,&m); db ans=0; int dian=m*2; int a=floor((1.0/p原创 2020-12-18 16:47:47 · 754 阅读 · 1 评论 -
2019ICPC南京——H
Prince and Princess题目链接麻婆王子与豆腐公主。。。给定三个数 a ,b,ca个人说真话b个人说假话c个人可能说真话可能说假话可以询问的三个问题1.你是谁?2.某个房子里住着谁?3.公主在那个房间?问 询问多少次 可以确定公主在哪个房间。题解:只考虑问第三个问题,统计每个人的回答,b和c都说假话,只要有b+c+1个人说真话,就会有一个答案被统计的次数超过说假话的人。注意特判一下 只有一个公主的情况。#include<bits/stdc++.h>原创 2020-12-10 18:07:43 · 391 阅读 · 0 评论 -
2019ICPC南京——K
Triangle题目链接给定一个三角形,和三角形上一个点,求三角形上另一个点,两点将三角形分成面积均等的两份。利用比值的思想,即可求解。#include<bits/stdc++.h>using namespace std;typedef long long ll;typedef double db;ll x1,x2,x3,y11,y2,y3,x,y;bool check(ll x1,ll y11,ll x2,ll y2,ll x,ll y) {//判断给定点是不是在三角形原创 2020-12-10 17:58:38 · 348 阅读 · 0 评论 -
Wannafly挑战赛5——D
子序列从m个位置中选出n个位置,每个位置有26种选择,这样就会出现重复的情况,例如题中的样例,按照这种方法,答案就是52。a_ _ b_ _ c_ _ _ ,a与b之间不能为a,b与c之间不能为b,所以,前面的空有25种选择方式,后面的空有26种选择方式,所以,只需要枚举字符串最后一位的位置,答案为C(i-1,n-1)*25(i-n)*26(m-i)相加的和。#include<bits/stdc++.h>using namespace std;typedef long long ll原创 2020-12-08 16:03:01 · 120 阅读 · 0 评论 -
Wannafly挑战赛5——A
珂朵莉与宇宙一道挺简单的思维题,想了好久没想出来,写个博客记录一下。#include<bits/stdc++.h>using namespace std;typedef long long ll;const int N=1e6+600;int vis[N];int main() { int n; scanf("%d",&n); int cut=0; vis[cut]++; ll ans=0; for(int i=1; i<=n; ++i) {原创 2020-12-08 11:44:38 · 98 阅读 · 0 评论 -
2020CCPC绵阳站——J
Joy of Handcraft题意:一串灯泡,每个灯泡都有一个亮度,一个开关周期,问每秒最亮的灯度是多少。题解:相同开关周期的灯泡,同时关,同时开,所以同一周期的灯泡,只需要考虑亮度最高的那个即可,其余灯泡对答案没影响。每一秒过后,周期为该秒数的因子的灯会变换一次状态,1e5以内的数,最多有120+个因子,所以,每秒最多只需要修改120+个等的状态即可。我们可以用线段树维护每种周期灯的状态,节点维护区间最大值,每次查询答案,只需要看根节点的值即可。#include<bits/stdc++原创 2020-11-04 21:13:30 · 896 阅读 · 0 评论 -
2020牛客暑期多校训练营(第四场)——H
Harder Gcd Problem时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288KSpecial Judge, 64bit IO Format: %lld题目描述After solving the Basic Gcd Problem, ZYB gives you a more difficult one:Given an integer n{n}n, find two subset A{A}A and B{B}B of {1,2,…,n}{1原创 2020-07-20 23:34:06 · 218 阅读 · 0 评论 -
2020牛客暑期多校训练营(第二场)——H
Happy Triangle链接:https://ac.nowcoder.com/acm/contest/5667/H来源:牛客网时间限制:C/C++ 2秒,其他语言4秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述Given a multiset {MS}MS and {q}q operations. {MS}MS is empty initailly, and operations are in three types, wh原创 2020-07-14 22:55:03 · 272 阅读 · 0 评论 -
Atcoder-AIsing Programming Contest 2020-D
Anything Goes to Zero题意:给定一个二进制串,按位计算,计算每一位时,取反,得到一个二进制数,用其取余其二进制下1的个数,得到结果,再执行同样的取余步骤,直到结果为0,输出所需的步数。做法:每一位取反,在二进制下1的个数,就是整体串中1的个数加一或减一,先预处理出不取反时的结果,然后每一位判断,加上或减去该位的变化,计算结果即可。简单来说就是:先这样,再这样,然后这样,最后输出就好了。切记快速幂时,数据类型定义为longlong,不然就会乘炸了(因题而定)。比赛时没开long原创 2020-07-12 22:26:44 · 199 阅读 · 0 评论 -
牛客练习赛60-D
比赛的时候没有做出来,今天补题的时候看了大佬的代码,也不至于太难理解,但当时就是没想出来,只能说大佬牛逼。K取余C,余下的部分用A和B补。先预处理出X个A取余C的所以情况,每种情况各需要几个A,B同样预处理出来,然后让X个A和Y个B取余C的余数凑出K取余C的余数即可。#include<bits/stdc++.h>using namespace std;typedef long ...原创 2020-03-28 11:55:51 · 201 阅读 · 0 评论 -
Codeforces-1323D
D. PresentCatherine received an array of integers as a gift for March 8. Eventually she grew bored with it, and she started calculated various useless characteristics for it. She succeeded to do it f...原创 2020-03-09 19:38:35 · 283 阅读 · 0 评论 -
AcWing-244.谜一样的牛
题解:从后往前依次判断牛的高度,当前牛之前有a个牛比它低,则当前牛的最低身高为a+1,所以当前牛的高度为所有牛的第a+1低,然后二分判断当前所有牛中第a+1,低的牛身高为多少,当前每头牛被选走之后,记录一下。用树状数组维护牛身高的序列,前缀和求第几高,当牛被选走之后,该身高位置减一即可。#include<stdio.h>#include<algorithm>us...原创 2020-01-04 19:59:59 · 269 阅读 · 0 评论 -
HDU - 5573
Binary TreeThe Old Frog King lives on the root of an infinite tree. According to the law, each node should connect to exactly two nodes on the next level, forming a full binary tree.Since the king i...原创 2019-12-29 11:47:15 · 153 阅读 · 0 评论 -
CodeForces - 1227D2(树状数组)
D2. Optimal Subsequences (Hard Version)This is the harder version of the problem. In this version, 1≤n,m≤2⋅105. You can hack this problem if you locked it. But you can hack the previous problem only ...原创 2019-12-27 17:53:05 · 275 阅读 · 0 评论 -
CodeForces - 1269
A. EquationLet’s call a positive integer composite if it has at least one divisor other than 1 and itself. For example:the following numbers are composite: 1024, 4, 6, 9;the following numbers are n...原创 2019-12-22 10:39:38 · 439 阅读 · 0 评论 -
CodeForces - 1266D
Decreasing DebtsThere are n people in this world, conveniently numbered 1 through n. They are using burles to buy goods and services. Occasionally, a person might not have enough currency to buy what...原创 2019-12-19 21:04:13 · 229 阅读 · 0 评论 -
CodeForces - 915C(DFS)
You are given two positive integer numbers a and b. Permute (change order) of the digits of a to construct maximal number not exceeding b. No number in input and/or output can start with the digit 0....原创 2019-11-26 20:46:46 · 182 阅读 · 0 评论 -
CodeForces - 1255E1
E1. Send Boxes to Alice (Easy Version)This is the easier version of the problem. In this version, 1≤n≤105 and 0≤ai≤1. You can hack this problem only if you solve and lock both problems.Christmas is ...原创 2019-11-21 15:47:54 · 183 阅读 · 0 评论 -
CodeForces - 1255C
Bob is an avid fan of the video game “League of Leesins”, and today he celebrates as the League of Leesins World Championship comes to an end!The tournament consisted of n (n≥5) teams around the worl...原创 2019-11-20 15:58:55 · 295 阅读 · 0 评论 -
CodeForces - 1228B
题目链接:https://codeforces.com/problemset/problem/1228/B题意就不写了。好久之前写过的一道题,大概有两个月了,今天看到韬哥在写,本想装一波教他一下,但是一上手就发现已经忘干净不会写了,赶紧再看了一遍之前的代码,现在又懂了,写一篇博客记录一下。开两个数组记录下行和列的值,然后两层循环依次判断每个位置,如果当前的位置行和列序号不影响原图,也就是当前...原创 2019-11-20 11:19:53 · 220 阅读 · 0 评论 -
CodeForces - 798C
Mike has a sequence A = [a1, a2, …, an] of length n. He considers the sequence B = [b1, b2, …, bn] beautiful if the gcd of all its elements is bigger than 1, i.e. .Mike wants to change his sequence i...原创 2019-11-11 22:19:35 · 115 阅读 · 0 评论 -
CodeForces - 1247C
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer p (which may be positive, negative, or zero). To co...原创 2019-10-27 16:14:55 · 188 阅读 · 0 评论