A - Buy and Resell

HDU - 6438

The Power Cube is used as a stash of Exotic Power. There are nn cities numbered 1,2,…,n1,2,…,n where allowed to trade it. The trading price of the Power Cube in the ii-th city is aiai dollars per cube. Noswal is a foxy businessman and wants to quietly make a fortune by buying and reselling Power Cubes. To avoid being discovered by the police, Noswal will go to the ii-th city and choose exactly one of the following three options on the ii-th day:

1. spend aiai dollars to buy a Power Cube 
2. resell a Power Cube and get aiai dollars if he has at least one Power Cube 
3. do nothing

Obviously, Noswal can own more than one Power Cubes at the same time. After going to the nn cities, he will go back home and stay away from the cops. He wants to know the maximum profit he can earn. In the meanwhile, to lower the risks, he wants to minimize the times of trading (include buy and sell) to get the maximum profit. Noswal is a foxy and successful businessman so you can assume that he has infinity money at the beginning. 

InputThere are multiple test cases. The first line of input contains a positive integer TT (T≤250T≤250), indicating the number of test cases. For each test case: 
The first line has an integer nn. (1≤n≤1051≤n≤105) 
The second line has nn integers a1,a2,…,ana1,a2,…,an where aiai means the trading price (buy or sell) of the Power Cube in the ii-th city. (1≤ai≤1091≤ai≤109) 
It is guaranteed that the sum of all nn is no more than 5×1055×105. 
OutputFor each case, print one line with two integers —— the maximum profit and the minimum times of trading to get the maximum profit.Sample Input

3
4
1 2 10 9
5
9 5 9 10 5
2
2 1

Sample Output

16 4
5 2
0 0

Hint

In the first case, he will buy in 1, 2 and resell in 3, 4. 

  profit = - 1 - 2 + 10 + 9 = 16
In the second case, he will buy in 2 and resell in 4. profit = - 5 + 10 = 5
In the third case, he will do nothing and earn nothing. profit = 0

利用pq贪心去看看那天选择了

#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define lson l,(l+r)/2,rt<<1
#define rson (l+r)/2+1,r,rt<<1|1
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define pb push_back
#define val first
#define pos second
#define ll long long
#define sz(x) (int)(x).size()
#define pll pair<long long,long long>
#define pii pair<int,int>
const int N=1e5+,MD=1e9+,INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const double eps=1e-,e=exp(),PI=acos(-.);
struct T
{
int v,cnt;
friend bool operator <(T a,T b)
{
if(a.v==b.v) return a.cnt<b.cnt;
return a.v>b.v;
}
};
priority_queue<T>Q;
int main()
{
ios::sync_with_stdio(false),cin.tie(),cout.tie();
int T,n;
cin>>T;
while(T--)
{
cin>>n;
ll ans=,cnt=;
for(int i=,x,y; i<=n; i++)
{
cin>>x;
if(!Q.empty())
{
y=Q.top().v;
if(y<x)Q.pop(),ans+=x-y,Q.push({x,});
}
Q.push({x,});
}
while(!Q.empty())cnt+=Q.top().cnt,Q.pop();
cout<<ans<<" "<<cnt*<<"\n";
}
return ;
}

CF上的神仙代码

#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define lson l,(l+r)/2,rt<<1
#define rson (l+r)/2+1,r,rt<<1|1
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define pb push_back
#define val first
#define pos second
#define ll long long
#define sz(x) (int)(x).size()
#define pll pair<long long,long long>
#define pii pair<int,int>
const int N=1e5+,MD=1e9+,INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const double eps=1e-,e=exp(),PI=acos(-.);
multiset<pll> pq,se1,se2;
int main()
{
ios::sync_with_stdio(false),cin.tie(),cout.tie();
int T,n;
cin>>T;
while(T--)
{
pq.clear(),se1.clear(),se2.clear();
cin>>n;
for(int i=,x,y; i<=n; i++)
{
cin>>x;
pq.insert({x, i});
y=(*pq.begin()).val;
if(y<x)
{
if(se2.empty()||(*se2.begin()).val>y)
{
se1.insert(*pq.begin());
pq.erase(pq.begin());
se2.insert({x,i});
pq.erase(pq.find({x,i}));
}
else
{
pq.insert(*se2.begin());
se2.erase(se2.begin());
se2.insert({x,i});
pq.erase(pq.find({x,i}));
}
}
else if(!se2.empty()&&(*se2.begin()).val < x)
{
pq.insert(*se2.begin());
se2.erase(se2.begin());
se2.insert({x,i});
pq.erase(pq.find({x,i}));
}
}
ll a=;
for(auto X:se1)a-=X.val;
for(auto X:se2) a+=X.val;
cout<<a<<" "<<se1.size()+se2.size()<<endl;
}
return ;
}

