結果

問題 No.254 文字列の構成
ユーザー itezpaceitezpace
提出日時 2016-10-29 09:14:43
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 21 ms / 5,000 ms
コード長 528 bytes
コンパイル時間 423 ms
コンパイル使用メモリ 60,980 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-15 22:19:09
合計ジャッジ時間 2,443 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 20 ms
4,380 KB
testcase_18 AC 21 ms
4,500 KB
testcase_19 AC 17 ms
4,380 KB
testcase_20 AC 10 ms
4,376 KB
testcase_21 AC 19 ms
4,376 KB
testcase_22 AC 5 ms
4,380 KB
testcase_23 AC 8 ms
4,376 KB
testcase_24 AC 8 ms
4,376 KB
testcase_25 AC 17 ms
4,380 KB
testcase_26 AC 16 ms
4,380 KB
testcase_27 AC 16 ms
4,380 KB
testcase_28 AC 12 ms
4,376 KB
testcase_29 AC 20 ms
4,376 KB
testcase_30 AC 18 ms
4,380 KB
testcase_31 AC 4 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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