結果

問題 No.784 「,(カンマ)」
ユーザー kaagekaage
提出日時 2019-03-17 22:29:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 664 bytes
コンパイル時間 2,900 ms
コンパイル使用メモリ 146,332 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 08:01:20
合計ジャッジ時間 2,555 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define moder (1000000007)
#define pie acos(-1)
#define P std::pair<int,int>
#define prique priority_queue
#define ggr getchar();getchar();return 0;
using namespace std;
string n,ans;
signed main(){
	cin>>n;
	if(n.size()<=3){
		cout<<n<<endl;
		return 0;
	}
	reverse(n.begin(),n.end());
	for(int i=2;i<n.size();i+=3){
		ans+=n.substr(i-2,3);
		ans+=',';
	}
	ans+=n.substr(n.size()/3*3,n.size()%3);
	reverse(ans.begin(),ans.end());
	if(ans[0]==',')ans=ans.substr(1,ans.size()-1);
	cout<<ans<<endl;
	return 0;
}
0