题目大意: 一个$n*n$的格子,每个格子由你填色,有三种允许填色的方法,问有一行或者一列相同的方案数. 题目分析: 标题的FMT是我吓人用的. 一行或一列的问题不好解决,转成它的反面,没有一行和一列相同的方案数. 从一个方向入手,比如列,把一列看成一个整体.把颜色看成二进制数,$001$,$010$,$100$. 那么一列构成了一个长度为$3n$的二进制数,$n$列之间互相与出来的结果为$0$.实际我要统计这个东西. 注意到每一列的取法是不能取相同颜色的,所以剔除相同.之后我们得到了每一列可选…
传送门:http://codeforces.com/problemset/problem/997/C [题解] 注意在把$i=0$或$j=0$分开考虑的时候,3上面的指数应该是$n(n-j)+j$ 至少一行一列相同颜色,那么这些相同颜色的行列一定是同一种颜色,所以是$3^((n-i)(n-j)+1)$. 如果只有若干行相同颜色,那么这些相同颜色的行之间的颜色不一定相同,所以是$3^((n-j)j+j)$. # include <bits/stdc++.h> using namespace st…
CF997C Sky Full of Stars 计数好题 在Ta的博客查看 容斥式子:发现只要每个钦定方案的贡献都考虑到再配上容斥系数就是对的 O(n^2)->O(n) 把麻烦的i=0,j=0特殊考虑下 剩下的,先把麻烦的东西化简干净 然后枚举一维i,剩下的二项式定理!!!! #include<bits/stdc++.h> #define reg register int #define il inline #define fi first #define se second #def…
题目链接:codeforces 997C.Sky Full of Stars 一道很简单(?)的推式子题 直接求显然不现实,我们考虑容斥 记\(f(i,j)\)为该方阵中至少有\(i\)行和\(j\)列为相同颜色的情况 那么显然有\(ans=\sum_{i=0}^n \sum_{j=0}^n C_n^i C_n^j (-1)^{i+j-1} f(i,j)\ \ (i+j\neq0)\) 其中对于\(f(i,j)\)的取值有两种情况 ​ I.若\(i=0\)或\(j=0\),先假设\(i=0\),…
C - Sky Full of Stars 思路: 容斥原理 题解:http://codeforces.com/blog/entry/60357 注意当i > 1 且 j > 1,是同一种颜色 代码: #include<iostream> #include<cstdio> #include<queue> #include<deque> #include<set> #include<cstring> using namesp…
[题解]CF997C Sky Full of Stars 为什么我的容斥原理入门题是这道题????????? \(Part-1\)正向考虑 直接考虑不合法合法的方案吧 所以我们设行有\(i\),列有\(j\)有是不同的颜色 所以分这几种情况讨论: \[ i\not=0,j\not=0 \\ i=j=0 \\ ij=0,i+j\not=0 \] 考虑到\(i=j=0​\)对答案没有贡献,所以我们考虑第一式和第三式吧 第三式简单一点,情况就是这样的: 方案数还是比较显然的(我说显然是因为是可以通过我…
[Codeforces 997C]Sky Full of Stars(排列组合+容斥原理) 题面 用3种颜色对\(n×n\)的格子染色,问至少有一行或一列只有一种颜色的方案数.\((n≤10^6)\) 分析 显然任意染色的方案数为\(3^{n^2}\),我们考虑求出没有一行一列只有一种颜色的方案数,然后相减. (1)首先考虑仅仅没有全部是一种颜色的列,每一列任意染色有\(3^n\)种方案,去掉每一列只有一种颜色的方案有3种,共\(3^n-3\)种,n列就有\((3^n-3)^n\)种. (2)再…
题意 题目链接 \(n \times n\)的网格,用三种颜色染色,问最后有一行/一列全都为同一种颜色的方案数 Sol Orz fjzzq 最后答案是这个 \[3^{n^2} - (3^n - 3)^n - \sum_{i = 1}^n (-1)^i C_n^i 3(3^{n-i} - 1)^n + (3^i - 3)(3^{(n-i)n}) \] 我来强行解释一波. 首先可以做个转化:答案 = 总的方案 - 任意行/列都至少含有两种颜色的方案 我们先来考虑列,任意一列含有两种颜色的方案是\((…
正解:容斥 解题报告: 传送门! 两个方法,分别港下QAQ 先说第一种 首先要推出式子,就∑2*C(i,n)*(-1)i+1*3i*3n*n-n+3*∑∑(-1)i+j+1*C(i,n)*C(j,n)*3(n-i)(n-j) 理解其实不难理解的?就至少有i行j列相同的方案数嘛 具体来说,首先从n行中选i行,n列中选j列的方案数是C(i,n)*C(j,n),然后除了这i行这j列以外还有(n-i)(n-j)个格子,这些格子都可以随便填的,所以是3(n-i)(n-j),然后选出的这i行j列的颜色有3种…
题目链接 那场完整的Div2(Div1 ABC)在这儿.. \(Description\) 给定\(n(n\leq 10^6)\),用三种颜色染有\(n\times n\)个格子的矩形,求至少有一行或一列格子同色的方案数. \(Solution\) 求恰好有多少行/列满足同色不好求,但如果某几行/列已经确定同色,这些行/列外任意选择,即至少多少行/列满足,那么很好求. 容斥.设\(f(i,j)\)表示至少有\(i\)行\(j\)列同色的方案数,则\(ans=\sum_{0\leq i\leq n…
赛前任务 tags:任务清单 前言 现在xzy太弱了,而且他最近越来越弱了,天天被爆踩,天天被爆踩 题单不会在作业部落发布,所以可(yi)能(ding)会不及时更新 省选前的练习莫名其妙地成为了Noip前的杂题训练,我也很无奈啊 做完了的扔最后,欢迎好题推荐 这么多题肯定是完不成了,能多做一道是一道吧 DP yyb真是强得不要不要的辣:http://www.cnblogs.com/cjyyb/category/1036536.html [ ] [SDOI2010]地精部落 https://www…
Sky Full of Stars 题目链接:http://codeforces.com/problemset/problem/997/C 数据范围:略. 题解: 首先考虑拟对象,如果至少有一行完全相等即可. 这个的答案就需要多步容斥:$\sum\limits_{i = 1} ^ n (-1)^{i + 1}\cdot 3 ^ i\cdot 3 ^ {n \cdot (n - i)}$. 那么至少有一列的答案跟这个一样. 把他俩加一起就是答案么?我们需要减去什么? 显然,需要减掉至少有一行且至少…
Sky Full of Stars CodeForces - 997C On one of the planets of Solar system, in Atmosphere University, many students are fans of bingo game. It is well known that one month on this planet consists of n2n2 days, so calendars, represented as square matri…
因为垃圾电脑太卡了就重开了一个... 前传:多项式Ⅰ u1s1 我预感还会有Ⅲ 多项式基础操作: 例题: 26. CF438E The Child and Binary Tree 感觉这题作为第一题还蛮合适的( 首先我们设 \(f_i\) 为权值之和为 \(i\) 的符合要求的二叉树的个数. 显然可以枚举根节点的权值.左子树的权值之和进行转移. 也就是 \(f_i=\sum\limits_{x\in S}\sum\limits_{y=0}^{i-S}f_yf_{i-x-y}\) 如果我们记 \(…
Starry NightIOI 98 High up in the night sky, the shining stars appear in clusters of various shapes. A cluster is a non-empty group of neighbouring stars, adjacent in horizontal, vertical or diagonal direction. A cluster cannot be a part of a larger…
目录 Codeforces 998 A.Balloons B.Cutting C.Convert to Ones D.Roman Digits E.Sky Full of Stars(容斥 计数) Codeforces 998 比赛链接 A.Balloons 输出啥看错WA\(*2\)+第一次写sort写了cmp()但是没加cmpWA\(*2\)(结构体重载运算符后遗症).. 没谁了. #include <cstdio> #include <cctype> #include <…
http://poj.org/problem?id=1175 题目解析: 这个题因为数据的原因可以很水的过,但我因为把1e-8写成了1e-9WA了N遍,一直WA,题目意思很简单就是相似图形(就是求旋转的图形,我不会,但在discuss中看到 可以通过求图形的长度来求)另外常识性问题double数据类型不能直接比较相等,需要借助一个小数比较,那个比较的小数题目一般会提示,例如这题就是1e-8,另外就是 这题的数据是在是忒坑了! #include <iostream> #include <s…
http://poj.org/problem?id=3904   题意:给一些数,求在这些数中找出四个数互质的方案数.   莫比乌斯反演的式子有两种形式http://blog.csdn.net/outer_form/article/details/50588307 这里用的是第二种形式. 求出四个数的公约数为x的倍数的方案数,即可得到,四个数的公约数为x的方案数. 这里x为1. 代码 #include<cstdio> #include<cstring> #include<io…
B - Sky Code Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 3904 Description Stancu likes space travels but he is a poor software developer and will never be able to buy his own spacecraft. Tha…
题意 Language:Default Sky Code Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3980 Accepted: 1333 Description Stancu likes space travels but he is a poor software developer and will never be able to buy his own spacecraft. That is why he is…
题目链接:http://poj.org/problem?id=3904 Sky Code Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2968   Accepted: 998 Description Stancu likes space travels but he is a poor software developer and will never be able to buy his own spacecraft…
Stars in Your Window Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11706   Accepted: 3183 Description Fleeting time does not blur my memory of you. Can it really be 4 years since I first saw you? I still remember, vividly, on the beaut…
题目描述 "But baby, I've been, I've been praying hard,     Said, no more counting dollars     We'll be counting stars" Grandpa Shaw loves counting stars. One evening he was sitting in his armchar, trying to figure out this problem. Consider the sky…
Stars in Your Window   Description Fleeting time does not blur my memory of you. Can it really be 4 years since I first saw you? I still remember, vividly, on the beautiful Zhuhai Campus, 4 years ago, from the moment I saw you smile, as you were walk…
Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 186    Accepted Submission(s): 124 Problem Description The sky was brushed clean by the wind and the stars were cold in a bl…
N. Sky Code Time Limit: 1000ms Case Time Limit: 1000ms Memory Limit: 65536KB   64-bit integer IO format: %lld      Java class name: Main Submit Status Font Size: + - Stancu likes space travels but he is a poor software developer and will never be abl…
Dancing Stars on Me Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5533 Description The sky was brushed clean by the wind and the stars were cold in a black sky. What a wonderful night. You observed that, somet…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5533 Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 601    Accepted Submission(s): 320 Problem Description The sky was brush…
Description Fleeting time does not blur my memory of you. Can it really be 4 years since I first saw you? I still remember, vividly, on the beautiful Zhuhai Campus, 4 years ago, from the moment I saw you smile, as you were walking out of the classroo…
Problem Description Yifenfei is a romantic guy and he likes to count the stars in the sky. To make the problem easier,we considerate the sky is a two-dimension plane.Sometimes the star will be bright and sometimes the star will be dim.At first,there…