結果
| 問題 |
No.220 世界のなんとか2
|
| コンテスト | |
| ユーザー |
tamiflu__shrine
|
| 提出日時 | 2015-06-22 18:52:52 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 901 bytes |
| コンパイル時間 | 576 ms |
| コンパイル使用メモリ | 58,984 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-07 16:38:21 |
| 合計ジャッジ時間 | 1,510 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 WA * 3 |
ソースコード
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
long p;
cin >> p;
long result1 = 0;
long result2 = 0;
long result3 = 0;
// 3の倍数
result1 = (long)(pow(10, p) / 3);
// 3の付く数
long init = 1;
for (long i = 1; i <= p; i++) {
if (i == 1) {
result2 = init;
} else {
result2 = init * 9 + pow(10, i - 1);
init = result2;
}
}
// 3の倍数かつ3の付く数
init = 1;
for (long i = 1; i <= p; i++) {
if (i == 1) {
result3 = init;
} else {
result3 = init * 3 + (init - 1) * 6 + (long)(pow(10, i - 1) / 3) + 1;
init = result3;
}
}
// 出力
long result = result1 + result2 - result3;
printf("%ld\n", result);
return 0;
}
tamiflu__shrine