C - Dream

HDU - 6440

Freshmen frequently make an error in computing the power of a sum of real numbers, which usually origins from an incorrect equation (m+n)p=mp+np(m+n)p=mp+np, where m,n,pm,n,p are real numbers. Let's call it ``Beginner's Dream''.

For instance, (1+4)2=52=25(1+4)2=52=25, but 12+42=17≠2512+42=17≠25. Moreover, 9+16−−−−−√=25−−√=59+16=25=5, which does not equal 3+4=73+4=7.

Fortunately, in some cases when pp is a prime, the identity

(m+n)p=mp+np(m+n)p=mp+np

holds true for every pair of non-negative integers m,nm,n which are less than pp, with appropriate definitions of addition and multiplication.

You are required to redefine the rules of addition and multiplication so as to make the beginner's dream realized.

Specifically, you need to create your custom addition and multiplication, so that when making calculation with your rules the equation (m+n)p=mp+np(m+n)p=mp+np is a valid identity for all non-negative integers m,nm,n less than pp. Power is defined as

ap={1,ap−1⋅a,p=0p>0ap={1,p=0ap−1⋅a,p>0

Obviously there exists an extremely simple solution that makes all operation just produce zero. So an extra constraint should be satisfied that there exists an integer q(0<q<p)q(0<q<p) to make the set {qk|0<k<p,k∈Z}{qk|0<k<p,k∈Z} equal to {k|0<k<p,k∈Z}{k|0<k<p,k∈Z}. What's more, the set of non-negative integers less than pp ought to be closed under the operation of your definitions.

Hint

Hint for sample input and output: 
From the table we get 0+1=10+1=1, and thus (0+1)2=12=1⋅1=1(0+1)2=12=1⋅1=1. On the other hand, 02=0⋅0=002=0⋅0=0, 12=1⋅1=112=1⋅1=1, 02+12=0+1=102+12=0+1=1. 
They are the same. 

InputThe first line of the input contains an positive integer T(T≤30)T(T≤30)indicating the number of test cases.

For every case, there is only one line contains an integer p(p<210)p(p<210), described in the problem description above. pp is guranteed to be a prime. 
OutputFor each test case, you should print 2p2p lines of pp integers.

The jj-th(1≤j≤p1≤j≤p) integer of ii-th(1≤i≤p1≤i≤p) line denotes the value of (i−1)+(j−1)(i−1)+(j−1). The jj-th(1≤j≤p1≤j≤p) integer of (p+i)(p+i)-th(1≤i≤p1≤i≤p) line denotes the value of (i−1)⋅(j−1)(i−1)⋅(j−1). 
Sample Input

1
2

Sample Output

0 1
1 0
0 0
0 1

构造一个群满足上述条件

#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define lson l,(l+r)/2,rt<<1
#define rson (l+r)/2+1,r,rt<<1|1
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define pb push_back
#define fi first
#define se second
#define ll long long
#define sz(x) (int)(x).size()
#define pll pair<long long,long long>
#define pii pair<int,int>
#define pq priority_queue
const int N=1e5+,MD=1e9+,INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const double eps=1e-,e=exp(),PI=acos(-.);
int a[N];
int main()
{
ios::sync_with_stdio(false),cin.tie(),cout.tie();
int T;
cin>>T;
while(T--)
{
int p;
cin>>p;
for(int i=; i<p; i++)
{
for(int j=; j<p; j++)
cout<<" "<<(i+j)%p;
cout<<"\n";
}
for(int i=; i<p; i++)
{
for(int j=; j<p; j++)
cout<<" "<<(i*j)%p;
cout<<"\n";
}
}
return ;
}

E - GuGu Convolution

HDU - 6442

As a newbie, XianYu is now learning generating function! 
Given a series {a}=(a0,a1,a2,⋯){a}=(a0,a1,a2,⋯), we can easily define its exponential generating function as g{a}(x)=∑i=0∞aii!xig{a}(x)=∑i=0∞aii!xi. 
Now we define a series {uc}=(c0,c1,c2,⋯){uc}=(c0,c1,c2,⋯) and let ecec represents the ucuc with 00 filled in all its even items. Formally, {ec}=(0,c1,0,c3,0,c5,⋯){ec}=(0,c1,0,c3,0,c5,⋯).

'Do you know convolution?' 
'GU GU.' GuGu utters. 
'Well, let me show you. 
Given two generating function g{a}g{a} and g{b}g{b}, the convolution can be represented as G(x)=(g{a}∗g{b})(x)=∑n=0∞(∑i+j=naibj)xnG(x)=(g{a}∗g{b})(x)=∑n=0∞(∑i+j=naibj)xn. 
It is quite easy, right?' 
'GU GU.' GuGu utters. 
'Ok. Now you have to find the coefficient of xnxn of the convolution G(x)=(g{uA}∗g{eB√})G(x)=(g{uA}∗g{eB}), given nn, AA and BB. 
Let GnGn representes that coefficient, you should tell me n!Gnn!Gn. 
You may know the severity of unsolving this problem.'

As GuGu is not that kind of good for it, it turns to you for help. 
'GU GU!' GuGu thanks.

Hint

First Sample: 1!(100!1–√11!+111!00!)=11–√1!(100!111!+111!00!)=11 
Second Sample: 2!(52300!02!+52311!12−−√11!+52322!00!)=20923–√2!(52300!02!+52311!1211!+52322!00!)=20923 
P.S.: 104612−−√104612 is equal to the answer. However, 1212 has a factor 4=224=22 so it can't be output directly. 

InputThere is an integer TT in the first line, representing the number of cases. 
Then followed TT lines, and each line contains four integers A,B,n,pA,B,n,p. The meaning of A,B,nA,B,n is described above, and that of ppwill be described in Output session. 
1≤T≤1051≤T≤105 
1≤A,B≤1061≤A,B≤106 
1≤n≤10181≤n≤1018 
1≤p≤1091≤p≤109OutputLet ∑i=1qaibi−−√∑i=1qaibi represents the answer, with bi≠bj,gcd(bi,bj)=1,1≤i<j≤qbi≠bj,gcd(bi,bj)=1,1≤i<j≤q, and none of bibi's factors is square number. 
Print TT lines only. Each line comes with a number qq and followed qqpairs of integers aiai bibi, with bibi in increasing order. Since aiai may be large, please print ai%pai%p instead. All integers in the same line should be seperated by exactly one space. 
You may find that each answer is unique. 
Sample Input

3
1 1 1 7
523 12 2 2100
1 1 1000000000000000000 998244353

Sample Output

1 1 1
1 2092 3
1 121099884 1

公式变换,然后作差

为了避免求逆出现问题,*2又/2

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int>v;
bool f[];
int la(int n)
{
if(n==) return ;
int res=;
for(auto i:v)
{
if(n%i==)
{
int num=;
while(n%i==)
{
n/=i;
if(num&) res*=i;
num++;
}
}
if(i*i>n) break;
}
return res;
} ll qmi(ll p,ll q,ll n,ll mod,ll B)
{
ll a=,b=,t1,t2;
while(n)
{
if (n&)
{
t1=(a*p+b*q%mod*B)%mod;
t2=(a*q+b*p)%mod;
a=t1;
b=t2;
}
t1=(p*p+q*q%mod*B)%mod;
t2=(p*q*)%mod;
p=t1;
q=t2;
n>>=;
}
return b;
}
int main()
{
for(int i=; i<; i++)
if(!f[i])
{
v.push_back(i);
for (int j=i+i; j<; j+=i) f[j]=;
}
ios::sync_with_stdio(false),cin.tie(),cout.tie();
int T;
ll n,A,B,p,ans;
cin>>T;
while(T--)
{
cin>>A>>B>>n>>p;
p*=;
ans=(qmi(A,,n,p,B)-qmi(A,-,n,p,B)+p)%p;
ans/=,p/=;
int k=la(B);
cout<<<<" "<<ans*k%p<<" "<<B/k/k<<"\n";
}
}

G - Neko's loop

HDU - 6444

Neko has a loop of size nn. 
The loop has a happy value aiai on the i−th(0≤i≤n−1)i−th(0≤i≤n−1) grid. 
Neko likes to jump on the loop.She can start at anywhere. If she stands at i−thi−th grid, she will get aiai happy value, and she can spend one unit energy to go to ((i+k)modn)−th((i+k)modn)−th grid. If she has already visited this grid, she can get happy value again. Neko can choose jump to next grid if she has energy or end at anywhere. 
Neko has mm unit energies and she wants to achieve at least ss happy value. 
How much happy value does she need at least before she jumps so that she can get at least ss happy value? Please note that the happy value which neko has is a non-negative number initially, but it can become negative number when jumping.

InputThe first line contains only one integer T(T≤50)T(T≤50), which indicates the number of test cases. 
For each test case, the first line contains four integers n,s,m,k(1≤n≤104,1≤s≤1018,1≤m≤109,1≤k≤n)n,s,m,k(1≤n≤104,1≤s≤1018,1≤m≤109,1≤k≤n). 
The next line contains nn integers, the i−thi−th integer is ai−1(−109≤ai−1≤109)ai−1(−109≤ai−1≤109) 
OutputFor each test case, output one line "Case #x: y", where x is the case number (starting from 1) and y is the answer.Sample Input

2
3 10 5 2
3 2 1
5 20 6 3
2 3 2 1 5

Sample Output

Case #1: 0
Case #2: 2

求一个环的最大值,有两种情况,用滑窗维护下吧

#include<bits/stdc++.h>
using namespace std;
const int MAX=1e4+;
const int MOD=1e9+;
const double PI=acos(-1.0);
typedef long long ll;
ll a[MAX];
ll sum[MAX];
int v[MAX];
vector<ll>p;
deque<int>que;
ll cal(ll m)
{
int len=p.size();
for(int i=; i<len; i++)p.push_back(p[i]); //扩大2倍
for(int i=; i<p.size(); i++)sum[i]=(i==?p[i]:sum[i-]+p[i]);
int y=m%len;
ll ans=;
while(!que.empty())que.pop_back();
for(int i=,R=; i<len; i++) //先走m/len圈
{
while(!que.empty()&&que.back()<i)que.pop_back();
while(R<=i+y-)
{
while(!que.empty()&&sum[que.front()]<=sum[R])que.pop_front();
que.push_front(R);
R++;
}
int x=que.back();
ll res=max(0ll,sum[x]-(i==?:sum[i-]));
ans=max(ans,res+max(0ll,m/len*sum[len-]));
}
if(m>=len) //先找到最大值所需步数x,再走(m-x)/len圈
{
while(!que.empty())que.pop_back();
for(int i=,R=; i<len; i++)
{
while(!que.empty()&&que.back()<i)que.pop_back();
while(R<=i+len-)
{
while(!que.empty()&&sum[que.front()]<=sum[R])que.pop_front();
que.push_front(R);
R++;
}
int x=que.back();
ll res=max(0ll,sum[x]-(i==?:sum[i-]));
ans=max(ans,res+max(0ll,(m-(x-i+))/len*sum[len-]));
}
}
return ans;
}
int main()
{
int T,cas=;
cin>>T;
while(T--)
{
ll n,s,m,k;
scanf("%lld%lld%lld%lld",&n,&s,&m,&k);
for(int i=; i<n; i++)scanf("%lld",&a[i]);
for(int i=; i<n; i++)v[i]=;
ll ans=s;
for(int i=; i<n; i++)
{
if(v[i])continue;
p.clear();
int j=i;
while(v[j]==) //找出循环节里的数并计算答案
{
v[j]=;
p.push_back(a[j]);
j=(j+k)%n;
}
ans=min(ans,max(s-cal(m),0ll));
}
printf("Case #%d: %lld\n",cas++,ans);
}
return ;
}

I - Tree and Permutation

HDU - 6446

There are NN vertices connected by N−1N−1 edges, each edge has its own length. 
The set { 1,2,3,…,N1,2,3,…,N } contains a total of N!N! unique permutations, let’s say the ii-th permutation is PiPi and Pi,jPi,j is its jj-th number. 
For the ii-th permutation, it can be a traverse sequence of the tree with NN vertices, which means we can go from the Pi,1Pi,1-th vertex to the Pi,2Pi,2-th vertex by the shortest path, then go to the Pi,3Pi,3-th vertex ( also by the shortest path ) , and so on. Finally we’ll reach the Pi,NPi,N-th vertex, let’s define the total distance of this route as D(Pi)D(Pi) , so please calculate the sum of D(Pi)D(Pi) for all N!N!permutations.

InputThere are 10 test cases at most. 
The first line of each test case contains one integer NN ( 1≤N≤1051≤N≤105 ) . 
For the next N−1N−1 lines, each line contains three integer XX, YY and LL, which means there is an edge between XX-th vertex and YY-th of length LL ( 1≤X,Y≤N,1≤L≤1091≤X,Y≤N,1≤L≤109 ) .OutputFor each test case, print the answer module 109+7109+7 in one line.Sample Input

3
1 2 1
2 3 1
3
1 2 1
1 3 2

Sample Output

16
24

求出两两间距离之和,在n!个排列里,两两相邻是(n-1)!

#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define lson l,(l+r)/2,rt<<1
#define rson (l+r)/2+1,r,rt<<1|1
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define pb push_back
#define v first
#define w second
#define ll long long
#define sz(x) (int)(x).size()
#define pll pair<long long,long long>
#define pii pair<int,int>
#define pq priority_queue
const int N=1e5+,MD=1e9+,INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const double eps=1e-,e=exp(),PI=acos(-.);
vector<pair<int,int> > tree[N];
ll dp[N],sum[N];//统计每个点子树所包含点的个数
int n;
void dfs(int cur,int fa)
{
sum[cur] = ;
for(int i = ; i<tree[cur].size(); i++)
{
int son=tree[cur][i].v;
ll len=tree[cur][i].w;
if(fa==son)continue;
dfs(son,cur);
sum[cur]+=sum[son];
dp[cur]+=dp[son]+sum[son]*(n-sum[son])%MD*len%MD;
dp[cur]%=MD;
}
}
int main()
{
while(~scanf("%d",&n))
{
ll ans=;
memset(dp,,sizeof(dp)),memset(sum,,sizeof(sum));
for(int i = ,u,v,w; i<n; i++)
{
ans=ans*i%MD;
scanf("%d%d%d",&u,&v,&w);
tree[u].push_back({v,w});
tree[v].push_back({u,w});
}
dfs(,);
for(int i=; i<=n; i++)tree[i].clear();
printf("%d\n",ans*dp[]%MD);
}
return ;
}

J - YJJ's Salesman

HDU - 6447

YJJ is a salesman who has traveled through western country. YJJ is always on journey. Either is he at the destination, or on the way to destination. 
One day, he is going to travel from city A to southeastern city B. Let us assume that A is (0,0)(0,0) on the rectangle map and B (109,109)(109,109). YJJ is so busy so he never turn back or go twice the same way, he will only move to east, south or southeast, which means, if YJJ is at (x,y)(x,y) now (0≤x≤109,0≤y≤109)(0≤x≤109,0≤y≤109), he will only forward to (x+1,y)(x+1,y), (x,y+1)(x,y+1) or (x+1,y+1)(x+1,y+1). 
On the rectangle map from (0,0)(0,0) to (109,109)(109,109), there are several villages scattering on the map. Villagers will do business deals with salesmen from northwestern, but not northern or western. In mathematical language, this means when there is a village kk on (xk,yk)(xk,yk) (1≤xk≤109,1≤yk≤109)(1≤xk≤109,1≤yk≤109), only the one who was from (xk−1,yk−1)(xk−1,yk−1) to (xk,yk)(xk,yk) will be able to earn vkvk dollars.(YJJ may get different number of dollars from different village.) 
YJJ has no time to plan the path, can you help him to find maximum of dollars YJJ can get.

InputThe first line of the input contains an integer TT (1≤T≤10)(1≤T≤10),which is the number of test cases.

In each case, the first line of the input contains an integer NN (1≤N≤105)(1≤N≤105).The following NN lines, the kk-th line contains 3 integers, xk,yk,vkxk,yk,vk (0≤vk≤103)(0≤vk≤103), which indicate that there is a village on (xk,yk)(xk,yk) and he can get vkvk dollars in that village. 
The positions of each village is distinct.OutputThe maximum of dollars YJJ can get.Sample Input

1
3
1 1 1
1 2 2
3 3 1

Sample Output

3

离散化就可以用数据结构去维护这个dp了

#include <bits/stdc++.h>
using namespace std;
const int N=1e5+;
struct T
{
int x,y,v;
} t[N];
bool cmp(T a, T b)
{
return a.x<b.x;
}
int a[N],c[N];
int tot;
void update(int i, int val)
{
for(; i<=tot; i+=i&(-i))c[i]=max(c[i], val);
}
int query(int i)
{
int res=;
for(; i>; i-=i&(-i))res = max(res, c[i]);
return res;
}
int dp[N];
int main()
{
int T,n;
scanf("%d", &T);
while (T--)
{
scanf("%d", &n);
for(int i=; i<n; i++)scanf("%d%d%d",&t[i].x,&t[i].y,&t[i].v);
tot=,memset(c,,sizeof c);
for(int i=; i<n; i++)a[tot++]=t[i].y;
sort(a,a+tot);
tot=unique(a,a+tot)-a;
for(int i=; i<n; i++)t[i].y=lower_bound(a,a+tot,t[i].y)-a+;
sort(t,t+n,cmp);
for(int i=; i<n; i++) dp[i]=t[i].v;
int pos=,ans=;
for(int i=; i<n; i++)
{
while(pos<i&&t[pos].x<t[i].x)update(t[pos].y,dp[pos]),pos++;
dp[i]=query(t[i].y-)+t[i].v,ans=max(ans,dp[i]);
}
printf("%d\n",ans);
}
return ;
}

2018CCPC网络赛的更多相关文章

  1. hdu6440 Dream 2018CCPC网络赛C 费马小定理+构造

    题目传送门 题目大意: 给定一个素数p,让你重载加法运算和乘法运算,使(m+n)p=mp+np,并且 存在一个小于p的q,使集合{qk|0<k<p,k∈Z} 等于集合{k|0<k&l ...

  2. hdu6446 Tree and Permutation 2018ccpc网络赛 思维+dfs

    题目传送门 题目描述:给出一颗树,每条边都有权值,然后列出一个n的全排列,对于所有的全排列,比如1 2 3 4这样一个排列,要算出1到2的树上距离加2到3的树上距离加3到4的树上距离,这个和就是一个排 ...

  3. 2018CCPC网络赛A(优先队列,思维)

    #include<bits/stdc++.h>using namespace std;priority_queue<pair<int,int>>q;int main ...

  4. HDU6438 Buy and Resell 2018CCPC网络赛 -低买高卖-贪心经典题

    目录 Catalog Solution: (有任何问题欢迎留言或私聊 && 欢迎交流讨论哦 Catalog Problem:Portal传送门  原题目描述在最下面.  出过很多次:5 ...

  5. HDU6440 Dream 2018CCPC网络赛-费马小定理

    目录 Catalog Solution: (有任何问题欢迎留言或私聊 && 欢迎交流讨论哦 Catalog Problem:Portal传送门  原题目描述在最下面.  给定一个素数p ...

  6. HDU6440 Dream(费马小定理+构造) -2018CCPC网络赛1003

    题意: 给定素数p,定义p内封闭的加法和乘法,使得$(m+n)^p=m^p+n^p$ 思路: 由费马小定理,p是素数,$a^{p-1}\equiv 1(mod\;p)$ 所以$(m+n)^{p}\eq ...

  7. HDU 5875 Function -2016 ICPC 大连赛区网络赛

    题目链接 网络赛的水实在太深,这场居然没出线zzz,差了一点点,看到这道题的的时候就剩半个小时了.上面是官方的题意题解,打完了才知道暴力就可以过,暴力我们当时是想出来了的,如果稍稍再优化一下估计就过了 ...

  8. 大连网络赛 1006 Football Games

    //大连网络赛 1006 // 吐槽:数据比较水.下面代码可以AC // 但是正解好像是:排序后,前i项的和大于等于i*(i-1) #include <bits/stdc++.h> usi ...

  9. 树形DP CCPC网络赛 HDU5834 Magic boy Bi Luo with his excited tree

    // 树形DP CCPC网络赛 HDU5834 Magic boy Bi Luo with his excited tree // 题意:n个点的树,每个节点有权值为正,只能用一次,每条边有负权,可以 ...

随机推荐

  1. IOS 设置子控件的frame(layoutSubviews and awakeFromNib)

      如果控件是通过xib或者storyboard创建出来的就会调用该方法 - (void)awakeFromNib :该方法只会调用一次 // 如果控件是通过xib或者storyboard创建出来的就 ...

  2. 安装Ubuntu桌面环境后只能Guest登录的解决办法

    1.安装Ubuntu桌面环境后,登录界面只显示了Guest 2.在登录界面按住crtl+shift+F1,进入tty模式 3.输入sudo -s进入root模式 4.输入vi /etc/lightdm ...

  3. 解决Mycat对自增表不支持(第一种已测试通过)

    表 INSERT INTO news_class (`class_id`,`class_name`) VALUES (next VALUE FOR MYCATSEQ_GLOBAL,'1'); sequ ...

  4. Dynemic Web Project中使用servlet的 doGet()方法接收来自浏览器客户端发送的add学生信息形成json字符串输出到浏览器并保存到本地磁盘文件

    package com.swift.servlet; import java.io.FileOutputStream;import java.io.IOException;import java.io ...

  5. 解决ndk编译lua时遇到 undefined reference to '__srget'的问题

    今天用ndk r10d版本编译lua时,遇到几个错误,提示没有找到__srget 没有定义,于是看了国外的大神的解决方法, 是因为ndk在r10c之后的版本已经将getc函数屏蔽了,所以导致编译器找不 ...

  6. select * 比select column快很多奇怪案例分析

    遇到MYSQL傻傻的地方,下面给个案例,大家感受下: 注意以下两个sql只有select *和select g.id区别. SQL1:SELECT g.idFROM table1 gINNER JOI ...

  7. Linux系统故障分析与排查--日志分析

    处理Linux系统出现的各种故障时,故障的症状是最先发现的,而导致这以故障的原因才是最终排除故障的关键.熟悉Linux系统的日志管理,了解常见故障的分析与解决办法,将有助于管理员快速定位故障点,“对症 ...

  8. 搭建Nginx反向代理做内网域名转发

    由于公司内网有多台服务器的 http 服务要映射到公司外网静态 IP,如果用路由的端口映射来做,就只能一台内网服务器的 80 端口映射到外网 80 端口,其他服务器的 80 端口只能映射到外网的非 8 ...

  9. git bush的一些基础命令

    git bush的一些基础命令(不区分大小写) 通过命令创建本地仓库 首先自己需要手动建一个文件夹用于本地仓库 进行如下输入,使用cd跳转到刚刚创建的文件夹中 之后再输入 git init 即可创建 ...

  10. tp5查询

    TP5的EXP.批量查询.聚合查询等. <!--more--> //使用EXP条件表达式,表示后面是原生的SQL表达式 $result = Db::table('think_inno')- ...