ホームページ ウェブフロントエンド htmlチュートリアル Codeforces ラウンド #259 (ディビジョン 2) A B C 3 連続ラウンド_html/css_WEB-ITnose

Codeforces ラウンド #259 (ディビジョン 2) A B C 3 連続ラウンド_html/css_WEB-ITnose

Jun 24, 2016 pm 12:00 PM
round

A. リトルポニーとクリスタルマイン

テストごとの制限時間

1 秒

テストごとのメモリ制限

256 メガバイト

入力

標準入力

出力

標準出力

トワイライトスパークルはかつてクリスタル鉱山からクリスタルを入手しました。サイズ n の結晶 (n は奇数; n?>?1) は、ダイヤモンドが刻まれた n?×?n 行列です。

奇数の整数 n が与えられます。サイズ n の結晶を描画する必要があります。マトリックスのひし形のセルは文字「D」で表す必要があります。マトリックスの他のすべてのセルは文字「*」で表す必要があります。例を見て、何を描画する必要があるかを理解してください。

入力

唯一の行には整数 n (3?≤?n?≤?101; n は奇数) が含まれています。

出力

出力サイズ n の結晶。

サンプルテスト

入力

出力

RREE

入力

出力

*D*DDD*D*
ログイン後にコピー

入力

出力

**D***DDD*DDDDD*DDD***D**
ログイン後にコピー



B. リトルポニーとシフトで並べ替え

テストごとの制限時間

1 秒

テストごとのメモリ制限

256 メガバイト

入力

標準入力

出力

標準出力

ある日、Twilight Sparkle は、一連の整数 a1,?a2,?..., を並べ替える方法に興味がありました。 ?an は降順ではありません。若いユニコーンである彼女が実行できる唯一の操作はユニットのシフトです。つまり、シーケンスの最後の要素を先頭に移動できます:

a1,?a2,?...,?an?→?an,?a1,?a2,?...,?an?-? 1.

トワイライト スパークルの計算を手伝ってください: シーケンスを並べ替えるのに必要な操作の最小数は何ですか?

入力 最初の行には整数 n (2?≤?n?≤?105) が含まれています。 2 行目には n 個の整数 a1,?a2,?...,?an(1?≤?ai?≤?105) が含まれています。

出力

シーケンスを並べ替えることが不可能な場合は、-1 を出力します。それ以外の場合は、Twilight Sparkle がソートするために必要な操作の最小数を出力します。

サンプル テスト

入力

***D*****DDD***DDDDD*DDDDDDD*DDDDD***DDD*****D***
ログイン後にコピー

入力

#include<iostream>#include<cstring>#include<algorithm>#include<cstdio>using namespace std;char mapp[110][110];int main(){    int i,j;    int cas;    while(~scanf("%d",&cas))    {        memset(mapp,0,sizeof(mapp));        int ans=cas/2;        for(i=0;i<cas/2+1;i++)        {            for(j=0;j<cas;j++)        {            if(j<ans||j>cas-ans-1)                mapp[i][j]='*';            else mapp[i][j]='D';        }        ans--;        cout<<mapp[i]<<endl;        }        for(i=cas/2-1;i>=0;i--)            cout<<mapp[i]<<endl;    }    return 0;}
ログイン後にコピー

出力

22 1
ログイン後にコピー

入力

出力




#include<iostream>#include<cstring>#include<algorithm>#include<cstdio>int a[100010];int main(){    int i,j;    int cas;    int flag=0;    int ans=0;    while(~scanf("%d",&cas))    {        for(i=0;i<cas;i++)            scanf("%d",&a[i]);        for(i=1;i<cas;i++)        {            if(a[i]<a[i-1])            {flag++;}            if(flag==1)            ans++;            if(flag==3)                break;        }        if((flag==1&&a[cas-1]<=a[0])||flag==0)            printf("%d\n",ans);        else printf("-1\n");    }    return 0;}
ログイン後にコピー

C. Little Pony and Expected Maximum

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Twilight Sparkle was playing Ludo with her friends Rainbow Dash, Apple Jack and Flutter Shy. But she kept losing. Having returned to the castle, Twilight Sparkle became interested in the dice that were used in the game.

The dice has m faces: the first face of the dice contains a dot, the second one contains two dots, and so on, the m-th face contains mdots. Twilight Sparkle is sure that when the dice is tossed, each face appears with probability . Also she knows that each toss is independent from others. Help her to calculate the expected maximum number of dots she could get after tossing the dice n times.

Input

A single line contains two integers m and n (1?≤?m,?n?≤?105).

Output

Output a single real number corresponding to the expected maximum. The answer will be considered correct if its relative or absolute error doesn't exceed 10??-?4.

Sample test(s)

input

6 1
ログイン後にコピー

output

3.500000000000
ログイン後にコピー

input

6 3
ログイン後にコピー

output

4.958333333333
ログイン後にコピー

input

2 2
ログイン後にコピー

output

1.750000000000
ログイン後にコピー

Note

