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 for if>cas-ans-1) mapp[i][j]='*'; else mapp[i][j]='D'; } ans--; cout=0;i--) cout <p class="sycode"> </p> 出力 <p class="sycode"> </p> <pre style="代码" class="precsshei">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 scanf for if ans break printf else return> <br> <p class="sycode"> </p> <p class="sycode"> C. Little Pony and Expected Maximum </p> <p class="sycode"> </p> <p class="sycode"> time limit per test </p> 1 second <p class="sycode"> </p> <p class="sycode"> memory limit per test </p> 256 megabytes <p class="sycode"> </p> <p class="sycode"> input </p> standard input <p class="sycode"> </p> <p class="sycode"> output </p> standard output <p class="sycode"> </p> <p> 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.</p> <p> 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.</p> <p class="sycode"> </p> <p class="sycode"> Input </p> <p> A single line contains two integers m and n (1?≤?m,?n?≤?105).</p> <p class="sycode"> </p> <p class="sycode"> Output </p> <p> 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.</p> <p class="sycode"> </p> <p class="sycode"> Sample test(s) </p> <p class="sycode"> </p> <p class="sycode"> </p> <p class="sycode"> input </p> <pre style="代码" class="precsshei">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:
- You can get 1 in the first toss, and 2 in the second. Maximum equals to 2.
- You can get 1 in the first toss, and 1 in the second. Maximum equals to 1.
- You can get 2 in the first toss, and 1 in the second. Maximum equals to 2.
- 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 <br> <br> <br> </algorithm></string></cstring></cmath></cstdio></iostream>

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

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

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

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

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

この記事では、html5&lt; time&gt;について説明します。セマンティックデート/時刻表現の要素。 人間の読み取り可能なテキストとともに、マシンの読みやすさ(ISO 8601形式)のDateTime属性の重要性を強調し、Accessibilitを増やします

記事では、HTML5クロスブラウザーの互換性を確保するためのベストプラクティスについて説明し、機能検出、プログレッシブエンハンスメント、およびテスト方法に焦点を当てています。

この記事では、ブラウザのユーザー入力を直接検証するために、必要、パターン、MIN、MAX、および長さの制限などのHTML5フォーム検証属性を使用して説明します。


ホットAIツール

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

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

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

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

人気の記事

ホットツール

MantisBT
Mantis は、製品の欠陥追跡を支援するために設計された、導入が簡単な Web ベースの欠陥追跡ツールです。 PHP、MySQL、Web サーバーが必要です。デモおよびホスティング サービスをチェックしてください。

MinGW - Minimalist GNU for Windows
このプロジェクトは osdn.net/projects/mingw に移行中です。引き続きそこでフォローしていただけます。 MinGW: GNU Compiler Collection (GCC) のネイティブ Windows ポートであり、ネイティブ Windows アプリケーションを構築するための自由に配布可能なインポート ライブラリとヘッダー ファイルであり、C99 機能をサポートする MSVC ランタイムの拡張機能が含まれています。すべての MinGW ソフトウェアは 64 ビット Windows プラットフォームで実行できます。

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

SublimeText3 英語版
推奨: Win バージョン、コードプロンプトをサポート!

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

ホットトピック



