結果

問題 No.1942 Leading zero
ユーザー ruase_
提出日時 2025-08-15 01:29:17
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 700 bytes
コンパイル時間 921 ms
コンパイル使用メモリ 103,112 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-08-15 01:29:19
合計ジャッジ時間 1,665 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
# include <iostream>
# include <iomanip>

using namespace std;


int main()
{
    int n;
    cin >> n;
    string a[n];
    for (int i = 0; i < n; i++) cin >> a[i];

    for (int i = 0; i < n; i++) {
        string tmp = a[i];
        int str_idx = 0;
        while (true){
            if (tmp[str_idx] == '0') {
                tmp.replace(str_idx,1,"");
                str_idx = 0;
                if (tmp.length() == 1) {
                    a[i] = tmp;
                    break;
                }
            }else{
                a[i] = tmp;
                break;
            }
        }
    }

    for (int i = 0 ; i < n ; i++) {
        cout << a[i] << endl;
    }


}
0