A - Little Artem and Presents (div2)

1 2 1 2这样加就可以了

#include <bits/stdc++.h>

typedef long long ll;
const int N = 1e5 + 5; int main() {
int n; scanf ("%d", &n);
int ans = n / 3 * 2;
if (n % 3) {
ans++;
}
printf ("%d\n", ans);
return 0;
}

B - Little Artem and Grasshopper (div2)

水题,暴力模拟一下

#include <bits/stdc++.h>

typedef long long ll;
const int N = 1e5 + 5;
char str[N];
int a[N]; int main() {
int n; scanf ("%d", &n);
scanf ("%s", str);
for (int i=0; i<n; ++i) {
scanf ("%d", a+i);
}
int now = 0;
while (true) {
if (now < 0 || now >= n) {
break;
}
if (a[now] == -1) {
puts ("INFINITE");
return 0;
}
if (str[now] == '>') {
int pre = now;
now = now + a[now];
a[pre] = -1;
} else {
int pre = now;
now = now - a[now];
a[pre] = -1;
}
}
puts ("FINITE");
return 0;
}

构造 C - Little Artem and Matrix (div2)

倒过来做,循环也反着来

#include <bits/stdc++.h>

typedef long long ll;
const int N = 1e2 + 5;
const int Q = 1e4 + 5;
int a[N][N];
int t[Q], row[Q], col[Q], x[Q]; int main() {
int n, m, q; scanf ("%d%d%d", &n, &m, &q);
for (int i=1; i<=q; ++i) {
scanf ("%d", t+i);
if (t[i] == 1) {
scanf ("%d", row+i);
}
if (t[i] == 2) {
scanf ("%d", col+i);
}
if (t[i] == 3) {
scanf ("%d%d%d", row+i, col+i, x+i);
}
//printf ("%d %d %d %d\n", t[i], row[i], col[i], x[i]);
}
for (int i=q; i>=1; --i) {
if (t[i] == 1) {
int last = a[row[i]][m];
for (int j=m; j>=2; --j) {
a[row[i]][j] = a[row[i]][j-1];
}
a[row[i]][1] = last;
}
if (t[i] == 2) {
int last = a[n][col[i]];
for (int j=n; j>=2; --j) {
a[j][col[i]] = a[j-1][col[i]];
}
a[1][col[i]] = last;
}
if (t[i] == 3) {
a[row[i]][col[i]] = x[i];
}
}
for (int i=1; i<=n; ++i) {
for (int j=1; j<=m; ++j) {
printf ("%d%c", a[i][j], j == m ? '\n' : ' ');
}
}
return 0;
}

数学 D - Little Artem and Dance (div2)

题意:男生与女生围成圈跳舞,女生的位置不变,男生可以移动x个女生或者相邻的男生奇偶互换,问最后男生的排列

分析:问题的关键点在于奇数男生的圈顺序不变,偶数也不变,只是起点的位置改变,所以只要对两个起点操作就行了。

#include <bits/stdc++.h>

typedef long long ll;
const int N = 1e6 + 5;
int ans[N]; int main() {
int p0 = 0, p1 = 1;
int n, q; scanf ("%d%d", &n, &q);
for (int i=0; i<q; ++i) {
int type; scanf ("%d", &type);
if (type == 1) {
int x; scanf ("%d", &x);
p0 = (p0 + x + n) % n;
p1 = (p1 + x + n) % n;
} else {
p0 = p0 ^ 1;
p1 = p1 ^ 1;
}
}
for (int i=0; i<n; i+=2) {
ans[(p0+i)%n] = i + 1;
}
for (int i=1; i<n; i+=2) {
ans[(p1+i-1)%n] = i + 1;
}
for (int i=0; i<n; ++i) {
printf ("%d%c", ans[i], i == n-1 ? '\n' : ' ');
}
return 0;
}

数学+前(后)缀 C - Little Artem and Random Variable (div1)

题意:已知p(max(a,b)=k) 和 p(min(a,b)=k)的概率,求p(a=k) 和 p(b=k)

分析:

P(a = k) = P(a <= k) — P(a <= k-1) P(max(a, b) <= k) = P(a <= k) * P(b <= k)

P(min(a, b) >= k) = P(a >= k) * P(b >= k) = (1 — P(a <= k-1)) *(1 — P(b <= k-1))

 

解方程的,从而求得

#include <bits/stdc++.h>

