自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

围巾的ACM博客

刚毕业~

  • 博客(111)
  • 收藏
  • 关注

原创 poj2109 Power of Cryptography

思路:看到这个数据范围以为要上高精度了...结果...#include#includedouble n, p;int main(){ while(scanf("%lf%lf", &n, &p) != EOF){ printf("%.0f\n", pow(p, 1/n)); }}DescriptionCurrent

2016-07-31 17:41:08 302

原创 poj2891 Strange Way to Express Integers(中国剩余定理)

题意:给出k个模方程组:x mod ai = ri。求x的最小正值。如果不存在这样的x,那么输出-1.思路:中国剩余定理有一个条件是m1,m2...mn必须两两互质,如果不互质怎么办呢?套模板!#include#includeusing namespace std;typedef long long LL;typedef pair PLL;LL a[100000], b[

2016-07-31 17:30:58 266

原创 poj1006 Biorhythms(中国剩余定理)

思路:中国剩余定理的裸题#includetypedef long long LL;const int N = 100000 + 5;void ex_gcd(LL a, LL b, LL &x, LL &y, LL &d){ if (!b) {d = a, x = 1, y = 0;} else{ ex_gcd(b, a % b, y, x, d);

2016-07-31 17:27:24 270

原创 hdu3080 The plan of city rebuild(最小生成树)

思路:比较简单的最小生成树,读懂题就好了#include#include#include#includeusing namespace std;const int INF =1e6;const int maxn=205;int n,m,t; //总点数,总边数,desert的边数int des[maxn]; //为1代表城市荒废int fa[maxn];

2016-07-30 23:42:18 326

原创 UVALive 6618 Skycity(数学)

思路:一开始写二分边数一直WA到无法自理...对于给定的圆,和他相切的正多边形的边数越多,正多边形的周长越小。但是因为对每个边长有最小的长度限制,我们可以直接算出来。利用边长的最小限制,我们能求出对应的内角,从而可以找到大于等于该内角度数的边数最小的正多边形。(摘自网上)#include #include #include #include #include using na

2016-07-30 23:23:44 337

原创 UVALive 6619 LIKE vs CANDLE(树形DP)

思路:              树形dp。因为最终答案要求的是差值,所以对于每个节点我们只需要考虑差值即可,dp[u][0]表示u节点以下(含u)中like的val比candle的val大的最大值,dp[u][1]表示candle的val值比like大的最大值。所以,对于每个节点我们就可以对于每个子树v:            dp[u][0] += dp[v][0]; 

2016-07-30 23:19:19 373

原创 UVALive 6620 Josephina and RPG(概率DP)

思路:简单的概率DP,题目连转移方向都给你规定好了...见代码#include#include#includeusing namespace std;double dp[10010][150];double p[150][150];int a[15000];int main(){ int M; while(scanf("%d",&M)!=EOF) { mems

2016-07-30 23:16:13 362

原创 UVALive 6621 Pocket Cube(暴力)

思路:将操作都打个表出来然后暴力就好了,一般遇到这种题我都是甩锅给队友...#include #include #include #include #include #include #include #include #include #include #include #include #define INF 0x3f3f3f3f#define esp

2016-07-30 23:15:13 418

原创 UVALive 6613 Collision(物理解方程)

思路:设走过的时间为t,那么就有在x方向上走过的路程x+t*vx,y方向上y+t*vy,然后代入圆的方程就可以解出两个根了,判断是不是有反弹也是同理的#include#include#include#includeusing namespace std;int main(){ double Rm,R,r,x,y,vx,vy; while(scanf("%lf%l

2016-07-30 23:13:54 344

原创 UVALive 6611 Alice's Print Service(二分)

思路:二分二分就好了#include #include #include #include #include #include #include #include #include #include #include #include #define INF 0x3f3f3f3f#define esp 1e-9typedef long long LL;u

2016-07-30 23:12:00 336

原创 POJ 1830 开关问题(高斯消元)

思路:裸的高斯消元#include#include#includeusing namespace std;int a[35][35],mp[35],ed[35];int n;int gan(){ int i,j; for(i = 1,j=1;i<=n&&j<=n;j++) { int k = i; for(;k<=n;k++) if(a[k][j]

