其他
ndsffx501ccy
这个作者很懒,什么都没留下…
展开
-
3629: [JLOI2014]聪明的燕姿 (搜索+筛法)
#include#include#include#include#include#includeusing namespace std;#define inf 0x7fffffffconst int maxn = 1000005;int s, n, sqrts, tot, ans[maxn], p[maxn];bool flag[maxn];void Get_Prime(原创 2014-07-30 09:17:42 · 955 阅读 · 0 评论 -
1650: [Usaco2006 Dec]River Hopscotch 跳石子 (二分法)
#include#include#includeusing namespace std;int L,n,m,ans,a[50005];bool jud(int x){ int tot=0; if(tot>m)return 0; int last=0; for(int i=1;i<=n;i++) if(a[i]-a[last]<x){ tot++; if(tot>m原创 2014-10-18 18:53:01 · 245 阅读 · 0 评论 -
1697: [Usaco2007 Feb]Cow Sorting牛排序 (置换群)
#include#include#include#includeusing namespace std;inline int read(){ int x=0,f=1;char ch=getchar(); while(ch'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0'原创 2014-10-18 18:53:54 · 216 阅读 · 0 评论 -
3251: 树上三角形
#include#include#include#define ll long longusing namespace std;int read(){ int x=0,f=1;char ch=getchar(); while(ch'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+c原创 2014-10-31 20:55:27 · 253 阅读 · 0 评论 -
1635: [Usaco2007 Jan]Tallest Cow 最高的牛 (差分序列)
#include#includeusing namespace std;struct que{ int l,r;}q[20001];inline bool cmp(que a,que b){ return a.l<b.l||(a.l==b.l&&a.r<b.r);}int n,I,h,r,sum,a[100001];int main(){ scanf("%d%d%d%d",&原创 2014-10-19 19:04:09 · 290 阅读 · 0 评论 -
1119: [POI2009]SLO (置换群)
#include#include#include#include#define ll long longusing namespace std;inline int read(){ int x=0,f=1;char ch=getchar(); while(ch'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&c原创 2014-10-18 18:58:08 · 337 阅读 · 0 评论 -
1637: [Usaco2007 Mar]Balanced Lineup (前缀和)
#include#include#include#includeusing namespace std;const int add=50000;int n,ans,s[50001],pre[100001];pair a[50001];inline int read(){ int x=0,f=1;char ch=getchar(); while(ch'9'){if(c原创 2014-10-19 19:05:12 · 296 阅读 · 0 评论 -
3431: [Usaco2014 Jan]Bessie Slows Down (模拟)
#include#include#includeusing namespace std;int read() { int x=0,f=1; char ch=getchar(); while(ch'9') { if(ch=='-')f=-1; ch=getchar(); } while(ch>='0'&&ch<='9')原创 2014-11-02 11:39:36 · 24535 阅读 · 0 评论 -
1146: [CTSC2008]网络管理Network (线段树套平衡树+二分+树链剖分)
O(nlogn^4)#include#include#includeusing namespace std;inline int read(){ int x=0,f=1;char ch=getchar(); while(ch'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getc原创 2014-11-11 10:00:28 · 678 阅读 · 0 评论 -
Vijos P1780 开车旅行 (倍增+Treap)
#include#include#include#include#include#include#define inf 1000000001using namespace std;int n,m,NOW,a[200010],x0,Si[100001],Xi[100001],sz,rt,tmp,tmp2,da[200010][18],db[200010][18],to[200010]原创 2014-11-06 11:40:16 · 684 阅读 · 0 评论 -
1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
#includeint n,ans;int main(){ scanf("%d",&n); while(n!=1){ if(n&1)n=n*3+1; else n/=2; ans++; } printf("%d",ans);}原创 2014-09-29 21:18:08 · 337 阅读 · 0 评论 -
3043: IncDec Sequence (中位数)
#include#includeusing namespace std;int n,a[100001];long long x,y,ans;int main(){ scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]); for(int i=2;i<=n;i++){ int delta=a[i]-a[i-1]; i原创 2014-09-11 20:18:49 · 1339 阅读 · 0 评论 -
2548: [Ctsc2002]灭鼠行动 (模拟)
#include#define SQR(x) ((x)*(x)using namespace std;const int maxn = 1000001;inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch '9') { if (ch == '-')f = -1;原创 2014-08-07 23:45:50 · 591 阅读 · 0 评论 -
1009: [HNOI2008]GT考试 (Kmp+Dp+矩阵乘法+快速幂)
#includeusing namespace std;inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch '9') { if (ch == '-')f = -1; ch = getchar(); } while (ch >= '0'原创 2014-08-14 18:38:50 · 410 阅读 · 0 评论 -
3545: [ONTAK2010]Peaks (Treap+离线处理+并查集+启发式合并)
#includeusing namespace std;inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch '9') { if (ch == '-')f = -1; ch = getchar(); } while (ch >= '0'原创 2014-08-15 23:36:10 · 457 阅读 · 0 评论 -
1046: [HAOI2007]上升序列 (动态规划+二分)
#includeusing namespace std;inline int read(){ int x=0,f=1;char ch=getchar(); while(ch'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f原创 2014-08-26 20:36:10 · 449 阅读 · 0 评论 -
2295: 【POJ Challenge】我爱你啊 (暴力)
#includeusing namespace std;char ch[100001];int T;inline int cal(){ int sum=0; char str[]="luvletter"; for(int i=0,k=0;i<(int)strlen(ch);++i){ if(str[k]==ch[i])++k; if(k==9)++sum,k=0; } r原创 2014-08-26 23:05:44 · 599 阅读 · 0 评论 -
藏妹子之处
#include#include#define mod 1000000007using namespace std;int n,m,mn,mx,tx[10001],ty[10001];long long ans;int main(){ freopen("excel.in","r",stdin); freopen("excel.out","w",stdout); cin>>n>>m原创 2014-09-06 17:21:09 · 385 阅读 · 0 评论 -
1045: [HAOI2008] 糖果传递 (中位数)
#include using namespace std;const int maxn = 1000001;long long n, sum, ans, a[maxn], need[maxn];inline void solve(long long a[], long long ave){ need[1] = ave - a[1]; for (int i = 2; i <=原创 2014-09-06 23:12:48 · 534 阅读 · 0 评论 -
2719: [Violet 4]银河之星 (DFS+Hash)
#include #include #include #include #define ll long longusing namespace std;const int xx[4] = {0, 1, 1, 1} , yy[4] = {1, -1, 0, 1};int n, m, k, xt, yt, sz, ans[1005];ll bin[15], bg, ed;bool m原创 2014-09-11 20:14:43 · 604 阅读 · 0 评论 -
1857: [Scoi2010]传送带 (三分法)
三分法套三分法。#include#define eps 1e-3#define dinf 1000000000using namespace std;double ax,ay,bx,by,cx,cy,dx,dy,va,vb,vc,k1,b1,k2,b2,len1,len2,rev1=1,rev2=1;inline double F(double x,double k,double b原创 2014-09-06 22:05:52 · 456 阅读 · 1 评论 -
2016: [Usaco2010]Chocolate Eating (二分法,贪心)
二分最小快乐值后判定。#include#include#define ll long longusing namespace std;ll read() { ll x=0,f=1; char ch=getchar(); while(ch'9') { if(ch=='-')f=-1; ch=getchar(); }原创 2014-10-25 10:52:46 · 330 阅读 · 0 评论 -
2079: [Poi2010]Guilds
存在度数为0的点则误解。原创 2014-10-25 14:12:27 · 299 阅读 · 0 评论 -
1603: [Usaco2008 Oct]打谷机
#include#includeusing namespace std;inline int read(){ int x=0,f=1;char ch=getchar(); while(ch'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}原创 2014-06-19 18:17:21 · 406 阅读 · 0 评论 -
3626: [LNOI2014]LCA (树链剖分+离线处理)
#include#include#include#includeusing namespace std;inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch '9') { if (ch == '-')f = -1; ch = getchar();原创 2014-07-29 11:56:22 · 472 阅读 · 0 评论 -
1679: [Usaco2005 Jan]Moo Volume 牛的呼声 (差分序列)
#include #include #include #include #define inf 0x7fffffff #define MAXN 100001using namespace std;inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch '9') {原创 2014-07-06 23:46:33 · 744 阅读 · 0 评论 -
快速乘模板
#include#define ll unsigned long longusing namespace std;ll a,b,p;ll mult(ll t,ll k){ ll f=0; for(;k;k>>=1,t=(t+t)%p)if(k&1)f=(f+t)%p; return f;}int main(){ cin>>a>>b>>p; cout<<mult(a,b);原创 2014-07-22 10:58:43 · 327 阅读 · 0 评论 -
1005: [HNOI2008]明明的烦恼 (prufer编码,排列组合,质因数分解,高精度)
#include#include#include#include#define mod 1000000#define ll long long using namespace std;inline int read(){ int x=0,f=1;char ch=getchar(); while(ch'9'){if(ch=='-')f=-1;ch=getchar();原创 2014-07-21 18:17:09 · 431 阅读 · 0 评论 -
1211: [HNOI2004]树的计数 (prufer编码,排列组合,质因数分解)
明明的烦恼简化版。#include#include#include#include#include#include#define inf 0x7fffffff#define ll long longusing namespace std;inline int read(){ int x=0,f=1;char ch=getchar(); while(ch'9')原创 2014-07-21 23:30:23 · 573 阅读 · 0 评论 -
C++ unique 模板
#include#include#includeusing namespace std;inline int read(){ int x=0,f=1;char ch=getchar(); while(ch'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getch原创 2014-07-15 13:23:59 · 386 阅读 · 0 评论 -
2506: calc
#include#include#includeusing namespace std;inline int read(){ int x=0,f=1;char ch=getchar(); while(ch'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch原创 2014-05-29 21:05:05 · 421 阅读 · 0 评论 -
【9018p1316】SPY(辽宁省赛2010)
http://218.5.5.242:9018/JudgeOnline/problem.php?id=1316#include #include #include #include using namespace std; int a,b,c; string sa[1005],sb[1005],sc[1005]; bool checka(int x){ for(int原创 2014-03-21 17:38:30 · 545 阅读 · 0 评论 -
2321: [BeiJing2011集训]星器
#include#includeusing namespace std;inline int read(){ int x=0,f=1;char ch=getchar(); while(ch'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}原创 2014-06-19 18:17:57 · 374 阅读 · 0 评论 -
1754: [Usaco2005 qua]Bull Math (高精度乘法)
a,b=input(),input()print a*b原创 2014-07-12 22:25:45 · 355 阅读 · 0 评论 -
【noip模拟赛】数位和乘积
#include#includeusing namespace std;int n,k,t,a1,a2,a3,a4,a[32][20][20][12][105],x[105],y[105],ans[105];void add(int *a,int *b){ for(int i=1;i<=100;i++)a[i]+=b[i]; for(int i=1;i<=100;i++)a[i+1]+原创 2014-09-13 23:05:31 · 281 阅读 · 0 评论 -
【noip模拟赛】环上的游戏
http://codevs.cn/problem/1037/#include#includeusing namespace std;int n,a[21],len1,len2;int main(){ scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]); for(int i=1;i<=n;i++){ if(!a[i原创 2014-09-13 17:50:48 · 276 阅读 · 0 评论 -
3101: N皇后
#includeint n;int main(){ scanf("%d",&n); if(n%6!=2&&n%6!=3){ for(int i=2;i<=n;i+=2)printf("%d\n",i); for(int i=1;i<=n;i+=2)printf("%d\n",i); } else{ int k=n/2; if(k&1){原创 2014-07-15 21:23:00 · 425 阅读 · 0 评论 -
3293: [Cqoi2011]分金币 (中位数)
#include#include#include#include#define inf 0x7fffffffusing namespace std;inline int read(){ int x=0,f=1;char ch=getchar(); while(ch'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&原创 2014-07-13 19:43:55 · 588 阅读 · 0 评论 -
1753: [Usaco2005 qua]Who's in the Middle (快速排序)
#include#includeint n,a[10001];int main(){ scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]); std::sort(a+1,a+n+1); printf("%d",a[(n+1)/2]); return 0;}原创 2014-07-12 22:35:46 · 334 阅读 · 0 评论 -
[Poj2420]A Star not a Tree? (爬山算法||模拟退火算法)
#include#include#include#define inf 0x7fffffffusing namespace std;inline int read(){ int x=0,f=1;char ch=getchar(); while(ch'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9')原创 2014-07-12 20:52:50 · 460 阅读 · 0 评论