题目大意: 输入n,m: ( 1 ≤ N ≤ 10000, 2 ≤ M ≤ 100 ) 接下来n个数:Each integer is not greater than 10000 by it's absolute value. 判断他们按顺序做加减法后能否整除m 若能输出“Divisible”,否则输出“Not divisible”: Sample Input Sample #14 717 5 -21 15 Sample #24 517 5 -21 15 Sample Output Sample…
先验知识: 余数的计算公式:c = a -⌊ a/b⌋ * b 其中,⌊ ⌋为向下取整运算符,向下取整运算称为Floor,用数学符号⌊ ⌋表示 题目: Consider an arbitrary sequence of integers. One can place + or - operators between integers in the sequence, thus deriving different arithmetical expressions that evaluate to…
2016 ACM-ICPC NEERC F. Foreign Postcards 题意:有一串由C.W组成的字符串,每次截取长度为k(1<=k<=n且k随机)的前缀,如果该前缀首位为W,则该前缀取反(即C->W,W->C),放到桌上,否则直接放到桌上:重复前面步骤直至字符串被截为空.求最后桌上W的个数期望. 思路:定义dp[i]:以s[i]为首的后缀的W个数期望 则dp[i]=Σ{ (dp[k]+"s[i]到s[k-1]的W或C的个数")/(n-i) }(i+1…
题目大意: 输入k,n :k为每位慢跑者最少应看到的广告牌数 接下来n行 描述第 i 位慢跑者的途径路段 输出需要设立的广告牌数 接下来每行为设立地点 Sample Input 5 101 1020 270 -315 158 27 30-1 -1027 202 914 21 Sample Output 19-5-4-3-2-10456781518192021252627 题解:https://blog.csdn.net/shuangde800/article/details/7828537 #i…
Divisibility Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 14084 Accepted: 4989 Description Consider an arbitrary sequence of integers. One can place + or - operators between integers in the sequence, thus deriving different arithmetical…
1.链接地址: http://bailian.openjudge.cn/practice/1042/ http://poj.org/problem?id=1042 2.题目: Gone Fishing Time Limit: 2000MS   Memory Limit: 32768K Total Submissions: 27652   Accepted: 8199 Description John is going on a fishing trip. He has h hours avail…
PS:[笔记+代码+图片]在GitHub上持续更新,欢迎star:https://github.com/gdouchufu/Core-Python-Programming 本章大纲 介绍Python支持的多种数字类型,包含:整型.长整型.布尔型.双精度浮点型.十进制浮点型和复数. 介绍和数字相关的运算符和函数. 知识点 5.1 布尔型 从Python2.3開始支持bool.取值范围:True.False 5.2 标准整型 在32位机器上,标准整数类型的取值范围:-2的31次方 ~ 2的31次方-…
Divisibility Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 10598   Accepted: 3787 Description Consider an arbitrary sequence of integers. One can place + or - operators between integers in the sequence, thus deriving different arithmet…
Divisibility Time Limit: 2 Seconds      Memory Limit:65536 KB Consider an arbitrary sequence of integers. One can place + or - operators between integers in the sequence, thus deriving different arithmetical expressions that evaluate to different val…
思路:d(i,j)表示以i开头,长度为j的K好数的个数,转移方程就是 for(int u = 0; u < k; ++u) { int x = abs(i - u); if(x == 1) continue; //相邻的数字相同 dp[i][j] += dp[u][j-1]; } 还有就是可能答案很大一定要一边求解一边求余. 同余定理用起来,内存可用滚动数组优化. AC代码 #include <cstdio> #include <cmath> #include <alg…