2016-07-29 19:46:20 396

原创 poj1222 EXTENDED LIGHTS OUT(高斯消元)

思路:高斯消元...每个格子列一个方程然后高斯消元即可#include#include#includeusing namespace std;int a[35][35];int ans[35];void init(){ for(int i = 0;i<30;i++) { a[i][i]=1; if(i>5) a[i-6][i]=1; if(i<24)

2016-07-29 14:53:46 394

原创 hdu5773 The All-purpose Zero(DP)

思路:0可以转化成任意整数,包括负数,显然求LIS时尽量把0都放进去必定是正确的。因此我们可以把0拿出来,对剩下的做O(nlogn)的LIS,统计结果的时候再算上0的数量。为了保证严格递增,我们可以将每个权值S[i]减去i前面0的个数,再做LIS,就能保证结果是严格递增的。#includeusing namespace std;const int maxn = 100000+50;

2016-07-28 20:27:15 483

原创 hdu5763 Another Meaning (DP+KMP)

思路:令dp[i]表示到i结尾的字符串可以表示的不同含义数,那么考虑两种转移:末尾不替换含义:dp[i - 1]末尾替换含义:dp[i - |B|]  (A.substr(i - |B| + 1,|B|) = B)那么对于末尾替换含义的转移,需要快速判断BB能不能和当前位置的后缀匹配,kmp或者hash判断即可。复杂度:O(N)#include

2016-07-28 20:25:53 786

原创 hdu5755 Bubble Sort(树状数组or线段树)

思路:考虑一个位置上的数字c在冒泡排序过程的变化情况。c会被其后面比c小的数字各交换一次,之后c就会只向前移动。数组从右向左扫,树状数组维护一下得到每个值右边有多少个比其小的值,加上原位置得到最右位置,最左位置为初始位置和最终位置的最小值。#include #include #include #include #include #include #include #inc

2016-07-28 20:24:00 435

原创 hdu5774 Where Amazing Happens (水)

思路:水题#include #include #include #include #include #include #include #include #include #include #include #include #define INF 0x3f3f3f3f#define esp 1e-9typedef long long LL;using name

2016-07-28 20:22:02 1037

原创 hdu5755 Gambler Bo(高斯消元)

思路:一个mod3版本的开关灯问题,对每个格子分别设操作了xi次,那么就可以列出一个n*m的方程组,然后高斯消元就可以了#includeusing namespace std;int a[35*36][35*35];int mp[35][35];int id[35][35];int cnt = 0;int x[35*35];int n,m,ans;int gcd(int

2016-07-28 20:19:34 522

原创 hdu5544 Ba Gua Zhen(高斯消元)

思路:首先DFS把图上的所有环找出来,然后就是K个数里面任意选数使得异或和最大,高斯消元就好了异或方程的高斯消元见 点击打开链接#includeusing namespace std;const int maxn = 5*1e4+7;const int maxm = 1e5+7;#define LL long longint dyn[maxn];vector >e[ma

2016-07-27 22:52:25 1430

原创 hdu5752 Sqrt Bo(水)

思路:五次的根号不会很大。1->3->15->255->65535->4294967295,那就最大就是4294967295了,超过就直接输出TAT好了#include using namespace std;typedef long long LL;const int N=1e5+10;const int INF=0x3f3f3f3f;int cas=1,T;char s

2016-07-26 20:46:21 539

原创 hdu5754 Life Winner Bo(博弈)

思路:国王和车手玩很快就出来规律了,马的话比较烦,可是不过手玩一下也是可以发现规律的...然后皇后其实就是一个威佐夫博弈#includeusing namespace std;const int maxn = 1e6+7;int sg[maxn];void init(){ int cnt = 1; for(int i = 2;i<=1000;i++) { if(!s

2016-07-26 20:42:23 385

原创 hdu5753 Permutation Bo(数学)

