# 1143 计算几何你瞎暴力

——————————————————————————————————————————

(话说我当时为什么要写一个树状数组….用数组的话 多么简单….最后处理下前缀和就行了啊)

#include <bits/stdc++.h>
typedef long long int LL;
using namespace std;
#define abs(x) ((x)>0?(x):-(x))

const int N   = 2222+7;
const int MOD = 1e9+7;
const int INF = (~(1<<31));

/*********************************************/

int sum[1111];
LL zero = 0;
void update(int i,LL v){
if(i==0) {zero+=v; return ;}
for(;i<111;i+=(i&-i)) sum[i]+=v;
}
LL getSum(int i){
LL ans = 0;
for(;i;i-=(i&-i)) ans+=sum[i];
return ans;
}

LL a[11][11][11];
struct node {
int x,y,z;
}b[11*11*11*10];

int l = 0;
void solve(){
for(int i=1;i<=l;i++){
update(0,(a[b[i].x][b[i].y][b[i].z]-1)*a[b[i].x][b[i].y][b[i].z]/2);
for(int j=i+1;j<=l;j++){
update(abs(b[i].x-b[j].x)+abs(b[i].y-b[j].y)+abs(b[i].z-b[j].z),
a[b[i].x][b[i].y][b[i].z]*a[b[j].x][b[j].y][b[j].z]);
}
}
}

int main(){
for(int i=0;i<=10;i++)for(int j=0;j<=10;j++)for(int k=0;k<=10;k++)
b[++l].x=i,b[  l].y=j,b[  l].z=k;

int _,n,q;scanf("%d",&_);
while(_--){
scanf("%d%d",&n,&q);
zero = 0;
memset(sum,0,sizeof(sum));
memset(a,0,sizeof(a));
for(int i=1,x,y,z;i<=n;i++){
scanf("%d%d%d",&x,&y,&z);
a[x][y][z]++;
}
solve();
for(int i=1,x;i<=q;i++){
scanf("%d",&x);
if(x>50) x=50;
printf("%lld\n",getSum(x)+zero);
}
}
return 0;
}

# 1144 数论你还会快速幂

——————————————————————————————————————————

#include <bits/stdc++.h>
typedef long long int LL;
using namespace std;
#define abs(x) ((x)>0?(x):-(x))

const int N   = 1e6+7;
const int MOD = 1e9+7;
const int INF = (~(1<<31));

/*********************************************/

LL qc(LL a,LL b,LL c){
LL res = 0;
while(b){
if(b&1) res=(res+a)%c;
b>>=1,a=(a+a)%c;
}
return res;
}

LL qmod(LL a,LL b,LL c) {
LL res = 1ll;
while(b) {
if(b&1) res=qc(res,a,c);
b>>=1,a=qc(a,a,c);
}
return res;
}

int main() {
LL n,k,p;
int _;
scanf("%d",&_);
while(_--) {
scanf("%lld%lld%lld",&n,&k,&p);
if(k == 0){
printf("%lld\n",n%p);
continue;
}
LL t = n,sum = 0; n %= p;
for(LL i=1; i<=n; i++) {
sum+=qmod(i,k,p);
sum%=p;
}

if( k%(p-1) != 0 ) {
printf("%lld\n",sum%p);
} else {
t/=p;
sum += qc( (p-1), t , p);
printf("%lld\n",sum%p);  // puts("--");
}
}
return 0;
}


# 1146 图论你先敲完模板

——————————————————————————————————————————

dp[i]=min{dp[j]+2x[i]x[j]j[1,i)}+a $dp[i] = min\{dp[j]+2^{x[i]-x[j]}\|j\in[1,i)\}+a$

#include <bits/stdc++.h>
typedef long long int LL;
using namespace std;
#define abs(x) ((x)>0?(x):-(x))

const int N   = 1e6+7;
const int MOD = 1e9+7;
const int INF = (~(1<<31));

/*********************************************/
LL n,a;

LL x[N];
LL dp[N];

int main(){
int _;scanf("%d",&_);
while(_--){
scanf("%lld%lld",&n,&a);
for(int i=1;i<=n;i++){
scanf("%lld",&x[i]);
}

dp[1]=0;
for(int i=2;i<=n;i++){
dp[i]=dp[i-1]+a+(1ll<<(x[i]-x[i-1]));
for(int j=i-1;j;j--){
if(x[i]-x[j]>60) break;
dp[i]=min(dp[i],dp[j]+a+(1ll<<(x[i]-x[j])));
}
}

printf("%lld\n",dp[n]);
}
return 0;
}

# 1147 最后你还是AK了

——————————————————————————————————————————

//#pragma comment(linker, "/STACK:102400000,102400000")
#define OPENSTACK
#include <bits/stdc++.h>
typedef long long int LL;
using namespace std;
#define abs(x) ((x)>0?(x):-(x))

const int N = 111111+7;
/*********************************************/

int n,k;
struct edge{
int to,next,w;
}G[N<<1];
}

struct node {
int w,x;
}e[N];

int l;
int dp[N];
void dfs(int u,int f=0,int w=0){
dp[u]=1;
to = G[i].to;
w  = G[i].w;
if(to == f) continue ;
dfs(to,u,w);
dp[u]+=dp[to];
}

e[++l].w  =w;
e[  l].x    =min(dp[u],n-dp[u]);
}

bool cmp(node a,node b){return a.x>b.x;}
bool cmp2(int a,int b){return a>b;}

int c[N];
int main(){

#ifdef OPENSTACK
int size = 64 << 20; // 64MB
char *p = (char*)malloc(size) + size;
#if (defined _WIN64) or (defined __unix)
__asm__("movq %0, %%rsp\n" :: "r"(p));
#else
__asm__("movl %0, %%esp\n" :: "r"(p));
#endif
#endif

int _;scanf("%d",&_);
while(_--){
scanf("%d%d",&n,&k);
for(int i=2,u,v,w;i<=n;i++){
scanf("%d%d%d",&u,&v,&w);
}
for(int i=1;i<=k;i++) scanf("%d",&c[i]);

dfs(1);

sort(e+1,e+l+1,cmp);
//        for(int i=0;i<=l;i++)      printf("%d %d\n",e[i].w,e[i].x);

sort(c+1,c+k+1,cmp2);

for(int i=1;i<=k;i++) e[i].w+=c[i];

LL ans = 0;
for(int i=1;i<l;i++){
//            printf("%d %d\n",e[i].w,e[i].x);
ans+=1LL*e[i].w*e[i].x;
}
printf("%lld\n",ans);
}
#ifdef OPENSTACK
exit(0);
#else
return 0;
#endif
}


# 1148 数据结构你干瞪眼啊

——————————————————————————————————————————

10-03 2855

01-08 1693
10-18 3321
05-11 3万+
08-11 2440
04-18 630
01-03 1974
04-19 551