結果
問題 | No.254 文字列の構成 |
ユーザー |
|
提出日時 | 2016-10-29 09:14:43 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 19 ms / 5,000 ms |
コード長 | 528 bytes |
コンパイル時間 | 403 ms |
コンパイル使用メモリ | 62,244 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-24 07:23:13 |
合計ジャッジ時間 | 1,658 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
ソースコード
#include <iostream>#include <string>#include <cmath>using namespace std;int main(){int N=0;cin>>N;string s1;int cn1=97;while(1){int M=sqrt(N);char c1=cn1;string s2;s2+=c1;int f=1;for(int i=1;i<M;++i){int cn2=cn1;if(f==1) cn2+=1;char c=cn2;s2.insert(s2.begin(),c);s2+=c;f*=-1;}s1+=s2;N-=M*M;cn1+=2;if(N==1){char c=cn1;s1+=c;break;} else if(N==0){break;}}cout<<s1<<endl;}