【玲珑杯Round17】xjb总结
zcy真是垃圾,啥都不会的那种。
菜的不行。
这场手速上了三题,然后各种E被卡……
日个吗居然E不开栈,傻逼吧
有毒吧
来看题:
A.sqc给的我的神奇公式,gtmd居然能A?
#include<bits/stdc++.h>
using namespace std;
int n;double ans=;
int main(){
scanf("%d",&n);
for(int i=;i<n-;i++){
int j=(n-i)/,k=(n-i)-(n-i)/;
ans=max(ans,sin(i)+sin(j)+sin(k));
}
printf("%.9lf\n",ans);
}
B.小学生容斥,2^m次系列。
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
using namespace std;
typedef long long ll;
#define N 2
const int maxn=;
const int L=<<;
int a[maxn],T,n,m;ll f[L];int bin[L];
ll gcd(ll n,ll m){
return m?gcd(m,n%m):n;
}
inline ll lcm(ll n,ll m){return n/gcd(n,m)*m;}
void dfs(int stp,int s,ll w){
if (w>n) return ;
if (stp>m) {f[s]+=n/w;return ;}
dfs(stp+,s<<,w);
dfs(stp+,s<<|,lcm(w,a[stp]));
}
int main(){ for (int i=;i<L;i++) bin[i]=bin[i>>]+(i&);
for (scanf("%d",&T);T--;) {
memset(f,,sizeof f);
scanf("%d %d",&n,&m);
for (int i=;i<=m;i++) scanf("%d",&a[i]);
dfs(,,);ll ans=;
for (int j=;j<m;j++)
for (int i=;i<(<<m);i++)
if (((i>>j)&)==) f[i]-=f[i+(<<j)];
for (int i=;i<(<<m);i++)
if (bin[i]&) ans+=f[i];
printf("%lld\n",ans);
}
return ;
}
剩下就一堆不会……
Ctm烦得跟什么一样,Etm卡空间卡常数,还狗日的不开栈。
D裸FFT算下。
#include<bits/stdc++.h>
#define N 1000005
typedef long long ll;
using namespace std;
const double pi=acos(-);
struct E{
double x,y;
E (double x=,double y=):x(x),y(y){}
}a[N];
E operator+(const E &a,const E &b){return E(a.x+b.x,a.y+b.y);}
E operator-(const E &a,const E &b){return E(a.x-b.x,a.y-b.y);}
E operator*(const E &a,const E &b){return E(a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x);}
int n,m,l,q,L,nmax;
int r[N],c[N];ll ans[N];
void FFT(E *x,int k){
for (int i=;i<n;i++) if (i<r[i]) swap(x[i],x[r[i]]);
for (int i=;i<n;i<<=){
E wn(cos(pi/i),sin(pi*k/i));
for (int j=;j<n;j+=(i<<)){
E w(,),l,r;
for (int p=j;p<j+i;p++,w=w*wn){
l=x[p],r=x[p+i];
x[p]=l+w*r;
x[p+i]=l-w*r;
}
}
}
if (k==-) for (int i=;i<=n;i++) x[i].x/=n;
}
inline int read(){
int f=,x=;char ch;
do{ch=getchar();if(ch=='-')f=-;}while(ch<''||ch>'');
do{x=x*+ch-'';ch=getchar();}while(ch>=''&&ch<='');
return f*x;
}
int main(){
int T=read();
while(T--){
n=read();q=read();m=n;nmax=;L=;
memset(ans,,sizeof(ans));memset(a,,sizeof(a));
for(int i=;i<=m;i++)c[i]=read(),nmax=max(n,c[i]),a[c[i]].x++;
nmax*=;for (n=;n<=nmax;n<<=,L++);
for(int i=;i<n;i++)r[i]=(r[i>>]>>)|((i&)<<(L-));
FFT(a,);
for(int i=;i<=n;i++)a[i]=a[i]*a[i];
FFT(a,-);
for(int i=;i<=n;i++)ans[i]=(ll)(a[i].x+0.5);
for(int i=;i<=m;i++)ans[c[i]*]--;
for(int i=;i<=n;i++)ans[i]>>=;
for(int i=n;i>=;i--)ans[i]+=ans[i+];
for(int i=;i<=q;i++){
int k=read();printf("%lld\n",ans[k]);
}
}
}
好气啊,要是知道开栈我就能rank1了
巨气。
【玲珑杯Round17】xjb总结的更多相关文章
- 程设大作业xjb写——魔方复原
鸽了那么久总算期中过[爆]去[炸]了...该是时候写写大作业了 [总不能丢给他们不会写的来做吧 一.三阶魔方的几个基本定义 ↑就像这样,可以定义面的称呼:上U下D左L右R前F后B UD之间的叫E,LR ...
- hdu_5881_Tea(xjb猜)
题目链接:hdu_5881_Tea 题意: 有一壶水, 体积在 L 和 R 之间, 有两个杯子, 你要把水倒到两个杯子里面, 使得杯子水体积几乎相同(体积的差值小于等于1), 并且使得壶里剩下水体积不 ...
- hdu_5873_Football Games(xjb搞)
题目链接:hdu_5873_Football Games 题意: 有n个队,每个队都会给其他队打一场,赢一场得2分,平局得一分,输了不得分,然后给你全部比赛结束后的得分,问你是否有假分 题解: 可以知 ...
- hdu_5761_Rower Bo(xjb猜公式)
题目链接:hdu_5761_Rower Bo 题意: 让你求一个物理问题 题解: xjb猜公式,由题目样例可得,答案为8/7,然后我们可以xjb猜出公式为v1*a/(v1*v1-v2*v2),然后特判 ...
- “玲珑杯”ACM比赛 Round #12题解&源码
我能说我比较傻么!就只能做一道签到题,没办法,我就先写下A题的题解&源码吧,日后补上剩余题的题解&源码吧! A ...
- “玲珑杯”ACM比赛 Round #19题解&源码【A,规律,B,二分,C,牛顿迭代法,D,平衡树,E,概率dp】
A -- simple math problem Time Limit:2s Memory Limit:128MByte Submissions:1599Solved:270 SAMPLE INPUT ...
- “玲珑杯”ACM比赛 Round #19 B -- Buildings (RMQ + 二分)
“玲珑杯”ACM比赛 Round #19 Start Time:2017-07-29 14:00:00 End Time:2017-07-29 16:30:00 Refresh Time:2017-0 ...
- “玲珑杯”ACM比赛 Round #1
Start Time:2016-08-20 13:00:00 End Time:2016-08-20 18:00:00 Refresh Time:2017-11-12 19:51:52 Public ...
- 玲珑杯”ACM比赛 Round #15
手速狗从西安回来一只浑浑噩噩,好不容易迎来一场送饭比赛体验一把河南的优势,结果被高中生狂虐,无缘奖金..我的奖品梦就这样一次次被打破.... A -- Reverse the lights 最后半小时 ...
随机推荐
- Python字符串的简单操作
数据的操作 字符串的一些常用操作: 1 1 #!/usr/bin/env python 2 # #coding=utf-8 3 # 4 # test='hello world' 5 # print(t ...
- hdu 1848(Fibonacci again and again)(SG博弈)
Fibonacci again and again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Jav ...
- POJ3977:Subset——题解(三分+折半搜索)
http://poj.org/problem?id=3977 题目大意:有一堆数,取出一些数,记他们和的绝对值为w,取的个数为n,求在w最小的情况下,n最小,并输出w,n. ————————————— ...
- BZOJ4518:[SDOI2016]征途——题解
https://www.lydsy.com/JudgeOnline/problem.php?id=4518 https://www.luogu.org/problemnew/show/P4072 Pi ...
- [Leetcode] Construct binary tree from inorder and postorder travesal 利用中序和后续遍历构造二叉树
Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume th ...
- UVA.10474 Where is the Marble ( 排序 二分查找 )
UVA.10474 Where is the Marble ( 排序 二分查找 ) 题意分析 大水题一道.排序好找到第一个目标数字的位置,返回其下标即可.暴力可过,强行写了一发BS,发现错误百出.应了 ...
- github clone 指定的tag
git clone --branch [tags标签] [git地址] 使用branch参数,后面加上tag标签,最后是git仓库的地址
- spring的RestTemplate使用指南
前言:现在restful接口越来越广泛,而如今很多接口摒弃了传统的配置复杂的webService开发模式,在java领域只需要很简单的springMvc就可以声明为一个控制器,再加上service层, ...
- poco普通线程
#include "Poco/Thread.h" #include "Poco/RunnableAdapter.h" #include <iostream ...
- HDU 5249 离线树状数组求第k大+离散化
KPI Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...