結果

問題 No.220 世界のなんとか2
ユーザー btk
提出日時 2015-05-30 14:31:03
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 293 bytes
コンパイル時間 502 ms
コンパイル使用メモリ 61,264 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-06 12:43:47
合計ジャッジ時間 1,183 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;

#define LL long long
LL dp[20]={1,3};
int main(){
	int p;
	cin>>p;
	LL res,ten=(LL)pow(10,p-1);
	res=ten;
	for(int i=2;i<=p;i++){
		ten/=10;
		dp[i]=dp[i-1]*9;
		res+=dp[i-1]*3*ten;
	}
	cout<<res+dp[p]-1<<endl;;


}
0