結果
問題 | No.254 文字列の構成 |
ユーザー |
|
提出日時 | 2015-09-15 23:21:28 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 485 bytes |
コンパイル時間 | 194 ms |
コンパイル使用メモリ | 31,360 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 06:38:36 |
合計ジャッジ時間 | 1,284 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’: main.cpp:24:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 24 | scanf("%d", &N); | ~~~~~^~~~~~~~~~
ソースコード
#include <stdio.h> #include <math.h> int const MAX = 100000; void GetStr(int N, char *str){ int i = 0, j = 0; char p[3][2] = { { 'a', 'b' }, { 'c', 'd' }, { 'e', 'f' } }; while(0 < N){ int i = (int)sqrt(double(N)); for(int k = 0; k < 2 * i - 1; ++k){ *str = p[j][k & 1]; ++str; } N -= i * i; ++j; j %= 3; } *str = 0; } int main(int argc, char *argv[]){ char str[MAX + 10]; int N = 0; scanf("%d", &N); GetStr(N, str); printf("%s", str); return 0; }