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

    A. Little Pony and Crystal Mine http://codeforces.com/contest/454/problem/A

     1 #include<cstdio>
     2 int main(){
     3     int n;
     4     while(~scanf("%d",&n)){
     5         for(int i=1;i<=n/2;i++){
     6             for(int j=0;j<n/2+1-i;j++){
     7                 printf("*");
     8             }
     9             for(int j=0;j<i*2-1;j++){
    10                 printf("D");
    11             }
    12             for(int j=0;j<n/2+1-i;j++){
    13                 printf("*");
    14             }
    15             puts("");
    16         }
    17         for(int i=1;i<=n;i++){
    18             printf("D");
    19         }
    20         puts("");
    21         for(int i=1;i<=n/2;i++){
    22             for(int j=0;j<i;j++){
    23                 printf("*");
    24             }
    25             for(int j=0;j<(n/2+1-i)*2-1;j++){
    26                 printf("D");
    27             }
    28             for(int j=0;j<i;j++){
    29                 printf("*");
    30             }
    31             puts("");
    32         }
    33     }
    34     return 0;
    35 }
    View Code

     B. Little Pony and Sort by Shift http://codeforces.com/contest/454/problem/B

     1 #include<cstdio>
     2 const int M=100010;
     3 int a[M];
     4 int main(){
     5     int n;
     6     while(~scanf("%d",&n)){
     7         for(int i=0;i<n;i++){
     8             scanf("%d",&a[i]);
     9         }
    10         int cnt=0,id;
    11         for(int i=0;i<n-1;i++){
    12             if(a[i]>a[i+1]){
    13                 cnt++;
    14                 id=i+1;
    15             }
    16         }
    17         if(cnt>1) puts("-1");
    18         else if(cnt<1) puts("0");
    19         else if(a[n-1]>a[0]) puts("-1");
    20         else printf("%d
    ",n-id);
    21     }
    22     return 0;
    23 }
    View Code

     C. Little Pony and Expected Maximum http://codeforces.com/contest/454/problem/C

     1 #include<cstdio>
     2 int m,n;
     3 double mypow(int i){
     4     double a=i*1.0/m,res=1;
     5     int p=n;
     6     while(p){
     7         if(p&1) res*=a;
     8         a*=a;
     9         p>>=1;
    10     }
    11     return res;
    12 }
    13 int main(){
    14     while(~scanf("%d%d",&m,&n)){
    15         double ans=0;
    16         for(int i=1;i<=m;i++){
    17             ans+=i*(mypow(i)-mypow(i-1));
    18         }
    19         printf("%.12f
    ",ans);
    20     }
    21     return 0;
    22 }
    View Code

    end

  • 相关阅读:
    搜狗输入法ubuntu
    数学
    1
    狗蚂蚁, 模拟题.
    最小公倍数
    哈夫曼费用计算C++
    C++十进制到任意进制
    【Django QuerySet API009】
    【Django模型(数据库)008】
    【Django模板进阶007】
  • 原文地址:https://www.cnblogs.com/gaolzzxin/p/3886666.html
Copyright © 2011-2022 走看看