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. lattice diamond fpga 状态机的理解

    比如序列检测101,需要三个状态 :so,s1,s2. 思路:(1)s0状态有两种情况0或1,若为0时在自身打圈,是1时进入s1状态. (2)s1状态有两种0或1,若为1自身打圈,因为1可以作为下次检 ...

  2. iOS开发:自定义带下划线文本的UIButton

    Uiunderlinedbutton.h代码 @interface UIUnderlinedButton : UIButton { } + (UIUnderlinedButton *) underli ...

  3. POJ 3421 X-factor Chains(构造)

    这条链依次乘一个因子.因为n<2^20,sqrt(n)分解因子,相同的因子相对顺序取一个. 组合公式计算一下就好. #include<cstdio> #include<iost ...

  4. POJ 1631 Bridging signals(LIS的等价表述)

    把左边固定,看右边,要求线不相交,编号满足单调性,其实是LIS的等价表述. (如果编号是乱的也可以把它有序化就像Uva 10635 Prince and Princess那样 O(nlogn) #in ...

  5. hdu-1068&&POJ1466 Girls and Boys---最大独立集

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1068 题目大意: 有n个人,一些人认识另外一些人,选取一个集合,使得集合里的每个人都互相不认识,求该 ...

  6. 【BZOJ4698】[SDOI2008] Sandy的卡片(后缀数组+二分)

    点此看题面 大致题意: 给你\(N\)个序列,若定义两个相同子串为一个子串内所有数加上一个数后能变成另一个串,求所有序列中的最长相同子串的长度. 简单的转化 首先,我们对题目进行一个简单的转化. 要求 ...

  7. 【洛谷1967】货车运输(最大生成树+倍增LCA)

    点此看题面 大致题意: 有\(n\)个城市和\(m\)条道路,每条道路有一个限重.多组询问,每次询问从\(x\)到\(y\)的最大载重为多少. 一个贪心的想法 首先,让我们来贪心一波. 由于要求最大载 ...

  8. [超详细] Python3爬取豆瓣影评、去停用词、词云图、评论关键词绘图处理

    爬取豆瓣电影<大侦探皮卡丘>的影评,并做词云图和关键词绘图第一步:找到评论的网页url.https://movie.douban.com/subject/26835471/comments ...

  9. 2017.12.4 JavaWeb中EL表达式的运用

    <%@ page contentType="text/html; charset=gb2312"%> <html> <head> <tit ...

  10. NSCopying

    ///< .h @interface ChatManager : NSObject <NSCopying> @property (nonatomic) NSUInteger inde ...