AIM Tech Round (Div. 2)——ABCD
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的更多相关文章
- AIM Tech Round (Div. 1) D. Birthday 数学 暴力
D. Birthday 题目连接: http://www.codeforces.com/contest/623/problem/D Description A MIPT student named M ...
- 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 ...
- 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 ...
- 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 ...
- AIM Tech Round (Div. 2) A. Save Luke 水题
A. Save Luke 题目连接: http://codeforces.com/contest/624/problem/A Description Luke Skywalker got locked ...
- Codeforces AIM Tech Round (Div. 2)
这是我第一次完整地参加codeforces的比赛! 成绩 news standings中第50. 我觉这个成绩不太好.我前半小时就过了前三题,但后面的两题不难,却乱搞了1.5h都没有什么结果,然后在等 ...
- 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 ...
- 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 ...
- AIM Tech Round (Div. 1) C. Electric Charges 二分
C. Electric Charges 题目连接: http://www.codeforces.com/contest/623/problem/C Description Programmer Sas ...
随机推荐
- JSP-Runoob:JSP 异常处理
ylbtech-JSP-Runoob:JSP 异常处理 1.返回顶部 1. JSP 异常处理 当编写JSP程序的时候,程序员可能会遗漏一些BUG,这些BUG可能会出现在程序的任何地方.JSP代码中通常 ...
- js的45个技巧
JavaScript是一个绝冠全球的编程语言,可用于Web开发.移动应用开发(PhoneGap.Appcelerator).服务器端开发(Node.js和Wakanda)等等.JavaScript还是 ...
- 能力 or say 职业 规划
2019.5.8 黑盒测试,白盒测试,接口测试,自动化测试,性能测试.. 往测试工程师发展,再是测试开发,高级测试开发.. 要是真的喜欢前端,可以再转吧.前端后端应该要清楚它们的区别 前端:广度, ...
- 阿里邮箱绑定Foxmail失败的解决办法
收件服务器地址: POP 服务器地址:pop3.mxhichina.com 端口110,SSL 加密端口995 或 IMAP 服务器地址:imap.mxhichina.com 端口143,SSL 加密 ...
- Eclipse中搭建Apache Tomcat7源码调试环境
第一步:获取Apache Tomcat7源码,读者可以从Apache 官方网站获取,官方下载地址: http://tomcat.apache.org/download-70.cgi 注意选择Sourc ...
- cordova科大讯飞语音识别
cordova-plugin-IFlyspeech 科大讯飞的语音听说读写的cordova插件 Supported Platforms iOS android Installation 插件安装命令: ...
- Android基础TOP2:单机按钮改变字体颜色
---恢复内容开始--- Activity: <TextView android:id="@+id/t1" android:textSize="30dp" ...
- [Windows Server 2012] IIS自带FTP配置方法
★ 欢迎来到[护卫神·V课堂],网站地址:http://v.huweishen.com★ 护卫神·V课堂 是护卫神旗下专业提供服务器教学视频的网站,每周更新视频.★ 本节我们将带领大家:IIS自带FT ...
- 【译】x86程序员手册18-6.3.1描述符保存保护参数
6.3 Segment-Level Protection 段级保护 All five aspects of protection apply to segment translation: 段转换时会 ...
- Centos安装smokeping教程
Centos安装smokeping教程 一 .安装基本依赖包 ntpdate time.windows.com #64bit rpm -Uhv http://apt.sw.be/redhat/el6/ ...