http://codeforces.com/contest/624

A.python是用来写div2的AB题的...

 a, b, x, y = map(float, raw_input().split())
print ((b - a) / (x + y))

B.思路很简单,但你的实现一样简短吗

 n = input()
a = sorted(map(int, raw_input().split()))
s = 0
x = 10 ** 9
while a and x:
x = min(x, a.pop())
s += x
x -= 1
print s

C.注意到只有abc三种字符

b是和abc都相邻的!就很ok!

跟n-1个都相邻的肯定涂b

然后随便选个连b的涂成a再dfs

剩下的涂c最后检验就行

 import java.util.Scanner;

 public class C {
static int[][] g = new int[505][505];
static char[] s = new char[505];
static int n;
static void dfs(int x) {
s[x] = 'a';
for(int i = 1;i <= n;i ++)
if(g[x][i] == 1 && s[i] == 0)
dfs(i);
}
public static void main(String []args) {
Scanner cin = new Scanner(System.in);
n = cin.nextInt();
int m = cin.nextInt();
int[] u = new int[130005];
int[] v = new int[130005];
int[] c = new int[505];
for(int i = 1;i <= m;i ++) {
u[i] = cin.nextInt();
v[i] = cin.nextInt();
g[u[i]][v[i]] = 1;
g[v[i]][u[i]] = 1;
c[u[i]] ++;
c[v[i]] ++;
}
boolean ok = false;
for(int i = 1;i <= n;i ++)
if(c[i] == n - 1) {
s[i] = 'b';
ok = true;
}
if(!ok) dfs(1);
else {
for(int i = 1;i <= n;i ++) {
if(s[u[i]] == s[v[i]] && s[u[i]] == 'b') continue;
if(s[u[i]] == 'b' || s[v[i]] == 'b') {
if(s[u[i]] == 'b') dfs(v[i]);
else dfs(u[i]);
break;
}
}
}
for(int i = 1;i <= n;i ++)
if(s[i] == 0)
s[i] = 'c';
for(int i = 1;i <= n;i ++)
for(int j = i + 1;j <= n;j ++) {
boolean x = (g[i][j] != 0);
boolean y = (s[i] == s[j] || s[i] - s[j] == 1 || s[j] - s[i] == 1);
if(x ^ y) {
System.out.println("No");
System.exit(0);
}
}
System.out.println("Yes");
for(int i = 1;i <= n;i ++)
System.out.print(s[i]);
}
}

注意也可能没有b,就选第一个点涂a,dfs下去就行了

D.显然a1,a1 + 1, a1 - 1, an, an + 1, an - 1

这六个数在最后的数列里至少出现了一个

最后数列的gcd肯定在这个数里...然后枚举这个gcd

开始DP,f[0/1/2][i]代表到第i个位置还没开始remove/正在remove/已经结束remove的最小代价

状态说清了,转移方程想一想咯

 #include <bits/stdc++.h>

 using namespace std;

 const int maxn = ;

 typedef long long ll;

 int n, a, b, c[maxn], v[maxn];

 ll f[][maxn], ans = 1e18;

 void dp(int x) {
memset(f, 0x3f3f3f3f, sizeof f);
f[][] = f[][] = f[][] = ;
for(int i = ;i <= n;i ++) {
if(c[i] % x == || c[i] % x == || c[i] % x == x - ) {
f[][i] = f[][i - ] + b * (c[i] % x != );
f[][i] = f[][i - ] + b * (c[i] % x != );
}
f[][i] = min(f[][i - ], f[][i - ]) + a;
f[][i] = min(f[][i], f[][i]);
if(f[][i] >= ans && f[][i] >= ans) return;
}
ans = min(min(f[][n], f[][n]), ans);
} void solve(int x) {
for(int i = ;i * i <= x;i ++)
if(x % i == ) {
if(!v[i]) dp(i);
v[i] = ;
while(x % i == ) x /= i;
}
if(x != ) dp(x);
} int main() {
scanf("%d %d %d", &n, &a, &b);
for(int i = ;i <= n;i ++)
scanf("%d", &c[i]);
solve(c[]), solve(c[] - ), solve(c[] + );
solve(c[n]), solve(c[n] - ), solve(c[n] + );
printf("%lld\n", ans);
return ;
}

