sgu - 269 - Rooks】的更多相关文章

题意:给出一个n行的棋盘,每行的长度任意,问在该棋盘中放k个车(不能同行或者同列)有多少种放法(n <= 250, 每行的长度 <= 250). 题目链接:http://acm.sgu.ru/problem.php?contest=0&problem=269 ——>>开始的时候冒险用dfs去做,结果TLE了...改dp,大数长度开小点WA,开大点MLE……最后改用滚动数组开1000位的大数长度才A掉…… 设d[i][j]表示前i行放j个车的方法数, 则状态转移方程为:d[i…
题意: 给n(<=250)条水平网格,然后在上面放k棋子,每行每列都只能放一个.求方法总数. Solution: 简单的DP, 只要对给出的水平长度排个序就很容易处理了. 需要用到高精度. 偷懒用java写了 import java.util.*; import java.math.*; public class Solution { public static void main(String[] args){ Scanner cin=new Scanner(System.in); int n…
题意: 求在n*n(n<10)的棋盘上放k个车(水平竖直行走)的方案数. Solution SGU220的简化版.直接DP 显然当k>n时,ans=0; f[i][j]代表在前n行放了j个棋子. 转移方程 f[i][j]=f[i-1][j]+f[i-1][j-1]*(n-j+1); #include <iostream> using namespace std; ][], n, m, ans; int main() { ios::sync_with_stdio (); cin &g…
SGU还是个不错的题库...但是貌似水题也挺多的..有些题想出解法但是不想写代码, 就写在这里吧...不排除是我想简单想错了, 假如哪位神犇哪天发现请告诉我.. 101.Domino(2015.12.16) 102.Coprimes 求φ(N). 1<=N<=10^4 按欧拉函数的公式直接算..O(N^0.5)(2015.12.16) #include<cstdio> #include<cstring> #include<algorithm> using n…
UVA - 11134 Fabled Rooks We would like to place n rooks, 1 ≤ n ≤ 5000, on a n × n board subject to the following restrictions The i-th rook can only be placed within the rectan- gle given by its left-upper corner (xli,yli) and its right- lower corner…
水概率....SGU里难得的水题.... 495. Kids and Prizes Time limit per test: 0.5 second(s)Memory limit: 262144 kilobytes input: standardoutput: standard ICPC (International Cardboard Producing Company) is in the business of producing cardboard boxes. Recently the…
sgu 101 - Domino Time Limit:250MS     Memory Limit:4096KB     64bit IO Format:%I64d & %I64u Description Dominoes – game played with small, rectangular blocks of wood or other material, each identified by a number of dots, or pips, on its face. The bl…
http://acm.sgu.ru/problem.php?contest=0&problem=495 题意:N个箱子M个人,初始N个箱子都有一个礼物,M个人依次等概率取一个箱子,如果有礼物则拿出礼物放回盒子,如果没有礼物则不操作.问M个人拿出礼物个数的期望.(N,M<=100000) #include <cstdio> using namespace std; double mpow(double a, int n) { double r=1; while(n) { if(n&…
题目链接:http://acm.sgu.ru/problem.php?contest=0&problem=455 Due to the slow 'mod' and 'div' operations with int64 type, all Delphi solutions for the problem 455 (Sequence analysis) run much slower than the same code written in C++ or Java. We do not gua…
http://www.lightoj.com/volume_showproblem.php?problem=1005        PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 32 MB A rook is a piece used in the game of chess which is played on a board of square grids. A rook can only move…