結果
問題 |
No.701 ひとりしりとり
|
ユーザー |
|
提出日時 | 2018-11-24 00:16:34 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 616 bytes |
コンパイル時間 | 628 ms |
コンパイル使用メモリ | 62,700 KB |
実行使用メモリ | 6,940 KB |
最終ジャッジ日時 | 2024-07-19 16:25:16 |
合計ジャッジ時間 | 1,676 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 WA * 1 |
ソースコード
#include<iostream> #include<string> #include<math.h> using namespace std; string int2a_b_string(int num){ long ans = 0; for(int i=0;num>0;i++){ ans = ans+(num%2)*pow(10,i); num=num/2; } string bin = to_string(ans); string outstr = ""; for(int j=bin.size()-1;j>=0;j--){ if(bin[j]=='0') outstr = "a" + outstr; else outstr = "b" + outstr; } return outstr; } int main(){ int n; cin >> n; for(int k=0;k<n;k++){ cout << "c" << int2a_b_string(k) << "c"; if(k==n-1) cout << "n\n"; else cout << "\n"; } return 0; }