AIM Tech Round (Div. 2)——ABCD的更多相关文章

  1. AIM Tech Round (Div. 1) D. Birthday 数学 暴力

    D. Birthday 题目连接: http://www.codeforces.com/contest/623/problem/D Description A MIPT student named M ...

  2. AIM Tech Round (Div. 2) D. Array GCD dp

    D. Array GCD 题目连接: http://codeforces.com/contest/624/problem/D Description You are given array ai of ...

  3. AIM Tech Round (Div. 2) C. Graph and String 二分图染色

    C. Graph and String 题目连接: http://codeforces.com/contest/624/problem/C Description One day student Va ...

  4. AIM Tech Round (Div. 2) B. Making a String 贪心

    B. Making a String 题目连接: http://codeforces.com/contest/624/problem/B Description You are given an al ...

  5. AIM Tech Round (Div. 2) A. Save Luke 水题

    A. Save Luke 题目连接: http://codeforces.com/contest/624/problem/A Description Luke Skywalker got locked ...

  6. Codeforces AIM Tech Round (Div. 2)

    这是我第一次完整地参加codeforces的比赛! 成绩 news standings中第50. 我觉这个成绩不太好.我前半小时就过了前三题,但后面的两题不难,却乱搞了1.5h都没有什么结果,然后在等 ...

  7. AIM Tech Round (Div. 2) B

    B. Making a String time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  8. AIM Tech Round (Div. 2) A

    A. Save Luke time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  9. AIM Tech Round (Div. 1) C. Electric Charges 二分

    C. Electric Charges 题目连接: http://www.codeforces.com/contest/623/problem/C Description Programmer Sas ...

随机推荐

  1. Vue相关开源项目库汇总 http://www.opendigg.com/tags/front-vue

    awesome-github-vue 是由OpenDigg整理并维护的Vue相关开源项目库集合.我们会定期同步OpenDigg上的项目到这里,也欢迎各位提交项目给我们. 如果收录的项目有错误,可以通过 ...

  2. JZOJ 1003 [ 东莞市选 2007 ] 拦截导弹 —— 递推

    题目:https://jzoj.net/senior/#main/show/1003 n^2 的话递推就可以啦. 代码如下: #include<iostream> #include< ...

  3. P2258 子矩阵(dp)

    P2258 子矩阵 题目描述 给出如下定义: 子矩阵:从一个矩阵当中选取某些行和某些列交叉位置所组成的新矩阵(保持行与列的相对顺序)被称为原矩阵的一个子矩阵. 例如,下面左图中选取第2.4行和第2.4 ...

  4. VUE移动端禁止双手放大缩小

    //index.html <meta name="viewport" content="width=device-width,initial-scale=1.0,u ...

  5. python自动化测试学习笔记-5常用模块

    上一次学习了os模块,sys模块,json模块,random模块,string模块,time模块,hashlib模块,今天继续学习以下的常用模块: 1.datetime模块 2.pymysql模块(3 ...

  6. 传值:web.xml传递参数 即在Servlet中获取web.xml里的值

    传值:web.xml传递参数 在web.xml中的Servlet里配置多个init-param <servlet> ... <init-param> <param-nam ...

  7. Linux下查看CPU和内存(很详细)

    在系统维护的过程中,随时可能有需要查看 CPU 使用率,并根据相应信息分析系统状况的需要.在 CentOS 中,可以通过 top 命令来查看 CPU 使用状况.运行 top 命令后,CPU 使用状态会 ...

  8. NHibernate学习(零)-本次学习遇到的错误汇总

    问题一: "System.TypeInitializationException"类型的未经处理的异常在 KimismeDemo.exe 中发生 其他信息: "NHibe ...

  9. java_基础知识_字符串练习题_计算两个字符串的最长公共字串长度

    package tek; Java算法——求出两个字符串的最长公共字符串 /** * @Title: 问题:有两个字符串str1和str2,求出两个字符串中最长公共字符串. * @author 匹夫( ...

  10. android黑科技系列——解析公众号文章消息和链接文章消息自动打开原理

    一.辅助功能方案分析 关于WX的各种功能插件已经非常普遍了,而现在的插件都是依赖于Xposed框架进行的,所以个人觉得WX应该在这方便应对Xposed框架的使用防护,防止插件满天飞的现象,本文来介绍一 ...