A - Little Artem and Presents (div2)

1 2 1 2这样加就可以了

  1. #include <bits/stdc++.h>
  2.  
  3. typedef long long ll;
  4. const int N = 1e5 + 5;
  5.  
  6. int main() {
  7. int n; scanf ("%d", &n);
  8. int ans = n / 3 * 2;
  9. if (n % 3) {
  10. ans++;
  11. }
  12. printf ("%d\n", ans);
  13. return 0;
  14. }

B - Little Artem and Grasshopper (div2)

水题,暴力模拟一下

  1. #include <bits/stdc++.h>
  2.  
  3. typedef long long ll;
  4. const int N = 1e5 + 5;
  5. char str[N];
  6. int a[N];
  7.  
  8. int main() {
  9. int n; scanf ("%d", &n);
  10. scanf ("%s", str);
  11. for (int i=0; i<n; ++i) {
  12. scanf ("%d", a+i);
  13. }
  14. int now = 0;
  15. while (true) {
  16. if (now < 0 || now >= n) {
  17. break;
  18. }
  19. if (a[now] == -1) {
  20. puts ("INFINITE");
  21. return 0;
  22. }
  23. if (str[now] == '>') {
  24. int pre = now;
  25. now = now + a[now];
  26. a[pre] = -1;
  27. } else {
  28. int pre = now;
  29. now = now - a[now];
  30. a[pre] = -1;
  31. }
  32. }
  33. puts ("FINITE");
  34. return 0;
  35. }

构造 C - Little Artem and Matrix (div2)

倒过来做,循环也反着来

  1. #include <bits/stdc++.h>
  2.  
  3. typedef long long ll;
  4. const int N = 1e2 + 5;
  5. const int Q = 1e4 + 5;
  6. int a[N][N];
  7. int t[Q], row[Q], col[Q], x[Q];
  8.  
  9. int main() {
  10. int n, m, q; scanf ("%d%d%d", &n, &m, &q);
  11. for (int i=1; i<=q; ++i) {
  12. scanf ("%d", t+i);
  13. if (t[i] == 1) {
  14. scanf ("%d", row+i);
  15. }
  16. if (t[i] == 2) {
  17. scanf ("%d", col+i);
  18. }
  19. if (t[i] == 3) {
  20. scanf ("%d%d%d", row+i, col+i, x+i);
  21. }
  22. //printf ("%d %d %d %d\n", t[i], row[i], col[i], x[i]);
  23. }
  24. for (int i=q; i>=1; --i) {
  25. if (t[i] == 1) {
  26. int last = a[row[i]][m];
  27. for (int j=m; j>=2; --j) {
  28. a[row[i]][j] = a[row[i]][j-1];
  29. }
  30. a[row[i]][1] = last;
  31. }
  32. if (t[i] == 2) {
  33. int last = a[n][col[i]];
  34. for (int j=n; j>=2; --j) {
  35. a[j][col[i]] = a[j-1][col[i]];
  36. }
  37. a[1][col[i]] = last;
  38. }
  39. if (t[i] == 3) {
  40. a[row[i]][col[i]] = x[i];
  41. }
  42. }
  43. for (int i=1; i<=n; ++i) {
  44. for (int j=1; j<=m; ++j) {
  45. printf ("%d%c", a[i][j], j == m ? '\n' : ' ');
  46. }
  47. }
  48. return 0;
  49. }

数学 D - Little Artem and Dance (div2)

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

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

  1. #include <bits/stdc++.h>
  2.  
  3. typedef long long ll;
  4. const int N = 1e6 + 5;
  5. int ans[N];
  6.  
  7. int main() {
  8. int p0 = 0, p1 = 1;
  9. int n, q; scanf ("%d%d", &n, &q);
  10. for (int i=0; i<q; ++i) {
  11. int type; scanf ("%d", &type);
  12. if (type == 1) {
  13. int x; scanf ("%d", &x);
  14. p0 = (p0 + x + n) % n;
  15. p1 = (p1 + x + n) % n;
  16. } else {
  17. p0 = p0 ^ 1;
  18. p1 = p1 ^ 1;
  19. }
  20. }
  21. for (int i=0; i<n; i+=2) {
  22. ans[(p0+i)%n] = i + 1;
  23. }
  24. for (int i=1; i<n; i+=2) {
  25. ans[(p1+i-1)%n] = i + 1;
  26. }
  27. for (int i=0; i<n; ++i) {
  28. printf ("%d%c", ans[i], i == n-1 ? '\n' : ' ');
  29. }
  30. return 0;
  31. }

