-
Bio
最大公约数:
__gcd( , );查找函数:
void find(int k) { int L=1,R=n+1; while(L+1<R) { int mid=(L+R)/2; if(a[mid]==k) return mid; else if(a[mid]>k) R=mid; else L=mid; } if(a[L]>=k) return L; else return R; }STL:
-std=c++11 -Wl,--stack=12345678q.push(1);放进去元素 q.push(2); q.top();有返回值的函数,返回堆里的最大值,不删掉 q.pop() 没有返回值,删掉堆里的最大值。 q.size()返回值为当前堆的大小(堆内元素数量) q.empty()当堆内元素数量为0时,返回值为1。如果元素数量大于0,返回值为0链
//链表的表示 struct Node { int value; int next; }a[N]; int head; //head表示头节点 //链表的生成 void gen() { //头节点的初始化 head=0; a[head].value=n; a[head].next=1; //生成链表 for(int i=1;i<=n;++i) { a[i].value=i; a[i].next=i+1; } a[n].next=0; idx=n; } //链表的遍历 void run() { int now=a[head].next; while(now) { cout<<a[now].value<<' '; now=a[now].next; } cout<<endl; } //链表的删除 void erase(int x) { int last=head,now=a[head].next; while(now&&a[now].value!=x) last=now,now=a[now].next; if(now==0) return; a[last].next=a[now].next; a[head].value--; } //链表的插入,在x的后面加入v void insert(int x,int v) { //查找,定位 int now=a[head].next; while(now&&a[now].value!=x) now=a[now].next; if(now==0) return; //新节点加上去 idx++; a[idx].value=v; a[idx].next=a[now].next; a[now].next=idx; a[head].value++; }栈
//入栈 void push(int x) { stck[++top]=x; } //出栈 void pop() { top--; } //得到栈顶元素 int get_top() { return stck[top]; } //得到栈大小 int length() { return top; } //判断栈是否为空 bool empty() { return top==0; } //STL中栈的基本操作 void run() { stack<int>s; s.push(1); s.push(100); s.push(6); cout<<s.top()<<endl; s.pop(); cout<<s.top()<<endl; cout<<s.size()<<endl; cout<<s.empty()<<endl; //清空操作 while(!s.empty()) s.pop(); }队列
//队列的定义 int q[N],head=1,tail=0; //入队 void push(int x) { q[++tail]=x; } //出队 void pop() { head++; } //获取队头 int get_front() { return q[head]; } //返回队列大小 int get_size() { return tail-head+1; } //判断队列是否为空 bool get_empty() { return head>tail; } void run() { queue<int>q; q.push(1); q.push(3); q.push(6); cout<<q.size()<<endl; cout<<q.front()<<endl; q.pop(); cout<<q.back()<<endl; cout<<q.front()<<endl; }PHY_JZ_2012 18339187092 15139125223 15138006650//"花逝爆零人"归并排序
void gbpx_sort(ll y[],ll l,ll r)//预存数组||左端点||右端点 { if(l>=r) return ;//遇到边界 ll mid=(l+r)/2; gbpx_sort(y,l,mid); gbpx_sort(y,mid+1,r); ll i=l,j=mid+1,k=l;//双指针||预存数组下标 while(i<=mid&&j<=r)//边界终止数组存好 { if(y[i]<=y[j]) temp[k++]=y[i++];//注意是y[i]<=y[j] else { temp[k++]=y[j++]; ans+=(mid-i+1); } //合并数组 ----> "归并" } while(i<=mid) temp[k++]=y[i++]; while(j<=r) temp[k++]=y[j++]; //多余数一并存入 for(int s=l;s<=r;s++) y[s]=temp[s]; //将预存数组中数据移入真正被排序的数组 }光速幂
long long pos(long long x,long long y,long long s) { long long res=1,k=x; while(y) { if(y&1) res=res*k%s; k=k*k%p; y>>=1; } return res; }洛谷(交互暂存) P1161 开灯
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; int x,ans=0; int t; double a; while(n--) { cin>>a>>t; for(int i=1;i<=t;i++) { x=(int)floor(a*i); ans^=x; } } cout<<ans; return 0; } -
Accepted Problems
-
Recent Activities
This person is lazy and didn't join any contests or homework.
Problem Tags
- AtCoder
- 3
- 2016
- 1
- abc171
- 1
- abc206
- 1
- abc225
- 1
- 其他
- 1
- 数学
- 1
- SDOI
- 1
- 组合计数
- 1