const int N = 1e5 + 5;
double p[N], q[N], a[N], b[N]; int main() {
int n; scanf ("%d", &n);
for (int i=1; i<=n; ++i) {
scanf ("%lf", p+i);
p[i] += p[i-1];
}
for (int i=1; i<=n; ++i) {
scanf ("%lf", q+i);
}
for (int i=n; i>=1; --i) {
q[i] += q[i+1];
}
for (int i=1; i<=n; ++i) {
double A = p[i], B = q[i+1];
double C = B - A - 1;
double delta = sqrt (std::max (C*C - 4 * A, 0.0));
a[i] = (-C+delta) / 2;
b[i] = (-C-delta) / 2;
}
for (int i=1; i<=n; ++i) {
printf ("%.10f%c", a[i] - a[i-1], i == n ? '\n' : ' ');
}
for (int i=1; i<=n; ++i) {
printf ("%.10f%c", b[i] - b[i-1], i == n ? '\n' : ' ');
}
return 0;
}

  

Codeforces Round #348(VK Cup 2016 - Round 2)的更多相关文章

  1. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) D. Little Artem and Dance

    题目链接: http://codeforces.com/contest/669/problem/D 题意: 给你一个初始序列:1,2,3,...,n. 现在有两种操作: 1.循环左移,循环右移. 2. ...

  2. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 1 Edition) C. Little Artem and Random Variable 数学

    C. Little Artem and Random Variable 题目连接: http://www.codeforces.com/contest/668/problem/C Descriptio ...

  3. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) E. Little Artem and Time Machine 树状数组

    E. Little Artem and Time Machine 题目连接: http://www.codeforces.com/contest/669/problem/E Description L ...

  4. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) D. Little Artem and Dance 模拟

    D. Little Artem and Dance 题目连接: http://www.codeforces.com/contest/669/problem/D Description Little A ...

  5. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) C. Little Artem and Matrix 模拟

    C. Little Artem and Matrix 题目连接: http://www.codeforces.com/contest/669/problem/C Description Little ...

  6. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) B. Little Artem and Grasshopper 模拟题

    B. Little Artem and Grasshopper 题目连接: http://www.codeforces.com/contest/669/problem/B Description Li ...

  7. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) A. Little Artem and Presents 水题

    A. Little Artem and Presents 题目连接: http://www.codeforces.com/contest/669/problem/A Description Littl ...

  8. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) D

    D. Little Artem and Dance time limit per test 2 seconds memory limit per test 256 megabytes input st ...

  9. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) C

    C. Little Artem and Matrix time limit per test 2 seconds memory limit per test 256 megabytes input s ...

随机推荐

  1. August 23rd 2016 Week 35th Tuesday

    The very essence of romance is uncertainty. 浪漫的精髓就在于它充满种种可能. And the uncertainty of life may be also ...

  2. ios框架

    iPhone OS(现在叫iOS)是iPhone, iPod touch 和 iPad 设备的操作系统.        1,Core OS: 是用FreeBSD和Mach所改写的Darwin, 是开源 ...

  3. MyEclipse破解(MEGen.java)

    步骤: 1.将MEGen.java粘贴到任意web项目下,运行结果如下: 2.输入注册名:如sun,得到注册码: 3.Window  >>  Preference  >>  S ...

  4. Linux常用的日志分析命令与工具

    >>基础命令 操作 命令 说明 查看文件的内容 cat -n access.log -n显示行号 分页显示文件 more access.log Enter下一行,空格下一页,F下一屏,B上 ...

  5. Validform 学习笔记---代码练习

    上一节主要梳理了validform的基础知识,针对这些基础知识,编写代码的时候,也整理的部分知识,先记录以便后期温习. 验证部分的css @charset "utf-8"; /* ...

  6. SSIS Dataflow使用存储过程不能检索列名

    在项目中遇到一个问题,需要在Dataflow中调用一个存储过程,然后把结果生成一个csv文件. 然而在dataflow调用存储过程中遇到了问题,SP不能正确的返回列名. 在SSMT里面明明是可以查出数 ...

  7. 向Word模板中填充数据

    现在有这样的需求,给Word文档的指定位置填充上特定数据,例如我们有一个终端,用来打印员工的薪资证明,对于一个公司来说,他的薪资证明模板是固定的,变化的地方是员工姓名,部门,职位等.我们只需要将这些指 ...

  8. 第一次尝试用 Live Writer 写博客

    之前在官网上下载了最新版的Windows Live Writer,可是安装不了,就在其他网站下了一个试试,可以安装,不过却是2009年的版本,很不喜欢,我希望能体验最新版的,回头还得重新下个最新版的安 ...

  9. csc.rsp Invent by Microshaoft

    # This file contains command-line options that the C# # command line compiler (CSC) will process as ...

  10. linux中预留的$变量

    $0表示bash脚本的文件名 $1表示第一个参数 $*表示参数列表$0, $1, $2… $@表示"$1"/"$2"...每个变量都是独立的,用双引号括起来 $ ...