結果
| 問題 |
No.220 世界のなんとか2
|
| コンテスト | |
| ユーザー |
tamiflu__shrine
|
| 提出日時 | 2015-06-22 18:47:43 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,006 bytes |
| コンパイル時間 | 944 ms |
| コンパイル使用メモリ | 57,088 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-07 16:37:18 |
| 合計ジャッジ時間 | 2,102 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 19 |
ソースコード
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
long p = 2; // p >= 1
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;
}
}
// 出力
printf("3の倍数 : %ld\n", result1);
printf("3の付く数: %ld\n", result2);
printf("両方 : %ld\n", result3);
cout << result1 + result2 - result3;
return 0;
}
tamiflu__shrine