zoukankan      html  css  js  c++  java
  • 2017 Multi-University Training Contest

    HDU 6058

     1 #pragma comment(linker, "/STACK:102400000,102400000")
     2 #include <bits/stdc++.h>
     3 #include <cstdlib>
     4 #include <cstdio>
     5 #include <iostream>
     6 #include <cstdlib>
     7 #include <cstring>
     8 #include <algorithm>
     9 #include <cmath>
    10 #include <cctype>
    11 #include <map>
    12 #include <set>
    13 #include <queue>
    14 #include <bitset>
    15 #include <string>
    16 #include <complex>
    17 #define LL long long
    18 #define mod 1000000007
    19 using namespace std;
    20 int t;
    21 int a[500005];
    22 int l[500005];
    23 int r[500005];
    24 int n,k;
    25 int main()
    26 {
    27      scanf("%d",&t);
    28     for(int i=1;i<=t;i++){
    29         LL ans=0;
    30         scanf("%d %d",&n,&k);
    31         for(int j=0;j<n;j++)
    32             scanf("%d",&a[j]);
    33         for(int j=0;j<n;j++){
    34             int s,t;
    35             int c1=1,c2=1;
    36             for(s=j+1;s<n;s++){
    37                 if(c1>k)
    38                   break;
    39                 if(a[s]>a[j])
    40                     r[c1++]=s-j;
    41             }
    42             if(s>=n)
    43                 r[c1]=n-j;
    44             for(t=j-1;t>=0;t--){
    45                 if(c2>k)
    46                 break;
    47                 if(a[t]>a[j])
    48                     l[c2++]=j-t;
    49             }
    50             if(t<=0)
    51                 l[c2]=j+1;;
    52             for(int o=0;o<c2;o++){
    53                 if(k-o-1>=c1)
    54                     continue;
    55                 ans=ans+1LL*a[j]*(l[o+1]-l[o])*(r[k-o]-r[k-o-1]);
    56             }
    57         }
    58         printf("%lld
    ",ans);
    59     }
    60     return 0;
    61 }

    HDU 6060

     1 #pragma comment(linker, "/STACK:102400000,102400000")
     2 #include <bits/stdc++.h>
     3 #include <cstdlib>
     4 #include <cstdio>
     5 #include <iostream>
     6 #include <cstdlib>
     7 #include <cstring>
     8 #include <algorithm>
     9 #include <cmath>
    10 #include <cctype>
    11 #include <map>
    12 #include <set>
    13 #include <queue>
    14 #include <bitset>
    15 #include <string>
    16 #include <complex>
    17 #define LL long long
    18 #define mod 1000000007
    19 using namespace std;
    20 int n,k;
    21 struct node
    22 {
    23     int st,ed;
    24     LL w;
    25 }N[3000006];
    26 int pre[1000006];
    27 LL www[1000006];
    28 int dp[1000006];
    29 
    30 int nedge=0;
    31 void init()
    32 {
    33     nedge=0;
    34     memset(pre,0,sizeof(pre));
    35     memset(www,0,sizeof(www));
    36     memset(dp,0,sizeof(dp));
    37     memset(N,0,sizeof(N));
    38 }
    39 void add(int s,int t,LL we)
    40 {
    41     nedge++;
    42     N[nedge].ed=t;
    43     N[nedge].w=we;
    44     N[nedge].st=pre[s];
    45     pre[s]=nedge;
    46 }
    47 int dfs(int root ,int fa)
    48 {
    49     dp[root]=1;
    50     for(int i=pre[root];i;i=N[i].st)
    51     {
    52         if(N[i].ed!=fa){
    53           www[N[i].ed]=N[i].w;
    54           dp[root]+=dfs(N[i].ed,root);
    55           }
    56     }
    57     return dp[root];
    58 }
    59 int main()
    60 {
    61     while(scanf("%d %d",&n,&k)!=EOF){
    62         int a,b;
    63         LL c;
    64         init();
    65         for(int i=1;i<n;i++){
    66             scanf("%d %d %lld",&a,&b,&c);
    67             add(a,b,c);
    68             add(b,a,c);
    69         }
    70         dfs(1,-1);
    71         LL ans=0;
    72         for(int i=2;i<=n;i++)
    73         {
    74             ans=ans+1LL*min(dp[i],k)*www[i];
    75         }
    76         printf("%lld
    ",ans);
    77     }
    78     return 0;
    79 }

    HDU 6063

     1 #pragma comment(linker, "/STACK:102400000,102400000")
     2 #include <bits/stdc++.h>
     3 #include <cstdlib>
     4 #include <cstdio>
     5 #include <iostream>
     6 #include <cstdlib>
     7 #include <cstring>
     8 #include <algorithm>
     9 #include <cmath>
    10 #include <cctype>
    11 #include <map>
    12 #include <set>
    13 #include <queue>
    14 #include <bitset>
    15 #include <string>
    16 #include <complex>
    17 #define LL long long
    18 #define mod 1000000007
    19 using namespace std;
    20 LL n,k;
    21 LL fun(LL n,LL k){
    22   LL ans=1;
    23   LL  b=n;
    24   while(k){
    25     if(k%2==1){
    26         ans=(ans*b)%mod;
    27     }
    28     k/=2;
    29     b=b%mod;
    30     b=(b*b)%mod;
    31   }
    32   return ans;
    33 }
    34 int main()
    35 {
    36     int t=0;
    37     while(scanf("%lld %lld",&n,&k)!=EOF){
    38     printf("Case #%d: %lld
    ",++t,fun(n,k));
    39     }
    40     return 0;
    41 }

    HDU 6066

     1 #pragma comment(linker, "/STACK:102400000,102400000")
     2 #include <bits/stdc++.h>
     3 #include <cstdlib>
     4 #include <cstdio>
     5 #include <iostream>
     6 #include <cstdlib>
     7 #include <cstring>
     8 #include <algorithm>
     9 #include <cmath>
    10 #include <cctype>
    11 #include <map>
    12 #include <set>
    13 #include <queue>
    14 #include <bitset>
    15 #include <string>
    16 #include <complex>
    17 #define LL long long
    18 #define mod 1000000007
    19 using namespace std;
    20 int t;
    21 int main()
    22 {
    23     int ans,exm;
    24     scanf("%d",&t);
    25     ans=0;
    26     for(int i=1; i<=t; i++)
    27     {
    28         scanf("%d",&exm);
    29         if(exm<=35)
    30             ans++;
    31     }
    32     printf("%d
    ",ans);
    33     return 0;
    34 }
  • 相关阅读:
    oracle 将表名和字段名变为大写
    第三方应用软件提权
    数据库提权
    mybatis spring代理开发
    mybatis整合spring原始dao开发
    mybatis和spring整合的jar包准备
    mybatis整合ehcache(分布式缓存框架)
    mybatis 查询缓存
    mybatis 延迟加载
    mybatis 高级映射
  • 原文地址:https://www.cnblogs.com/hsd-/p/7276903.html
Copyright © 2011-2022 走看看