結果

問題 No.254 文字列の構成
ユーザー itezpace
提出日時 2016-10-29 09:05:17
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 530 bytes
コンパイル時間 520 ms
コンパイル使用メモリ 61,416 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-24 07:23:10
合計ジャッジ時間 2,144 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 27 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
    if(N==1){
      char c=cn1+1;
      s1+=c;
      break;
    } else if(N==0){
      break;
    }
    cn1+=2;
  }
  cout<<s1<<endl;
}
0