思路:根据期望的线性性,我们可以分开考虑每个位置对答案的贡献。可以发现当ii不在两边的时候和两端有六种大小关系,其中有两种是对答案有贡献的。那么对答案的贡献就是\frac{c_i}{3}​3​​c​i​​​​。在两端的话有两种大小关系,其中有一种对答案有贡献。那么对答案的贡献就是\frac{c_i}{2}​2​​c​i​​​​。复杂度是O(n)O

2016-07-26 20:34:27 470

原创 hdu5761 Rower Bo(物理题or瞎猜)

思路:比赛的时候看到样例答案就是8/7,然后猜了几发公式...正解:首先这个题微分方程强解显然是可以的,但是可以发现如果设参比较巧妙就能得到很方便的做法。先分解v_1v​1​​,设船到原点的距离是rr,容易列出方程\frac{ dr}{ dt}=v_2\cos \theta-v_1​dt​​dr​​=v​2​​cosθ−v​1​​\fra

2016-07-26 20:32:01 725

原创 hdu 5762 Teacher Bo(鸽巢原理)

思路:虽然有10^5个点,可是两两曼哈顿距离不会超过2*10^5,所以根据鸽巢原理有复杂度为不会超过2*10^5#includeusing namespace std;#define LL long longconst int maxn = 1e5+7;struct point{ int x, y;}p[maxn];int vis[2*maxn];int Dis

2016-07-26 20:28:40 443

原创 HDU 5547 Sudoku(暴力)

思路:4X4的,直接爆搜就好了#include using namespace std;const int maxn = 5;char a[maxn][maxn];int rec[20][2], cnt;bool dfs(int th){ //cout<<"th:"<<th<<endl; if(th>=cnt) return true; int x = rec[t

2016-07-25 21:05:08 597

原创 HDU 5540 Secrete Master Plan(水)

思路:水#include #include #include #include #include #include #include #include #include #include #include #include #define INF 0x3f3f3f3f#define esp 1e-9typedef long long LL;using n

2016-07-25 20:05:13 539

原创 HDU 5551 Huatuo's Medicine(水题)

思路:大概...就是一眼看过去2*n-1...#includeusing namespace std;int main(){ int T,cas=1; scanf("%d",&T); while(T--) { int n; scanf("%d",&n); printf("Case #%d: %d\n",cas++,2*n-1); }}

2016-07-25 19:54:40 706

原创 HDU 5546 Ancient Go(DFS)

思路:找一个连通块如果它只能往外扩展一个空格的话那么就满足题意,所以直接DFS一波就好了#includeusing namespace std;char mp[20][20];int vis[20][20];int dx[] = {0,0,-1,1};int dy[] = {1,-1,0,0};int cnt = 0;int num = 0;void dfs(int x

2016-07-25 19:53:27 512

原创 HDU 5545 The Battle of Guandu(最短路)

思路:首先每次曹操从一个村庄调用一个兵到战场xi时,其实相当于同时往yi战场减少一个兵,如果yi战场的价值度是0的话那么是无所谓的,如果价值是2的话,那么这减少的一个兵你就要通过其他村庄转移来填补这一个减少的兵,否则就会输掉,那么这样一直转移到一个无用的战场,那么就可以满足条件了,所以按照这样建图然后跑一次最短路那么就是最少费用了(一开始以为是网络流什么的...大概数据范围也透露了一点...)

2016-07-25 19:51:55 874

原创 HDU 5543 Pick The Sticks(DP)

思路:显然的背包DP,因为可以加在边界,所以可以多加一维来表示不加在边界,加在左边界和右边界转移就可以了#includeusing namespace std;const int maxn = 4005;#define LL long longLL dp[maxn][4];LL a[maxn],v[maxn];int main(){ int T,cas=1; scan

2016-07-25 19:47:44 623

原创 HDU 5542 The Battle of Chibi(DP+树状数组)

