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. [Android Pro] CountDownTimer倒计时

    定时执行在一段时候后停止的倒计时,在倒计时执行过程中会在固定间隔时间得到通知(译者:触发onTick方法),下面的例子显示在一个文本框中显示一个30s倒计时: new CountdownTimer(3 ...

  2. September 19th 2016 Week 39th Monday

    We come nearest to the great when we are great in humility. 我们最为谦逊的时候越接近伟大. When you are powerful en ...

  3. Linux(CentOS)系统下设置nginx开机自启动

    Nginx 是一个很强大的高性能Web和反向代理服务器.下面介绍在linux下安装后,如何设置开机自启动.首先,在linux系统的/etc/init.d/目录下创建nginx文件,使用如下命令:vi ...

  4. hdu 2034人见人爱A-B

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2034 解题思路:set的基本用法 #include<iostream> #include& ...

  5. 多图上传 - Web Uploader

    http://fex.baidu.com/webuploader/   官方DEMO,我都不想说了,各种问题.参考ShuaiBi文章   http://www.cnblogs.com/ismars/p ...

  6. MVC – 7.Razor 语法

    7.1 Razor视图引擎语法 Razor通过理解标记的结构来实现代码和标记之间的顺畅切换. @核心转换字符,用来 标记-代码 的转换字符串. 语境A: @{ string rootName=&quo ...

  7. Linux USB Project

    转自:http://www.linux-usb.org/ Welcome to the home of the Linux USB Project This web site was created ...

  8. Delphi基础语法的学习笔记和注意事项总结

    以下是我在自学Delphi的时候,对一些注意点的简单总结,并没有什么系统性可言,只是一个学习时顺手记下的笔记,主要为了当时加深对知识的印象,并没有希望能在以后的复习和使用Delphi中有什么多大的参考 ...

  9. 一次Promise 实践:异步任务的分组调度

    起因是在工作中遇到一个问题,可以用一个二维数组简单描述: [[1,2,3],[4,5,6],[7,8,9]] 这里每个数字都代表“一个异步计算任务”, 每个子数组把1个或多个计算任务划分成组,要求是: ...

  10. 攻城狮在路上(叁)Linux(二十一)--- linux磁盘检查 fsck \ badblocks

    若系统掉电或磁盘发生问题,可利用fsck命令对文件系统进行检查.这一步是可选的,尽量少用. 使用前的建议:使用fsck命令时,被检查的分区务必不要挂载在系统上. 一.fsck: 命令格式:fsck [ ...