結果
| 問題 |
No.784 「,(カンマ)」
|
| コンテスト | |
| ユーザー |
Kura
|
| 提出日時 | 2019-02-13 22:12:41 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 585 bytes |
| コンパイル時間 | 640 ms |
| コンパイル使用メモリ | 60,668 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-13 11:14:59 |
| 合計ジャッジ時間 | 1,169 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
#include<iostream>
#include<vector>
using namespace std;
int main() {
int a;
cin >> a;
int b = 1;
int c = a;
for (;c>=1000;) {
c /= 1000;
b++;
}
vector<int> d(b);
for (int i = 0; i < b; i++) {
d[i] = a % 1000;
a /= 1000;
}
for (int i = b-1; i >= 1; i--) {
if (i!=b-1&&d[i] < 10) {
cout << "00" << d[i] << ",";
}else if (i != b - 1&&d[i] < 100) {
cout << 0 << d[i] << ",";
}else {
cout << d[i] << ",";
}
}
if (b-1!=0&&d[0] < 10) {
cout << "00" << d[0] ;
}
else if (b-1!=0&&d[0] < 100) {
cout << 0 << d[0];
}
else {
cout << d[0]<<endl;
}
}
Kura