Consider the third test example. If you've made two tosses:

  1. You can get 1 in the first toss, and 2 in the second. Maximum equals to 2.
  2. You can get 1 in the first toss, and 1 in the second. Maximum equals to 1.
  3. You can get 2 in the first toss, and 1 in the second. Maximum equals to 2.
  4. You can get 2 in the first toss, and 2 in the second. Maximum equals to 2.

The probability of each outcome is 0.25, that is expectation equals to:

You can read about expectation using the following link: http://en.wikipedia.org/wiki/Expected_value




#include<iostream>#include<cstdio>#include<cmath>#include<cstring>#include<string>#include<algorithm>using namespace std;int a[100010];typedef double LL;double qpow(double a,int b){    LL ans=1;    while(b)    {        if(b&1) ans*=a;        b>>=1;        a*=a;    }    return ans;}int main(){    int n;    int m;    scanf("%d%d",&n,&m);    double ans=0;    for(int i=1;i<=n;i++)        ans+=(qpow(1.0*i/n,m)-qpow(1.0*(i-1)/n,m))*i;    printf("%.12f\n",ans);    return 0;}
ログイン後にコピー



このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

AI Hentai Generator

AI Hentai Generator

AIヘンタイを無料で生成します。

ホットツール

メモ帳++7.3.1

メモ帳++7.3.1

使いやすく無料のコードエディター

SublimeText3 中国語版

SublimeText3 中国語版

中国語版、とても使いやすい

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統合開発環境

ドリームウィーバー CS6

ドリームウィーバー CS6

ビジュアル Web 開発ツール

SublimeText3 Mac版

SublimeText3 Mac版

神レベルのコード編集ソフト(SublimeText3)

&lt; Progress&gt;の目的は何ですか 要素? &lt; Progress&gt;の目的は何ですか 要素? Mar 21, 2025 pm 12:34 PM

この記事では、HTML&lt; Progress&gt;について説明します。要素、その目的、スタイリング、および&lt; meter&gt;との違い要素。主な焦点は、&lt; Progress&gt;を使用することです。タスクの完了と&lt; Meter&gt; statiの場合

&lt; datalist&gt;の目的は何ですか 要素? &lt; datalist&gt;の目的は何ですか 要素? Mar 21, 2025 pm 12:33 PM

この記事では、HTML&lt; Datalist&GT;について説明します。オートコンプリートの提案を提供し、ユーザーエクスペリエンスの改善、エラーの削減によりフォームを強化する要素。

HTMLは初心者のために簡単に学ぶことができますか? HTMLは初心者のために簡単に学ぶことができますか? Apr 07, 2025 am 12:11 AM

HTMLは、簡単に学習しやすく、結果をすばやく見ることができるため、初心者に適しています。 1)HTMLの学習曲線はスムーズで簡単に開始できます。 2)基本タグをマスターして、Webページの作成を開始します。 3)柔軟性が高く、CSSおよびJavaScriptと組み合わせて使用​​できます。 4)豊富な学習リソースと最新のツールは、学習プロセスをサポートしています。

&lt; meter&gt;の目的は何ですか 要素? &lt; meter&gt;の目的は何ですか 要素? Mar 21, 2025 pm 12:35 PM

この記事では、html&lt; meter&gt;について説明します。要素は、範囲内でスカラーまたは分数値を表示するために使用され、Web開発におけるその一般的なアプリケーション。それは差別化&lt; Meter&gt; &lt; Progress&gt;およびex

&lt; iframe&gt;の目的は何ですか タグ?使用する際のセキュリティ上の考慮事項は何ですか? &lt; iframe&gt;の目的は何ですか タグ?使用する際のセキュリティ上の考慮事項は何ですか? Mar 20, 2025 pm 06:05 PM

この記事では、&lt; iframe&gt;外部コンテンツをWebページ、その一般的な用途、セキュリティリスク、およびオブジェクトタグやAPIなどの代替案に埋め込む際のタグの目的。

ビューポートメタタグとは何ですか?レスポンシブデザインにとってなぜそれが重要なのですか? ビューポートメタタグとは何ですか?レスポンシブデザインにとってなぜそれが重要なのですか? Mar 20, 2025 pm 05:56 PM

この記事では、モバイルデバイスのレスポンシブWebデザインに不可欠なViewportメタタグについて説明します。適切な使用により、最適なコンテンツのスケーリングとユーザーの相互作用が保証され、誤用が設計とアクセシビリティの問題につながる可能性があることを説明しています。

HTML、CSS、およびJavaScriptの役割:コアの責任 HTML、CSS、およびJavaScriptの役割:コアの責任 Apr 08, 2025 pm 07:05 PM

HTMLはWeb構造を定義し、CSSはスタイルとレイアウトを担当し、JavaScriptは動的な相互作用を提供します。 3人はWeb開発で職務を遂行し、共同でカラフルなWebサイトを構築します。

HTMLでの開始タグの例は何ですか? HTMLでの開始タグの例は何ですか? Apr 06, 2025 am 12:04 AM

Anexampleapalofastartingtaginhtmlis、それはaperginsaparagraph.startingtagsaresentionentientiontheyinitiateelements、definetheirtypes、およびarecrucialforurturingwebpagesandcontingthomedomを構築します。

See all articles