結果
問題 |
No.401 数字の渦巻き
|
ユーザー |
![]() |
提出日時 | 2025-03-25 16:13:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 917 bytes |
コンパイル時間 | 282 ms |
コンパイル使用メモリ | 28,800 KB |
実行使用メモリ | 816,256 KB |
最終ジャッジ日時 | 2025-03-25 16:13:28 |
合計ジャッジ時間 | 3,024 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 1 MLE * 1 -- * 28 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:5:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 5 | scanf("%d",&val); | ~~~~~^~~~~~~~~~~
ソースコード
#include <stdio.h> int main(){ int val = 0; scanf("%d",&val); // 出力する配列 int ans[val][val]; int reference = 0; int i = 1; while(i != (val * val) + 1){ if(reference % 4 == 0){ // みぎ for(int j = reference / 4;j < val - (reference / 4);j ++){ ans[reference / 4][j] = i; i++; } }else if(reference % 4 == 1){ // した for(int j = reference / 4;j <= val - (reference / 4);j ++){ ans[j][reference / 4] = i; i++; } }else if(reference % 4 == 2){ // ひだり for(int j = val - (reference / 4);j < reference/ 4;j --){ ans[reference / 4][j] = i; i++; } }else if(reference % 4 == 3){ // うえ for(int j = val - (reference / 4);j < reference/ 4;j --){ ans[j][reference / 4] = i; i++; } } reference++; } for(int i = 0;i < val;i ++){ for(int j = 0;j < val;j ++){ printf("%03d ",ans[i][j]); } printf("\n"); } }