数学+前(后)缀 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))

 

解方程的,从而求得

  1. #include <bits/stdc++.h>
  2.  
  3. const int N = 1e5 + 5;
  4. double p[N], q[N], a[N], b[N];
  5.  
  6. int main() {
  7. int n; scanf ("%d", &n);
  8. for (int i=1; i<=n; ++i) {
  9. scanf ("%lf", p+i);
  10. p[i] += p[i-1];
  11. }
  12. for (int i=1; i<=n; ++i) {
  13. scanf ("%lf", q+i);
  14. }
  15. for (int i=n; i>=1; --i) {
  16. q[i] += q[i+1];
  17. }
  18. for (int i=1; i<=n; ++i) {
  19. double A = p[i], B = q[i+1];
  20. double C = B - A - 1;
  21. double delta = sqrt (std::max (C*C - 4 * A, 0.0));
  22. a[i] = (-C+delta) / 2;
  23. b[i] = (-C-delta) / 2;
  24. }
  25. for (int i=1; i<=n; ++i) {
  26. printf ("%.10f%c", a[i] - a[i-1], i == n ? '\n' : ' ');
  27. }
  28. for (int i=1; i<=n; ++i) {
  29. printf ("%.10f%c", b[i] - b[i-1], i == n ? '\n' : ' ');
  30. }
  31. return 0;
  32. }

  

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. .NET后台如何获取前台HMTL控件的值

    很多时候我们需要HTML控件,感觉比服务器控件更加简介,清爽,那么如何获取HMTL控件的值呢,请看下面例子: 前台页面代码: <input id="Text1" type=& ...

  2. Mysql分布式事务

    关于Mysql分布式事务介绍,可参考:http://blog.csdn.net/luckyjiuyi/article/details/46955337 分为两个阶段:准备和执行阶段.有两个角色:事务的 ...

  3. hdu1018(数位)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1018 题意:求n!的数位(即n!有多少位): 思路:对于一个数x,它的数位ans=log10(x): ...

  4. Xcode - 修改变量名、类名及字符串的替换操作

    在做iOS开发代码优化的工作时,优化代码结构之前,我们应该先整理好工程的外貌,将文件和类的命名进行规范,在Xcode中为我们提供了方便而强大的名称修改功能. 第一步:修改类名 将鼠标点击放在类的名称上 ...

  5. 三、jQuery--jQuery基础--jQuery基础课程--第6章 jQuery 事件与应用

    1.页面加载时触发ready()事件 ready()事件类似于onLoad()事件,但前者只要页面的DOM结构加载后便触发,而后者必须在页面全部元素加载成功才触发,ready()可以写多个,按顺序执行 ...

  6. JavaWeb学习之tomcat安装与运行、tomcat的目录结构、配置tomcat的管理用户、web项目目录、虚拟目录、虚拟主机(1)

    1.tomcat安装与运行双击tomcat目录下的bin/startup.bat,启动之后,输入http://localhost:8080,出现安装成功的提示,表示安装tomcat成功 2.tomca ...

  7. Oracle 监听器

    Oracle监听器listener是一个重要的数据库服务器组件,在整个Oracle体系结构中,扮演着重要的作用. 监听器Lisener功能 从当前的Oracle版本看,Listener主要负责下面的几 ...

  8. 开心网的账号登录及api操作

    .kaixin.php <?php /** * PHP Library for kaixin001.com * * @author */ class kaixinPHP { function _ ...

  9. JS常用语句

    JavaScript常用语句 1.document.write("");    输出语句 2.JS中的注释为   // 3.传统的HTML文档顺序是:     document-& ...

  10. PL/SQL Developer 9.x 注册码

    记下来,以备以后使用,好笔头,哈哈哈 Product Code:46jw8l8ymfmp2twwbuur8j9gv978m2q2du serial Number:307254 password:xs3 ...