A - Thickest Burger

水。

 #include <bits/stdc++.h>
using namespace std; int t;
int a, b; int main()
{
scanf("%d" ,&t);
while (t--)
{
scanf("%d%d", &a, &b);
if (a > b) swap(a, b);
printf("%d\n", a + b * );
}
return ;
}

B - Relative atomic mass

水。

 #include <bits/stdc++.h>
using namespace std; int t;
char s[]; int main()
{
scanf("%d", &t);
while (t--)
{
scanf("%s", s);
int res = ;
for (int i = , len = strlen(s); i < len; ++i)
{
if (s[i] == 'H') res += ;
if (s[i] == 'C') res += ;
if (s[i] == 'O') res += ;
}
printf("%d\n", res);
}
return ;
}

C - Recursive sequence

题意:求$F[n] = F[n - 1] + 2 \cdot F[n - 2] + n^4$

思路:考虑

$n^4 = (n - 1)^4 + 4 \cdot (n - 1) ^ 3 + 6 \cdot (n - 1) ^2 + 4 \cdot (n - 1) ^ 2 + (n - 1) + 1$

然后进行递推即可

 #include <bits/stdc++.h>
using namespace std; #define ll long long const ll MOD = ; int t;
ll n, a, b; struct node
{
ll a[][];
node () { memset(a, , sizeof a); }
node operator * (const node &r) const
{
node ans = node();
for (int i = ; i < ; ++i) for (int j = ; j < ; ++j) for (int k = ; k < ; ++k)
ans.a[i][j] = (ans.a[i][j] + a[i][k] * r.a[k][j] % MOD) % MOD;
return ans;
}
}; ll tmp[][] =
{
, , , , , , ,
, , , , , , ,
, , , , , , ,
, , , , , , ,
, , , , , , ,
, , , , , , ,
, , , , , , ,
}; ll tmp2[] =
{
, , , , , , ,
}; node qmod(ll n)
{
node base = node();
for (int i = ; i < ; ++i) for (int j = ; j < ; ++j)
base.a[i][j] = tmp[i][j];
node res = node();
for (int i = ; i < ; ++i) res.a[][i] = tmp2[i];
while (n)
{
if (n & ) res = res * base;
base = base * base;
n >>= ;
}
return res;
} int main()
{
scanf("%d", &t);
while (t--)
{
scanf("%lld%lld%lld", &n, &a, &b);
if (n == ) printf("%lld\n", a);
else if (n == ) printf("%lld\n", b);
else
{
tmp2[] = b; tmp2[] = a;
printf("%lld\n", qmod(n - ).a[][]);
}
}
return ;
}

D - Winning an Auction

留坑。

E - Counting Cliques

题意:给出n个点,m条边,求点集大小为S的完全图个数

思路:以每个点为起点搜有多少完全图

 #include<bits/stdc++.h>

 using namespace std;

 const int maxn = 1e2 + ;

 int n, m, s;
int ans;
int arr[maxn], tot;
int mp[maxn][maxn];
vector<int>G[maxn]; void Init(int N)
{
ans = ;
for(int i = ; i <= N; ++i)
{
G[i].clear();
mp[i][i] = ;
for(int j = i + ; j <= N; ++j)
{
mp[i][j] = mp[j][i] = ;
}
}
} void DFS(int u, int cnt)
{
if(cnt == s)
{
++ans;
return ;
}
for(auto it: G[u])
{
bool flag = true;
for(int i = ; i < tot; ++i)
{
if(!mp[arr[i]][it])
{
flag = false;
break;
}
}
if(flag)
{
arr[tot++] = it;
DFS(it, cnt + );
tot--;
}
}
} int main()
{
int t;
scanf("%d", &t);
while(t--)
{
scanf("%d %d %d", &n, &m, &s);
Init(n);
for(int i = ; i <= m; ++i)
{
int u, v;
scanf("%d %d", &u, &v);
G[u].push_back(v);
mp[u][v] = mp[v][u] = ;
}
for(int i = ; i <= n; ++i)
{
tot = ;
arr[tot++] = i;
DFS(i, );
}
printf("%d\n", ans);
}
return ;
}

G - Do not pour out

题意:有一个底部为直径为2的圆,高度为2的桶,现在里面有高度为h的液体,将桶倾斜至最大,求上表面面积

思路:分类,若经过没经过底部则为PI / cos(2.0-d)

否则二分+积分求面积

 #include<bits/stdc++.h>

 using namespace std;

 const double eps = 1e-;
