题目地址:Ural 1353 定义dp[i][j].表示当前位数为i位时,各位数和为j的个数. 对于第i位数来说.总能够看成在前i-1位后面加上一个0~9.所以状态转移方程就非常easy出来了: dp[i][j]=dp[i][j]+dp[i][j-1]+dp[i][j-2]+.......+dp[i][j-9]: 最后统计就可以. 代码例如以下: #include <iostream> #include <cstdio> #include <string> #inclu…
题目传送门 /* 题意:1~1e9的数字里,各个位数数字相加和为s的个数 递推DP:dp[i][j] 表示i位数字,当前数字和为j的个数 状态转移方程:dp[i][j] += dp[i-1][j-k],为了不出现负数 改为:dp[i][j+k] += dp[i-1][j] */ #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <str…
1353. Milliard Vasya's Function Time limit: 1.0 second Memory limit: 64 MB Vasya is the beginning mathematician. He decided to make an important contribution to the science and to become famous all over the world. But how can he do that if the most i…
1353. Milliard Vasya's Function Time limit: 1.0 second Memory limit: 64 MB Vasya is the beginning mathematician. He decided to make an important contribution to the science and to become famous all over the world. But how can he do that if the most i…
题目链接 题意 : 让你找出1到10^9中和为s的数有多少个. 思路 : 自己没想出来,看的题解,学长的题解报告 题解报告 //URAL 1353 #include <iostream> #include <stdio.h> #include <string.h> using namespace std; ][] ; int main() { int s ; memset(dp,,sizeof(dp)) ; ; i < ; i++) { dp[][i] = ; d…
http://acm.timus.ru/problem.aspx?space=1&num=2072 题意:有n朵花,每朵花有一个饥渴值.现在浇花,优先浇饥渴值小的(即从小到大浇),浇花需要耗费1个单位时间,从第i个位置走到第j个位置需要耗费abs(j-i)个单位时间,问浇完所有的花需要耗费的最少时间是多少. 思路:考虑到有饥渴值一样的花,那么只要考虑怎么在饥渴值相同的情况下取最优,那问题便可以迎刃而解了. 首先想,要让时间耗费的少,那么就尽量不要走重复的路程,所以想到这里,可以确定:对于某一个饥…
http://acm.timus.ru/problem.aspx?space=1&num=1353 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; ][]; void inti() { memset(dp,,sizeof(dp)); dp[][]=; ; i<=; i++) { ; j<=i*; j++) { ; k<=; k++) {…
Problem Description JGShining's kingdom consists of 2n(n is no more than 500,000) small cities which are located in two parallel lines. Half of these cities are rich in resource (we call them rich cities) while the others are short of resource (we ca…
题目链接:http://codeforces.com/contest/1058/problem/E 题意:给出 n 个数,对于一个选定的区间,区间内的数可以通过重新排列二进制数的位置得到一个新的数,问有多少个区间满足,区间内的数异或和为 0 . 题解:首先对于一个区间来说,区间内二进制为 1 的个数为奇数时显然不可能满足条件,先统计二进制为 1 的个数为偶数的区间总个数.而在一个区间内,如果某个数二进制下有 x 个 1 ,而区间内其他数的二进制 1 加起来小于 x ,则是不满足的,可以暴力去掉这…
1.前言 2.function(下) 2.13.angular.isArray(★★) angular.isArray用于判断对象是不是数组,等价于Array.isArray console.log(angular.isArray([])); // true console.log(angular.isArray({0: '1', 1: '2', length: 2})); // false 2.14.angular.isDate(★★) 通过判断toString.call(value)是不是等…