思路:求递增子序列个数为M的方案数,显然有一个很简单的DP是dp[i][j]=sum(dp[i-1][k]) (a[k]#includeusing namespace std;const int maxn = 1005;const int mod = 1e9+7;#define LL long longint dp[maxn][maxn];int a[maxn],b[max

2016-07-25 19:43:46 669

原创 Codeforces Round #364 (Div. 2) D As Fast As Possible(数学)

思路:如果时间最小 那么最后一定是每个人都同时到达终点,设所有人 走路时间都为t1 搭车时间都为t2,那么车子每次回头去载人的时间就是t3=t2*(v2-v1)/(v2+v1)可以列出(num-1)*( t2 + t3 )*v1+t2*v2=L,t2*v2+t1*v1=L,然后解方程就可以了#includeusing namespace std;double l,v1,v2

2016-07-24 20:19:27 765

原创 Codeforces Round #364 (Div. 2) C They Are Everywhere(滑窗)

思路:大白上面有一道和这个很相似的经典尺取法。先O(n)求出总共有多少种字符num。把字符一个一个加到队列,统计队列里面的字符种数,不够num,继续加入,如果够了,更新答案,并且将第一个字符出队,重复上述操作。#includeusing namespace std;const int maxn = 100000+50;char a[maxn];mapvis;int main(

2016-07-24 20:17:30 511

原创 Codeforces Round #364 (Div. 2) B Cells Not Under Attack(数学)

思路:每放一个棋子影响的就是它所在的行和列嘛,那么标记一下哪一些行和列没有被标记的乘起来就是答案了#includeusing namespace std;#define LL long longconst int maxn = 100000+500;int vis1[maxn],vis2[maxn];int main(){ int n,q; scanf("%d

2016-07-24 20:15:30 312

原创 Codeforces Round #364 (Div. 2) A - Cards(水)

思路:水水#includeusing namespace std;int a[105];int vis[105];int main(){ int n; scanf("%d",&n); int sum = 0; for(int i = 1;i<=n;i++) { scanf("%d",&a[i]); sum+=a[i]; } sum/=(n/2);

2016-07-24 20:14:00 441

原创 HDU 4454 Stealing a Cake(暴力计算几何)

思路:直接枚举圆上的角度,然后算点到圆上一点距离和圆上一点到矩形最短距离就可以了...#includeusing namespace std;#define pi acos(-1.0)#define INF 0x7fffffffstruct Point{ double x,y;};Point s,c,recta,rectb,t;double dist(Point a,

2016-07-24 01:11:33 455

原创 HDU 4455 Substrings(dp)

思路:参考别人的博客:dp[i]=dp[i-1]-A+B;                           减的A是最后一个长度为i-1的区间的不同数的个数,这个很容易预处理得出来。                           加的B是第t个数到它上一个数的距离大于i-1的个数.                           这个B值也容易得出。

2016-07-24 01:09:43 298

原创 HDU 4458 Shoot the Airplane(计算几何or数学)

思路:固定飞机不动,那么相当于子弹多了一个水平速度-v,那么就可以将子弹的轨迹看作一条抛物线,枚举抛物线上的点然后判点是否在多边形内即可#includeusing namespace std;const double PI=acos(-1.0);const double eps=1e-10;int dcmp(double x){ if(fabs(x)<eps)re

2016-07-23 21:07:10 590

原创 HDU 4462 Scaring the Birds(状态压缩枚举)

思路:考虑K只有10,压缩一下然后暴力枚举即可,注意的是放稻草人的点是不需要被覆盖的#includeusing namespace std;const int maxn = 150;#define INF 1e9int r[maxn],c[maxn],vis[maxn][maxn],R[maxn];int a[maxn];int n,k;int main(){

2016-07-23 21:04:51 385

原创 HDU 4463 Outlets(最小生成树)

思路:先按题目给的那两个点连一条边,然后剩下的求kruskal就好了#include #include #include #include #include #include #include #include #include #include #include #include #define INF 0x3f3f3f3f#define esp 1e-9

2016-07-23 21:02:50 358

原创 HDU 4461 The Power of Xiangqi(水)

思路:水题#includeusing namespace std;int gan(int n){ int sc = 0; string temp; int flag1 = 0,flag2 = 0; for(int i = 0;i<n;i++) { cin >>temp; if(temp[0]=='A') sc+=16; if (te

2016-07-23 21:01:05 303

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除