A. System of Equations

  • \(a\)的范围在\(\sqrt n\)内,所以暴力枚举即可。

B. Hometask

  • 需要被2、5整除,所以末位必然为0,如果0没有出现,则直接返回-1。
  • 在不考虑被3整除的情况下,为了凑出最大数,必然是从9到0的顺序填数。
  • 设位数和模3的值为\(sum\),如果\(sum=0\),显然当前数即答案,否则考虑去除一些数使得数被3整除。
  • 因为\(sum \ne 0\),所以\(sum=1\ or\ sum = 2\),显然去除的数不会超过2个。优先考虑去除一个数\(x\),需要满足\(x \% 3 = sum\),且越小越好;去除两个数时\((x, y)\),需要满足\((x+y)\%3=sum\),且两个值越小越好。

C. Game

  • 游戏顺序必然是\(\cdots \to 1 \to 2 \to 3 \to 1 \to \cdots\)
  • 那么只要枚举起点,取最小值即可。

D. Numbers

  • \(f(i,j)\)表示由前i个数凑成长度为j的方案数。
  • 每次转移时,当前数的个数需要大于等于\(a[i]\)。
  • 由于不能有前导0,所以填0时需要去掉首位这个位置。

E. Relay Race

  • \(dp(i,j,k)\)表示走了i步后,第一个人的横坐标为j,第二个人为k的最大值。
  • 转移时需要判断两个人是否在同一格子,即\(j==k\)。

Codeforces Round #131 (Div. 2)的更多相关文章

  1. Codeforces Round #131 (Div. 1) B. Numbers dp

    题目链接: http://codeforces.com/problemset/problem/213/B B. Numbers time limit per test 2 secondsmemory ...

  2. Codeforces Round #131 (Div. 2) B. Hometask dp

    题目链接: http://codeforces.com/problemset/problem/214/B Hometask time limit per test:2 secondsmemory li ...

  3. Codeforces Round #131 (Div. 2) E. Relay Race dp

    题目链接: http://codeforces.com/problemset/problem/214/E Relay Race time limit per test4 secondsmemory l ...

  4. Codeforces Round #131 (Div. 2) : B

    首先能被2,5整除的数结尾必须是0: 如果没有0肯定不行: 然后判断他们的和ans%3: 如果==0,直接从大到小输出就行: 如果==1,要么删除它们之间最小的那个%3==1的,要么删除两个小的并且% ...

  5. Codeforces Round #131 (Div. 1) A - Game

    A. Game time limit per test 1 second memory limit per test 256 megabytes input standard input output ...

  6. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  7. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  8. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  9. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

随机推荐

  1. poj 3264 Balanced Lineup (线段树)

    Balanced Lineup Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 42489   Accepted: 20000 ...

  2. Program A - 暴力求解

    Description   Write a program that finds and displays all pairs of 5-digit numbers that between them ...

  3. English idioms

    a hot potato : speak of an issue(mostly current) which many people are talking about and which is us ...

  4. c#读取文本文档实践1-File.ReadAllLines()

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.I ...

  5. 去除hadoop启动时的警告

    hadoop启动的时候,会出现以下警告提示: 执行more start-all.sh查看该文件 但/libexec下不存在hadoop-config.sh文件,所以会执行bin/hadoop-conf ...

  6. C# Sandboxer

    public static string IsolateCallV1(PageContentHandler pHandler) { string name = Guid.NewGuid().ToStr ...

  7. (转)深入浅出 iOS 之生命周期

    原文:http://www.cocoachina.com/applenews/devnews/2011/0817/3129.html 深入浅出 iOS 之生命周期 发布于:2011-08-17 10: ...

  8. hdu 2068

    ps:长度长到我不想说....WA了无数次...25的阶乘就爆炸... 代码: #include "stdio.h" #define LL long long LL fac(lon ...

  9. mongo db 分享 ppt

    在公司内部的mongo db的ppt.初步进阶 http://files.cnblogs.com/files/yuhan-TB/mongoDB.pptx

  10. ISO c++11 does not allow conversion from string literal to 'char*'

    http://stackoverflow.com/questions/9650058/deprecated-conversion-from-string-literal-to-char