The 2016 ACM-ICPC Asia Shenyang Regional Contest
A. Thickest Burger
大数 × 2 + 小数
#include <cstdio>
#include <algorithm>
using namespace std; int T;
int A,B;
int main()
{
scanf("%d",&T);
for(int t=1; t<=T; t++)
{
scanf("%d%d",&A,&B);
if(A<B) swap(A,B);
printf("%d\n",A*2+B);
}
return 0;
}
B. Relative atomic mass
给定一个分子式,只包含 H C O 三种,求相对分子质量。
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=15; char s[maxn];
int T, ans = 0;
int main()
{
scanf("%d",&T);
for(int t=1; t<=T; t++)
{
ans=0;
scanf("%s",s);
int n=strlen(s);
for(int i=0; i<n; i++)
{
if(s[i]=='H') ans++;
if(s[i]=='C') ans+=12;
if(s[i]=='O') ans+=16;
}
printf("%d\n",ans);
}
return 0;
}
C. Recursive sequence
矩阵快速幂
#include <bits/stdc++.h>
using namespace std; typedef long long LL;
const LL MOD = 2147493647;
int a, b;
LL C[7][7]; void mut(LL A[][7], LL B[][7]) {
memset(C, 0, sizeof(C));
for(int i = 0; i < 7; ++i)
for(int j = 0; j < 7; ++j)
for(int k = 0; k < 7; ++k)
C[i][j] = ( C[i][j] + A[i][k] * B[k][j] ) % MOD;
memcpy(A, C, sizeof(C));
} LL qpow(int n) {
LL aa[7][7] = {{1,2,1,0,0,0,0},{1,0,0,0,0,0,0},{0,0,1,4,6,4,1},{0,0,0,1,3,3,1},{0,0,0,0,1,2,1},{0,0,0,0,0,1,1},{0,0,0,0,0,0,1}};
LL ans[7][7] = {{1,0,0,0,0,0,0},{0,1,0,0,0,0,0},{0,0,1,0,0,0,0},{0,0,0,1,0,0,0},{0,0,0,0,1,0,0},{0,0,0,0,0,1,0},{0,0,0,0,0,0,1}};
while(n) {
if(n&1) mut(ans, aa);
mut(aa,aa);
n>>=1;
}
LL res = ans[0][0] * b % MOD + ans[0][1] * a % MOD + ans[0][2] * 3 * 3 * 3 * 3 % MOD;
res = res + ans[0][3] * 3 * 3 * 3 % MOD + ans[0][4] * 3 * 3 % MOD + ans[0][5] * 3 % MOD;
res = ( res + ans[0][6] ) % MOD;
return res;
} int main() {
int T;
scanf("%d", &T);
while(T--) {
int n;
scanf("%d%d%d", &n, &a, &b);
if(n == 1) {
printf("%d\n",a);
continue;
}
LL ans = qpow(n-2);
printf("%lld\n", ans);
}
return 0;
}
D. Winning an Auction
博弈
E. Counting Cliques
爆搜。vector[i] 记录与 i 有边且编号大于 i 的点。
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
const int maxn = 100 + 10;
const int maxm = 1000 + 100; int n, m, k;
vector<int> v[maxn];
int from[maxm], to[maxm];
int G[maxn][maxn];
int d[maxn], node[maxn];
int tot, ans; void DFS(int x, int start)
{
if (tot == k) { ++ans; return; } int sz = v[x].size();
for (int i = start; i < sz; i++)
{
int flag = 0;
for (int j = 2; j <= tot; j++)
if (!G[ node[j] ][ v[x][i] ]) { flag = 1; break; } if (flag) continue; node[++tot] = v[x][i], DFS(x, i+1), --tot;
}
} int main()
{
int t;
scanf("%d", &t);
for (int ca = 1; ca <= t; ca++)
{
memset(d, 0, sizeof(d));
for (int i = 1; i <= n; i++)
{
for (int j = i+1; j <= n; j++) G[i][j] = G[j][i] = 0;
v[i].clear();
} scanf("%d%d%d", &n, &m, &k);
for (int i = 1; i <= m; i++)
{
scanf("%d%d", &from[i], &to[i]);
d[ from[i] ]++, d[ to[i] ]++;
} for (int i = 1; i <= m; i++)
if (d[ from[i] ] >= k-1 && d[ to[i] ] >= k-1)
{
if (from[i] < to[i]) v[ from[i] ].push_back(to[i]);
else v[ to[i] ].push_back(from[i]);
G[ from[i] ][ to[i] ] = G[ to[i] ][ from[i] ] = 1;
} ans = 0;
for (int i = 1; i <= n; i++)
{
tot = 1, node[1] = i;
DFS(i, 0);
} printf("%d\n", ans);
}
}
F. Similar Rotations
G. Do not pour out
H. Guessing the Dice Roll
I. The Elder
J. Query on a graph
K. New Signal Decomposition
L. A Random Turn Connection Game
M. Subsequence
The 2016 ACM-ICPC Asia Shenyang Regional Contest的更多相关文章
- 2016 ACM/ICPC Asia Regional Shenyang Online 1003/HDU 5894 数学/组合数/逆元
hannnnah_j’s Biological Test Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K ...
- 2016 ACM/ICPC Asia Regional Shenyang Online 1009/HDU 5900 区间dp
QSC and Master Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
- 2016 ACM/ICPC Asia Regional Shenyang Online 1007/HDU 5898 数位dp
odd-even number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- 2016 ACM/ICPC Asia Regional Qingdao Online 1001/HDU5878 打表二分
I Count Two Three Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- 2016 ACM/ICPC Asia Regional Dalian Online 1002/HDU 5869
Different GCD Subarray Query Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K ( ...
- 2016 ACM/ICPC Asia Regional Dalian Online 1006 /HDU 5873
Football Games Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)To ...
- HDU 5874 Friends and Enemies 【构造】 (2016 ACM/ICPC Asia Regional Dalian Online)
Friends and Enemies Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Othe ...
- HDU 5889 Barricade 【BFS+最小割 网络流】(2016 ACM/ICPC Asia Regional Qingdao Online)
Barricade Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total S ...
- HDU 5875 Function 【倍增】 (2016 ACM/ICPC Asia Regional Dalian Online)
Function Time Limit: 7000/3500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total ...
- HDU 5873 Football Games 【模拟】 (2016 ACM/ICPC Asia Regional Dalian Online)
Football Games Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)To ...
随机推荐
- Morris.js-利用JavaScript生成时序图
morris.js是一个轻量级的时间序列javascript类库,是网页显示图表的好工具.github项目地址:点击打开,使用起来很简单,但是需要你有一点网页设计的一些基本知识,对一个网页内容的结构要 ...
- 工作中碰到的css问题解决方法
好久都没来这写东西了,都长草了.刚解决的两个小问题,先记下来 textarea横向没有滚动条加上 wrap="off"这个属性 英文单词不断行加上这个 word-break:bre ...
- 访问FTP站点下载文件,提示“当前的安全设置不允许从该位置下载文件”的解决方案
访问FTP站点下载文件,提示“当前的安全设置不允许从该位置下载文件”的解决方案: 打开客戶端浏览器--工具---internet-安全-自定义级别-选择到低到中低. 然后点受信任站点,把你要访问的站点 ...
- SAP Cloud for Customer Extensibility的设计与实现
今天的文章来自Jerry的同事,SAP成都研究院C4C开发团队的开发人员徐欢(Xu Boris).徐欢就坐我左手边的位置,因此我工作中但凡遇到C4C的技术问题,一扭头就可以请教他了,非常方便.下图是他 ...
- codeforce 599B Spongebob and Joke
一道水题WA那么多发,也是醉了.f看成函数的话,其实就是判断一下反函数存不存在. 坑点,只能在定义域内判断,也就是只判断b[i].没扫一遍前不能确定Impossible. #include<bi ...
- UVA Mega Man's Mission(状压dp)
把消灭了那些机器人作为状态S,预处理出状态S下可以消灭的机器人,转移统计方案.方案数最多16!,要用64bit保存方案. #include<bits/stdc++.h> using nam ...
- python基础一 day17 复习
# 迭代器# 生成器进阶 # 内置函数 # 55个 # 带key的 max min filter map sorted # 思维导图上红色和黄色方法必须会用 # 匿名函数 # lambda 参数,参数 ...
- 小w的糖果
题目连接 : https://ac.nowcoder.com/acm/contest/923/C 算是一道找规律的题了,因为后一个人会比前一个人多,可以理解成后一个人要继承前一个人,sum为当前糖果数 ...
- js 数组方法大集合,各方法是否改变原有的数组详解
不会改变原来数组的有: concat()---连接两个或更多的数组,并返回结果. every()---检测数组元素的每个元素是否都符合条件. some()---检测数组元素中是否有元素符合指定条件. ...
- shell脚本,利用awk计算指定范围内的和。
期望得到结果如下: vivi 42800Tom 32500John 104500 解题方法如下: 1.利用数组来进行解题.