10 2013 档案
摘要:题目链接我看错题了。。。都是泪啊,不存在3*4^2这种情况。。。系数必须为1。。。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 #define LL long long 7 int num[60]; 8 LL dp[60][60]; 9 int k,b;10 LL dfs(int pos,int pre,int bound)11 {12 int i,end;13 LL ans = 0;14 if(pos == -1)15 return pre == 0;16 ...
阅读全文
摘要:水题。好久没有写过优化搜索题了。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 char str[31][31]; 7 int r[31][31]; 8 int c[31][31]; 9 int judge(int rx,int ry,int lx,int ly)10 {11 int i,j;12 for(i = lx;i = 1;i --)46 {47 for(j = m;j >= 1;j --)48 {49 fo...
阅读全文
摘要:挺简单的组合把。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 #define LL long long 7 int flag[1001]; 8 int p[1001]; 9 class LittleElephantAndIntervalsDiv110 {11 public :12 LL getNumber(int M, vector L, vector R)13 {14 LL ans = 1;15 int i,j;16 for...
阅读全文
摘要:数位DP的感觉,但是跟模版不是一个套路的,看的题解,代码好理解,但是确实难想。 1 #include 2 #include 3 #include 4 using namespace std; 5 #define LL long long 6 LL dp[31][2][2][2]; 7 int a[31],b[31],c[31]; 8 void fun(int *p,int x) 9 {10 int i;11 for(i = 0; i <= 30; i ++)12 {13 if(x&(1<<i))14 p[i] = 1;15 ...
阅读全文
摘要:题目链接本质上是DP,但是俩变量就搞定了。 1 #include 2 #include 3 #include 4 using namespace std; 5 int p[500001]; 6 bool cmp(int a,int b) 7 { 8 if(a 0)30 p1 = p2 + 1;31 else32 p2 = p1 + 1;33 }34 printf("%d\n",max(p1,p2));35 }36 }
阅读全文
摘要:数位DP部分,不是很难。DP[i][j]前i位j个幸运数的个数。枚举写的有点搓。。。 1 #include 2 #include 3 using namespace std; 4 #define LL __int64 5 #define MOD 1000000007 6 int dp[21][21]; 7 int p[21],num; 8 int o[21]; 9 int dfs(int pos,int pre,int bound) 10 { 11 int ans,i,end; 12 ans = 0; 13 if(pos == -1) 14 ...
阅读全文
摘要:题目链接主要是标记前面素数的最大的DP值,要认真一些。没想到居然写了一个很难发现的错误。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 int o[200001];10 int prim[200001];11 int p[200001];12 int sp[200001];13 int flag[200001];14 int main()15 {16 int i,j,n,num = 1;17 int temp...
阅读全文
摘要:题目链接 1 #include 2 using namespace std; 3 int main() 4 { 5 int n,sum,a,t,i; 6 scanf("%d",&t); 7 while(t--) 8 { 9 scanf("%d",&n);10 sum = 0;11 for(i = 0;i < n;i ++)12 {13 scanf("%d",&a);14 sum += a*(n-1-a);15 }16 ...
阅读全文
摘要:题目链接 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 #define LL long long10 #define MOD 100000000711 int p[1001];12 int judge(int x)13 {14 int str,end,mid;15 if(x x)23 end = mid - 1;24 else25 str = mid;26 ...
阅读全文
摘要:题目链接不知道为什么,我用cin,cout就是过不了。。。改成scanf过了。。。还是我居然理解错题意了,已经不能用看错了。。。至少两个数字,我理解成两个数字了,还写了个爆搜。。。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 #define LL long long10 #define MOD 100000000711 int prim[1000001];12 int o[1000001];13 LL que[5001];...
阅读全文
摘要:题目链接想了一会,应该是跟二项式系数有关系,无奈自己推的式子,构不成二项式的系数。选1个人Cn1*1,选2个人Cn2*2....这样一搞,以为还要消项什么的。。。搜了一下题解,先选队长Cn1,选一个人的时候Cn-1 0,选2个人的时候Cn-1 1这样就构成二项式系数了。一约,n*2^n-1。。。最后,还忘了取模,错了好多次。。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 #define LL long long10 #de...
阅读全文
摘要:题目链接水题,LA我居然没找到在那里。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 #define LL long long10 LL dp[50],bin[50];11 int que[31],s;12 void judge(int x)13 {14 s = 0;15 while(x)16 {17 que[s++] = x%10;18 x /= 10;19 ...
阅读全文
摘要:题目链接 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 char str[1001];10 int flag[4];11 int main()12 {13 int t,cas = 1,i,len,sum,ans;14 scanf("%d",&t);15 while(t--)16 {17 memset(flag,0,sizeof(flag));18 scanf("...
阅读全文
摘要:题目链接脑子抽了,看错题了,神奇的看成没有0了。主要问题把n个数插入m个相同的数,把m个数给分成1-m堆,然后插到n+1空里。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 #define MOD 100000010 #define LL long long11 LL c[21][21];12 int p[21];13 int n;14 LL judge()15 {16 LL ans = 1;17 int i...
阅读全文
摘要:题目链接写写,就ok了。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 #define MOD 100000010 #define LL long long11 int prim[1000001];12 int o[1000001];13 int main()14 {15 int i,j,num = 0,temp;16 LL n;17 for(i = 2;i >n)31 {32 ...
阅读全文
摘要:题目链接思路好想,注意细节。错了很多次。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 #define MOD 100000010 int prim[5001];11 int o[5001];12 int flag[5001];13 int aim[5001];14 int main()15 {16 int t,n,m,i,j,num = 0,minz,temp,cas = 1;17 for(i = 2;i ...
阅读全文
摘要:题目链接很久以前就见过此题,以前看了题解,然后今天写了写,写的真搓。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 int dp2[1001][1001]; 10 int dp5[1001][1001]; 11 int p2[1001][1001]; 12 int p5[1001][1001]; 13 int p[1001][1001]; 14 int que[5001]; 15 int x,y,n,num...
阅读全文
摘要:题目链接居然1Y了,以前写的模拟退火很靠谱啊。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 struct point10 {11 double x,y;12 }p[201];13 int n;14 int a[4] = {0,0,-1,1};15 int b[4] = {1,-1,0,0};16 double dis(double x1,double y1,double x2,double y2)17 {18 ...
阅读全文
摘要:题目链接挺好玩的一个题,1Y。。。 1 #include 2 #include 3 #include 4 using namespace std; 5 int dp[2601][2601]; 6 char s1[50001]; 7 char s2[50001]; 8 int o[26]; 9 char que[5001];10 int main()11 {12 int i,j,len,a,b,num;13 scanf("%s",s1);14 len = strlen(s1);15 for(i = 0; i = 100)22 {23 ...
阅读全文
摘要:题目链接以前做过类似的,USACO,2.3,开始数组开小了,导致数据乱了,然后超数据范围了,。。 1 #include 2 #include 3 #include 4 using namespace std; 5 #define LL __int64 6 LL dp[101][101][101]; 7 LL c[71][71]; 8 int main() 9 {10 int i,j,n,k,u,h;11 for(i = 0; i <= 70; i ++)12 {13 c[i][0] = 1;14 }15 for(i = 1; i <...
阅读全文
摘要:题目链接java的水题,特判啊。。。依旧无法1Y。 1 import java.util.*; 2 import java.math.*; 3 4 public class Main { 5 public static void main(String[] args) { 6 Scanner cin = new Scanner(System.in); 7 int prim[] = new int[100]; 8 int i,j,n,num; 9 num = 0;10 BigInteger ans,temp...
阅读全文
摘要:题目链接水题依旧无法1Y。 1 #include 2 #include 3 #include 4 using namespace std ; 5 #define LL __int64 6 LL gcd(LL a,LL b) 7 { 8 return b == 0?a:gcd(b,a%b); 9 }10 11 int main()12 {13 LL a,b,x,y,t;14 LL str,end,mid;15 scanf("%I64d%I64d%I64d%I64d",&a,&b,&x,&y);16 t = gcd(x,y);17 x = x/.
阅读全文
摘要:题目链接AC了。经典问题,a*x+b*y+c = 0整数点,有些忘记了扩展欧几里德,复习一下。 1 #include 2 #include 3 #include 4 using namespace std ; 5 #define LL __int64 6 LL x,y; 7 LL ext_eulid(LL a,LL b) 8 { 9 LL t,d;10 if(b == 0)11 {12 x = 1;13 y = 0;14 return a;15 }16 d = ext_eulid(b,a%b);17 ...
阅读全文
摘要:题目链接水题,卡了下下精度。 1 #include 2 #include 3 #include 4 using namespace std ; 5 #define PI acos(-1.0) 6 #define eps 1e-8 7 int judge(double x,double y) 8 { 9 double a;10 a = x-y;11 if(a eps)32 {33 swap(ly,ry);34 swap(lx,rx);35 }36 else if(jud...
阅读全文
摘要:题目链接折腾了半天,没想出怎么证明,以前初中老师教过,不知道怎么办,就量量。。。受不了,怒抄模版1Y。。。 1 #include 2 #include 3 using namespace std; 4 #define eps 1e-8 5 struct point 6 { 7 double x,y; 8 }; 9 struct line10 {11 point a,b;12 };13 point intersection(line u,line v)14 {15 point ret = u.a;16 double t = ((u.a.x-v.a.x)*(v....
阅读全文
摘要:可能开始宿舍比较乱,思绪静不下来。。。想了大半个小时,终于确定了应该暴力+DP,然后写了枚举除数,和被除的版本。。这样,还敲错了个字母,第一次提交还100多,修改提交还有75.多,最后想到,貌似不打对啊,改完再交就剩下75了。。。还好,没挂0。。。这样写,还是比较好写的,最后10分钟,开始改,最后4分钟改完。。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 #define LL long long 9 int dp[62][61];10 int g...
阅读全文
摘要:脑子又卡了。。。来一发set的,STL真心不熟。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 int flag[400001]; 7 setse; 8 set::iterator it1,it,it2; 9 int main()10 {11 int i,x,y,num,n,m;12 scanf("%d%d",&n,&m);13 for(i = 1; i <= n; i ++)14 se.insert(i);15 for(i = 1; i <= m...
阅读全文
摘要:题目链接卡了一下精度和内存。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 #define eps 1e-8 9 #define N 100000110 #define LL __int6411 int a[9] = {-1,0,1,-1,0,1,-1,0,1};12 int b[9] = {-1,-1,-1,0,0,0,1,1,1};13 char str[N];14 LL cross(LL x1,LL y1,LL x2,LL y2)15 {16...
阅读全文
摘要:题目链接2Y,模版抄错了一点。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define eps 1e-8 8 #define N 2001 9 struct point10 {11 double x,y;12 }p[N],pre[N],temp[N];13 double a,b,c;14 int n,m;15 void getline(point x,point y)16 {17 a = y.y - x.y;18 b = x.x - y.x;...
阅读全文
摘要:题目链接小小的模拟一下。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 char str[1000]; 8 double a[10]; 9 double b[10];10 void CL()11 {12 a[0] = a[2] = 0.0;13 a[4] = a[5] = sqrt(2.0)/2.0;14 a[1] = 1.0;15 a[3] = -1.0;16 a[6] = a[7] = -sqrt(2.0)/2.0;17 ...
阅读全文
摘要:题目链接抄的外心模版。然后,输出认真一点。1Y。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define eps 1e-8 8 struct point 9 {10 double x,y;11 };12 struct line13 {14 point a,b;15 };16 point intersection(line u,line v)17 {18 point ret = u.a;19 double t = ((u.a.x-v.a...
阅读全文
摘要:题目链接回忆了一下,半平面交,整理了一下模版。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define eps 1e-8 8 #define N 2001 9 struct point10 {11 double x,y;12 }p[N],temp[N],pre[N];13 int n,m;14 double a,b,c;15 void getline(point x,point y)16 {17 a = y.y - x.y;18 b = x....
阅读全文
摘要:题目链接很简单的一题,数据 很小,直接暴力的。但是也是写也好久,有几个数,没算好。。。一次CE,一次PE,3Y。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define eps 1e-8 8 #define zero(x) (((x) > 0?(x):-(x))<eps) 9 int o[200];10 struct point11 {12 double x,y;13 } p[1001];14 double dis(point p1,point p2)15 ...
阅读全文
摘要:题目链接抄的模版,居然1Y了。就是简单的线段相交+并查集。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define eps 1e-8 8 #define zero(x) (((x) > 0?(x):(-x)) eps;35 }36 int interset_in(line u,line v)37 {38 if(!dots_online(u.a,u.b,v.a)||!dots_online(u.a,u.b,v.b))39 return !same_si...
阅读全文
摘要:题目链接切计算几何,感觉计算几何的算法还不熟。此题,枚举线段和圆点的直线,平分一个圆 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define eps 1e-8 8 struct point 9 {10 double x,y;11 }p[201];12 double dis(point p1,point p2)13 {14 return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));15 }...
阅读全文
摘要:题目链接 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 int dp[101][101]; 9 char str[101];10 int judge(int x,int y)11 {12 if(str[x] == '['&&str[y] == ']')13 return 1;14 else if(str[x] == '('&&str[y] == ')')15 ret
阅读全文
摘要:题目链接去年杭州现场赛的神题。。枚举角度。。精度也不用注意。。#include #include #include #include #include #include using namespace std;#define eps 1e-8#define PI 3.1415926double xl,xr,yl,yr;double judge(double tx,double ty){ if(tx = xl&&tx = yr) return ty - yr; else if(tx >= xl&&tx xr&&ty > yr) retu
阅读全文
摘要:题目链接只要会做,周长并,这题肯定有思路。有个小地方敲错了,细心啊,扫描线,有一段时间没写过了,还有注意排序的问题,很重要。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 #define LL __int64 9 #define lson l,m,rt S.c; 26 else if(c == 1) 27 return h > S.h; 28 else if(...
阅读全文
摘要:题目链接这题,关键不是二分,而是如果在t的时间内,将n个头,刷完这m个磁盘。看了一下题解,完全不知怎么弄。用一个指针从pre,枚举m,讨论一下。只需考虑,每一个磁盘是从右边的头,刷过来的(左边来的之前刷了)。思维是硬伤。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 #define LL __int64 9 LL p[100001],h[100001];10 int n,m;11 int judge(LL x)12 {13 int pre ...
阅读全文
摘要:题目链接想了挺久,枚举每一件物品,当做关键物品,假设再加这一件物品,就>=c了,把剩下的物品背一下包,dp[i][j]表示i个物品可以组成重量j的个数。这样就可以知道前面放i件,后边肯定放n-i-1件,乱搞搞,算double,边乘边算保证不要越界。最后注意,LL和sum 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 #define LL __int64 9 LL dp[2][51][101];10 int p[51];11 int main()12 {13 in...
阅读全文
摘要:我只能说的亏没做,要不就挂0了。。本来想四色定理,肯定4就可以的。。。然后准备爆,发现3的时候不好爆,又想了老一会,嗯,数据范围不小,应该不是暴力,直接找规律,貌似最大就是3,有一个3连块,输出3,其他输出2什么的。交,发现有环的时候,特殊的也是3。。。没办法还得暴力啊。暴力2的情况,写的也是各种错误。。。终于过了。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 char p[51][51]; 9 int o[51][51];10 int mp[2...
阅读全文
摘要:很棒的DP,不过没想出,看题解了。。思维很重要。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 int dp[1000010]; 9 int sum[51];10 class MayTheBestPetWin11 {12 public :13 int calc(vector A, vector B)14 {15 int i,j,s1,s2;16 s1 = s2 = 0;17 ...
阅读全文
摘要:题目链接做题, 1 #include 2 #include 3 #include 4 using namespace std; 5 #define MOD 20090717 6 int trie[351][26]; 7 int o[351]; 8 int fail[351]; 9 int que[351]; 10 int dp[2][351][1024]; 11 int flag[1024]; 12 int t; 13 void CL() 14 { 15 memset(trie,-1,sizeof(trie)); 16 memset(dp,0,sizeo...
阅读全文
摘要:非常幸运。。第三题,有个地方没想清楚,枚举一下就行了。。x to n,这个x没考虑好,跪了。。。傻傻的lock了代码,通过hack进了DIV1,5-2 。第一次进入DIV1,记录一下。不知不觉,已经是第34场,CF了。
阅读全文

浙公网安备 33010602011771号