随笔分类 - 比赛总结记录
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4454#pragma comment (linker,"/stack:102400000,102400000")#include #include #include #include #include #include #include #include #include #include #include using namespace std;const int MM = 1111;#define inf 0x3f3f3f3f#define pi acos(-1.0)cons
阅读全文
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4317有可能error串包含相互的error串,所以建立fail的时候val的标记也要相互转移。View Code typedef long long ll;ll N;#define mod 1000000009 #define debug puts("wrong");#define ROOT 0const int MAX_NODE=2222;//stringnum*stringlenconst int CHI=2; //儿子数ll dp[222][MAX
阅读全文
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3975View Code
阅读全文
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1837有dp[floor]=sum{dp[floor+i]/6}+1 (1<=i<=6) 可以列出方程,方向分up和down讨论View Code
阅读全文
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4712View Code int N,M;//注意题目说x为正整数,0不算int Extend_euc(int a,int b,int&x,int&y) { if(b==0) {x=1,y=0;return a;} int d=Extend_euc(b,a%b,x,y); int tmp=x; x=y; y=tmp-(a/b)*y; return d;}void modeq(int a,int b,int n) { int e,i,d,x,y,t...
阅读全文
摘要:http://acm.zju.edu.cn/onlinejudge/showSubmission.do?submissionId=3568082View Code //确定king只有一个后可以在O(N)解决每次询问const int MM = 331630;const int maxn = 31;typedef long long int64;#define debug puts("wrong"); int N,M,Q;char ss[MM][100];set<pair<int,int> >sbt;map<string,int>mp;m
阅读全文
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3216View Code //复杂度O(sqrt(N)),蛮有意思的const int MM = 11111;typedef long long int64;int64 N;void solve() { int64 i,j,k,sum=0,tmp; scanf("%lld",&N); for(i=1;(i*i)<=N;i++) { tmp=N/i; sum=sum+i*(N/i-N/(i+1)); if(tmp!=i...
阅读全文
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3221View Code //逆推const int MM = 1111111;#define debug puts("wrong")//typedef __int64 int64;const double lep=1e-10;int N,M, n,m;map<vector<int>,bool>mp;vector<int>st;vector<int>en;void get_data() { int i,j,k
阅读全文
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1686View Code //存在到0边的奇数步的路,则先手胜const int MM = 11111;#define inf 0x3f3f3f3f#define debug puts("wrong")typedef long long int64;int N,M;int num[MM];void get_data() { int i,j,k; scanf("%d",&N); for(i=0;i<N;i++) scanf(
阅读全文
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1684View Code //重新建树,求两点间最短距离const int MM = 11111;#define inf 0x3f3f3f3f#define debug puts("wrong")typedef long long int64;int num[MM], N, tot;int chd[MM], len; //节点的儿子个数bool vis[MM];vector<int>edge[MM];struct Info{int node,s
阅读全文
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2838View Code //对于x,y,z树上的位置进行分类讨论/* z z t t /\ / /\ /\ x y t z y x z /\ / \ x y x y*/const int MM = 55555;int N, M;vector<...
阅读全文
摘要:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=34348View Code const int MM = 11111;#define debug puts("wrong")//typedef __int64 int64;int p[MM]={1,2,5,10,20,50,100,200};int num[MM], g[MM], gg[MM];int N,M,sum=0;void get_data() { int i,j,k; for(i=sum=0;i<8;i++) { scanf("
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1545View Code const int MM = 11111;#define debug puts("wrong")typedef __int64 int64;int N,M;int64 dp[63][11][11];//j min(0-1) k max(0-1)void solve() { int i,j,k;int64 tmp,t1,t2; memset(dp[0],0,sizeof(dp[0])); dp[0][M][M]=1; for(i=1;i<=N;i++) { .
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1544View Code
阅读全文
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4013记忆化搜索,学到啦用map做映射不用担心数组开多大的问题,还有map<vector<int>,int>vis;可以对一个list进行映射,由于10^9以内的素数因子的组合很少,可以记忆化。View Code //记忆化搜索,学到啦用map做映射不用担心数组开多大的问题,还有map<vector<int>,int>vis;//可以对一个list进行映射,由于10^9以内的素数因子的组合很少,可以记忆化。const int M
阅读全文
摘要:http://acm.fzu.edu.cn/problem.php?pid=2107状态压缩DP,dp[i][j][k] 表示前i行j状态,有没有2*2普通放板的问题。深搜枚举的过程中记录当前和转移到的状态。View Code const int MM = 1111;typedef __int64 int64;#define debug puts("wrong")int N,M,L,ans,ss;char str[MM];int num[MM];int dp[10][32][3]; //0 no 1 yesvoid get_data() { int i,j,k; scanf
阅读全文
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=49950-1背包,按照时间排序保证总时间最小。以后写if-else注意多continue,还有0-1背包不需要多加一维。以后注意。View Code const int MM = 1111;#define debug puts("wrong")//typedef __int64 int64;int N,M;int dp[MM][4];struct Info{int t,v;}g[MM];bool cmp(Info x,Info y) {return x.t
阅读全文
摘要:http://acm.timus.ru/problem.aspx?space=1&num=1684kmpView Code const int MM = 1111111;#define debug puts("wrong")typedef __int64 int64;char str[MM], ch[MM];int n,m;int fail[MM], ans[MM], cnt;void get_next(int n) { int i, j=-1; for(fail[0]=-1, i=1;i < n; i++) { while(j>=0 &&
阅读全文
摘要:http://acm.timus.ru/problem.aspx?space=1&num=1682记录取模的余数,并查集。View Code const int MM = 511111;#define debug puts("wrong")typedef __int64 int64;int64 N;bool vis[MM];vector<int64>g[MM];vector<int64>gg[MM]; //^2int64 fa[MM], ran[MM];int64 getfa(int64 x) {return x==fa[x]?x:fa[x]
阅读全文
摘要:http://codeforces.com/problemset/problem/50/C记录出轮廓线,计算出走的长度, ans+4View Code void get_data() { int64 i,j,k; for(i=0;i<N;i++) scanf("%I64d%I64d",&g[i].x,&g[i].y);}void solve() { int64 i,j,k,x,y,ans=0,cnt; cnt=graham(g,N,res); for(i=1;i<cnt;i++) { // printf("%d %d\n",r
阅读全文