zoukankan      html  css  js  c++  java
  • Codeforces Round #262 (Div. 2)

    A. Vasya and Socks http://codeforces.com/contest/460/problem/A

    水题暴力

     1 #include<cstdio>
     2 int main(){
     3     int n,m;
     4     while(~scanf("%d%d",&n,&m)){
     5         int ans=0;
     6         while(n){
     7             n--;
     8             ans++;
     9             if(!(ans%m)) n++;
    10         }
    11         printf("%d
    ",ans);
    12     }
    13     return 0;
    14 }
    View Code

     B. Little Dima and Equation http://codeforces.com/contest/460/problem/B

    sx=x所有位的和,要知道sx在1~1e9的x 对应的是1~81,枚举81,判断。

     1 #include<cstdio>
     2 typedef __int64 LL;
     3 LL gxpow(int x,int n){
     4     LL res=1;
     5     while(n--) res*=x;
     6     return res;
     7 }
     8 int sum(LL x){
     9     int res=0;
    10     while(x){
    11         res+=x%10;
    12         x/=10;
    13     }
    14     return res;
    15 }
    16 LL ans[128];
    17 int main(){
    18     int a,b,c;
    19     while(~scanf("%d%d%d",&a,&b,&c)){
    20         int la=0;
    21         for(int i=1;i<=81;i++){
    22             LL x=b*gxpow(i,a)+c;
    23             if(0<x&&x<1e9&&sum(x)==i){
    24                 ans[la++]=x;
    25             }
    26         }
    27         printf("%d
    ",la);
    28         if(!la) continue;
    29         for(int i=0;i<la;i++){
    30             printf("%d ",ans[i]);
    31         }
    32         puts("");
    33     }
    34     return 0;
    35 }
    View Code

     C. Present http://codeforces.com/contest/460/problem/C

    二分答案,注意LR上下界,瞎定义tle了一次,对答案贪心的从前往后浇水,看能否构成答案,区间更新on左++右--是线段树nlogn的10分之一的时间46ms  vs 390ms。

     1 #include<cstdio>
     2 #include<cstring>
     3 #include<algorithm>
     4 #define mt(a,b) memset(a,b,sizeof(a))
     5 using namespace std;
     6 const int M=100010;
     7 int n,m,w,a[M],lazy[M];
     8 bool judge(int ans){
     9     mt(lazy,0);
    10     int add=0,left=m;
    11     for(int i=1;i<=n;i++){
    12         add+=lazy[i];
    13         int now=a[i]+add;
    14         if(now<ans){
    15             int need=ans-now;
    16             if(need>left) return false;
    17             left-=need;
    18             if(w>1){
    19                 lazy[i+1]+=need;
    20                 if(i+w<=n)
    21                     lazy[i+w]-=need;
    22             }
    23         }
    24     }
    25     return true;
    26 }
    27 int main(){
    28     while(~scanf("%d%d%d",&n,&m,&w)){
    29         int L=1,R=0;
    30         for(int i=1;i<=n;i++){
    31             scanf("%d",&a[i]);
    32             R=max(R,a[i]);
    33         }
    34         R+=m;
    35         while(L<=R){
    36             int mid=(L+R)>>1;
    37             if(judge(mid))
    38                 L=mid+1;
    39             else
    40                 R=mid-1;
    41         }
    42         printf("%d
    ",L-1);
    43     }
    44     return 0;
    45 }
    View Code

    end

  • 相关阅读:
    SQL注入绕过——主要是magic_quotes_gpc, is_int(只能跑路,无注入点),以及关键字绕过,WAF绕过
    小葵多功能转换工具——编解码绕过,TODO
    load_file() 常用敏感信息
    crontab 结合 thinkphp3.2
    Docker 小型电脑
    Linux 查找大目录
    phpmyadmin 连接远程数据库
    git 变更 地址
    showdoc可以导出
    showdoc搭建
  • 原文地址:https://www.cnblogs.com/gaolzzxin/p/3927903.html
Copyright © 2011-2022 走看看