const double PI = acos(-1.0); int sgn(double x)
{
if(fabs(x) < eps) return ;
else return x > ? : -;
} double d; double calc(double arc)
{
return PI * cos(arc) - arc * cos(arc) + sin(arc) - sin(arc) * sin(arc) * sin(arc) / 3.0;
} int check(double mid)
{
double tmp = (calc(acos(2.0 * tan(mid) - 1.0)) - calc(PI)) / tan(mid);
return sgn(tmp - d * PI);
} double get(double l, double r)
{
if(check(l) == ) return l;
int cnt = ;
while(cnt--)
{
double mid = (l + r) / 2.0;
int tmp = check(mid);
if(tmp == ) return mid;
if(tmp == ) r = mid;
if(tmp == -) l = mid;
}
return l;
} int main()
{
int t;
scanf("%d", &t);
while(t--)
{
scanf("%lf", &d);
if(sgn(d) == )
{
printf("0.00000\n");
}
else if(sgn(d - ) > )
{
double arc = atan(2.0 - d);
double ans = PI / cos(arc);
printf("%.5f\n", ans);
}
else
{
double tmp = get(eps, PI / 4.0);
double t1 = 2.0 * tan(tmp) - 1.0;
double arc = acos(t1);
double ans = PI - arc + cos(arc) * sin(arc);
ans = ans / sin(tmp);
printf("%.5f\n", ans);
}
}
return ;
}

H - Guessing the Dice Roll

留坑。

I - The Elder

题意:给出一棵树,每个点到根节点1的方式可以是连续走,也可以经过一个点消耗时间p,使得重新计算所经过路径,求每个点到根节点最小的最大时间   时间为$L^2$

思路:考虑朴素的转移 $F[i] = min(F[j] + p + (sum[i] - sum[j]) ^ 2) (j 为 i 的祖先们)$

拆分式子

$F[i] = F[j] + p + {sum[i]} ^ 2 - 2 \cdot sum[i] \cdot sum[j] + {sum[j]} ^ 2$

$F[j] = F[i] + 2 \cdot sum[i] \cdot sum[j] - p - {sum[i]} ^ 2 - {sum[j]} ^ 2$

考虑斜率优化

树上的单调队列优化可以通过标记最后一个更改的值,然后还原(XHT)

 #include<bits/stdc++.h>

 using namespace std;

 typedef long long ll;

 const int maxn = 1e5 + ;

 struct Edge{
int to, nxt;
ll w;
Edge(){}
Edge(int to, int nxt, ll w): to(to), nxt(nxt), w(w){}
}edge[maxn << ]; ll ans;
ll dis[maxn];
ll dp[maxn];
int n, p;
int que[maxn];
int head[maxn], tot; void Init(int N)
{
for(int i = ; i <= N; ++i) head[i] = -;
tot = ans = ;
} void addedge(int u, int v, ll w)
{
edge[tot] = Edge(v, head[u], w);
head[u] = tot++;
} ll dy(int j, int k)
{
return dp[j] - dp[k] + dis[j] * dis[j] - dis[k] * dis[k];
} ll dx(int j, int k)
{
return * (dis[j] - dis[k]);
} void DFS(int u, int fa, int l, int r)
{
int remind = -; if(u != )
{
while(l < r && dy(que[l + ], que[l]) <= dis[u] * dx(que[l + ], que[l])) l++;
// cout << u << " " << que[l] << " " << dp[que[l]] + p + (dis[u] - dis[que[l]]) * (dis[u] - dis[que[l]]) << endl;
dp[u] = min(dis[u] * dis[u], dp[que[l]] + p + (dis[u] - dis[que[l]]) * (dis[u] - dis[que[l]]));
while(l < r && dy(que[r], que[r - ]) * dx(u, que[r]) >= dy(u, que[r]) * dx(que[r], que[r - ])) r--;
remind = que[++r];
que[r] = u;
} ans = max(ans, dp[u]); for(int i = head[u]; ~i; i = edge[i].nxt)
{
int v = edge[i].to;
if(v == fa) continue;
dis[v] = dis[u] + edge[i].w;
DFS(v, u, l, r);
} if(remind != -) que[r] = remind;
} int main()
{
int t;
scanf("%d", &t);
while(t--)
{
scanf("%d %d", &n, &p);
Init(n);
for(int i = ; i < n; ++i)
{
int u, v, w;
scanf("%d %d %d", &u, &v ,&w);
addedge(u, v, w);
addedge(v, u, w);
}
DFS(, -, , );
// for(int i = 1; i <= n; ++i) cout << i << " " << dp[i] << endl;
printf("%lld\n", ans);
}
return ;
}

