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 有边且编号大于的点。

#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的更多相关文章

  1. 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 ...

  2. 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) ...

  3. 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 ...

  4. 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 ...

  5. 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 ( ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

  10. 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 ...

随机推荐

  1. Composition or inheritance for delegating page methods?

    引用链接:http://watirmelon.com/2011/01/24/composition-or-inheritance-for-delegating-page-methods/ Compos ...

  2. GitHub上易于高效开发的Android开源项目TOP20--适合新手

    1. android-async-http android-async-http是Android上的一个异步.基于回调的HTTP客户端开发包,建立在Apache的HttpClient库上. 2. an ...

  3. 【踩坑】socket.io服务器不能访问

    今天在单机测试socket.io服务器时一切正常,但用jar包的方式部署在服务器时发现客户端无法连接. 于是做了一系列排查,如检查端口是否在占用,防火墙有没有开放该端口,阿里云终端是否有开放安全组,本 ...

  4. css盒子模型 css3盒子相关样式

    1.内边距(内边距在content外,边框内) 内边距属性: padding          设置所有边距 padding-bottom     底边距 padding-left           ...

  5. 方法和函数,isinstance/issubclass/type以及反射

    一丶,isinstance/issubclass/type 1.issubclass检查第一个参数是否是第二个参数的 子子孙孙类 class Foo(): pass class Boo(Foo): p ...

  6. 关于Vue生命周期的小记录

    1.created的时候才能获取到data中的属性和methods中的方法 2.特殊情况:beforeCreate中如果是进行了ajax请求,在请求回调中对属性赋值是可以的,因为页面渲染速度比ajax ...

  7. LeetCode Valid Anagram (简单题)

    题意: 给出两个字符串s和t,判断串t是否为s打乱后的串. 思路: 如果返回的是true,则两个串的长度必定相等,所有字符出现的次数一样.那么可以统计26个字母的次数来解决,复杂度O(n).也可以排序 ...

  8. VMware NAT端口映射外网访问虚拟机linux可能会出现的错误总结

    博主因为做实验报告的缘故,尝试以NAT的方式从外网远程连接到虚拟机的linux操作系统:https://www.cnblogs.com/jluzhsai/p/3656760.html,本文主要举出在此 ...

  9. fetch用法说明

    语法说明 fetch(url, options).then(function(response) { // handle HTTP response }, function(error) { // h ...

  10. 闭包 -------JavaScript

    本文摘要:http://www.liaoxuefeng.com/ 函数作为返回值 高阶函数除了可以接受函数作为参数外,还可以把函数作为结果值返回. 我们来实现一个对Array的求和.通常情况下,求和的 ...