J - Query on a graph

留坑。

K - New Signal Decomposition

留坑。

L - A Random Turn Connection Game

留坑。

M - Subsequence

留坑。

2016ACM/ICPC亚洲区沈阳站 Solution的更多相关文章

  1. HDU 5950 Recursive sequence 【递推+矩阵快速幂】 (2016ACM/ICPC亚洲区沈阳站)

    Recursive sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Other ...

  2. HDU 5952 Counting Cliques 【DFS+剪枝】 (2016ACM/ICPC亚洲区沈阳站)

    Counting Cliques Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  3. HDU 5948 Thickest Burger 【模拟】 (2016ACM/ICPC亚洲区沈阳站)

    Thickest Burger Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  4. HDU 5949 Relative atomic mass 【模拟】 (2016ACM/ICPC亚洲区沈阳站)

    Relative atomic mass Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Oth ...

  5. 2016ACM/ICPC亚洲区沈阳站-重现赛赛题

    今天做的沈阳站重现赛,自己还是太水,只做出两道签到题,另外两道看懂题意了,但是也没能做出来. 1. Thickest Burger Time Limit: 2000/1000 MS (Java/Oth ...

  6. 2016ACM/ICPC亚洲区沈阳站 - A/B/C/E/G/H/I - (Undone)

    链接:传送门 A - Thickest Burger - [签到水题] ACM ICPC is launching a thick burger. The thickness (or the heig ...

  7. 2016ACM/ICPC亚洲区沈阳站-重现赛

    C.Recursive sequence 求ans(x),ans(1)=a,ans(2)=b,ans(n)=ans(n-2)*2+ans(n-1)+n^4 如果直接就去解...很难,毕竟不是那种可以直 ...

  8. HDU 5950 - Recursive sequence - [矩阵快速幂加速递推][2016ACM/ICPC亚洲区沈阳站 Problem C]

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5950 Farmer John likes to play mathematics games with ...

  9. HDU 5954 - Do not pour out - [积分+二分][2016ACM/ICPC亚洲区沈阳站 Problem G]

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5954 Problem DescriptionYou have got a cylindrical cu ...

随机推荐

  1. mysql中根据一个字段相同记录写递增序号,如序号结果,如何实现?

      mysql中根据一个字段相同记录写递增序号,如序号结果,如何实现? mysql中实现方式如下: select merchantId, NameCn, send_date, deliver_name ...

  2. Spring学习笔记--自动装配Bean属性

    Spring提供了四种类型的自动装配策略: byName – 把与Bean的属性具有相同名字(或者ID)的其他Bean自动装配到Bean的对应属性中. byType – 把与Bean的属性具有相同类型 ...

  3. whistle--全新的跨平台web调试工具

    版权声明:本文由吴文斌原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/151 来源:腾云阁 https://www.qclo ...

  4. hibernate实现有两种配置,xml配置与注释配置。<转>

    <注意:在配置时hibernate的下载的版本一定确保正确,因为不同版本导入的jar包可能不一样,所以会导致出现一些错误> hibernate实现有两种配置,xml配置与注释配置. (1) ...

  5. Maven入门指南(一)

    Maven介绍: Maven是一个强大的Java项目构建工具. 什么是构建工具? 构建工具是将软件项目构建相关的过程自动化的工具.构建一个软件项目通常包含以下一个或多个过程: 生成源码(如果项目使用自 ...

  6. SHTML 教程

    什么是 SHTML 使用SSI(Server Side Include)的html文件扩展名,SSI(Server Side Include),通常称为“服务器端嵌入”或者叫“服务器端包含”,是一种类 ...

  7. tortoiseSVN如何发现和解决冲突?

    版本冲突原因: 假设A.B两个用户都在版本号为100的时候,更新了kingtuns.txt这个文件,A用户在修改完成之后提交kingtuns.txt到服务器,这个时候提交成功,这个时候kingtuns ...

  8. Swift - 触摸事件响应机制(UiView事件传递)

    import UIKit class FatherView: UIView { override func hitTest(point: CGPoint, withEvent event: UIEve ...

  9. 日志记录---log4j详解

    Apache官方项目地址 通常的日志记录的缺点是会减慢程序的运行速度,如果用普通的System.out的话影响视觉效果,另外解耦度也不好,而log4j的设计则使得日志记录变得可靠快速和可拓展性好. l ...

  10. shell中的多进程【并发】(转)

    http://bbs.51cto.com/thread-1104907-1-1.html